aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-04-02 15:30:58 -0400
committeremersion <contact@emersion.fr>2018-04-02 15:30:58 -0400
commita4a241697ae591289d7c14eff972e1ef787216e2 (patch)
treed82d3c3eba2946670aa634a62d03feb7102f0bf8 /sway/tree/layout.c
parent2f64ce86c47efb2ee4c0e3a3c2b31307d21404d9 (diff)
parent0c0cc79282b5ce29616893977aca629f90521988 (diff)
downloadsway-a4a241697ae591289d7c14eff972e1ef787216e2.tar.xz
Merge branch 'wlroots' into view-redesign
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 122ea494..3333f9f1 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -106,8 +106,10 @@ struct sway_container *container_reap_empty(struct sway_container *container) {
if (!sway_assert(container, "reaping null container")) {
return NULL;
}
- wlr_log(L_DEBUG, "reaping %p %s", container, container->name);
- while (container != &root_container && container->children->length == 0) {
+ wlr_log(L_DEBUG, "Reaping %p %s '%s'", container,
+ container_type_to_str(container->type), container->name);
+ while (container->type != C_ROOT && container->type != C_OUTPUT
+ && container->children->length == 0) {
if (container->type == C_WORKSPACE) {
if (!workspace_is_visible(container)) {
struct sway_container *parent = container->parent;
@@ -138,22 +140,46 @@ struct sway_container *container_remove_child(struct sway_container *child) {
return container_reap_empty(parent);
}
-void container_move_to(struct sway_container* container,
- struct sway_container* destination) {
+void container_move_to(struct sway_container *container,
+ struct sway_container *destination) {
if (container == destination
|| container_has_anscestor(container, destination)) {
return;
}
struct sway_container *old_parent = container_remove_child(container);
container->width = container->height = 0;
- struct sway_container *new_parent =
- container_add_sibling(destination, container);
+ struct sway_container *new_parent;
+ if (destination->type == C_VIEW) {
+ new_parent = container_add_sibling(destination, container);
+ } else {
+ new_parent = destination;
+ container_add_child(destination, container);
+ }
+ wl_signal_emit(&container->events.reparent, old_parent);
+ if (container->type == C_WORKSPACE) {
+ struct sway_seat *seat = input_manager_get_default_seat(
+ input_manager);
+ if (old_parent->children->length == 0) {
+ char *ws_name = workspace_next_name(old_parent->name);
+ struct sway_container *ws =
+ container_workspace_create(old_parent, ws_name);
+ free(ws_name);
+ seat_set_focus(seat, ws);
+ }
+ container_sort_workspaces(new_parent);
+ seat_set_focus(seat, new_parent);
+ }
if (old_parent) {
arrange_windows(old_parent, -1, -1);
}
arrange_windows(new_parent, -1, -1);
}
+void container_move(struct sway_container *container,
+ enum movement_direction dir, int move_amt) {
+ // TODO
+}
+
enum sway_container_layout container_get_default_layout(
struct sway_container *output) {
if (config->default_layout != L_NONE) {
@@ -248,8 +274,8 @@ void arrange_windows(struct sway_container *container,
struct wlr_box *area = &output->sway_output->usable_area;
wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
area->width, area->height, area->x, area->y);
- container->width = area->width;
- container->height = area->height;
+ container->width = width = area->width;
+ container->height = height = area->height;
container->x = x = area->x;
container->y = y = area->y;
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
@@ -406,7 +432,7 @@ static struct sway_container *get_swayc_in_output_direction(
return NULL;
}
- struct sway_container *ws = sway_seat_get_focus_inactive(seat, output);
+ struct sway_container *ws = seat_get_focus_inactive(seat, output);
if (ws->type != C_WORKSPACE) {
ws = container_parent(ws, C_WORKSPACE);
}
@@ -427,7 +453,7 @@ static struct sway_container *get_swayc_in_output_direction(
case MOVE_UP:
case MOVE_DOWN: {
struct sway_container *focused =
- sway_seat_get_focus_inactive(seat, ws);
+ seat_get_focus_inactive(seat, ws);
if (focused && focused->parent) {
struct sway_container *parent = focused->parent;
if (parent->layout == L_VERT) {
@@ -511,7 +537,7 @@ static struct sway_container *get_swayc_in_direction_under(
struct sway_container *container, enum movement_direction dir,
struct sway_seat *seat, struct sway_container *limit) {
if (dir == MOVE_CHILD) {
- return sway_seat_get_focus_inactive(seat, container);
+ return seat_get_focus_inactive(seat, container);
}
struct sway_container *parent = container->parent;
@@ -523,26 +549,6 @@ static struct sway_container *get_swayc_in_direction_under(
}
}
- if (dir == MOVE_PREV || dir == MOVE_NEXT) {
- int focused_idx = index_child(container);
- if (focused_idx == -1) {
- return NULL;
- } else {
- int desired = (focused_idx + (dir == MOVE_NEXT ? 1 : -1)) %
- parent->children->length;
- if (desired < 0) {
- desired += parent->children->length;
- }
- return parent->children->items[desired];
- }
- }
-
- // If moving to an adjacent output we need a starting position (since this
- // output might border to multiple outputs).
- //struct wlc_point abs_pos;
- //get_layout_center_position(container, &abs_pos);
-
-
// TODO WLR fullscreen
/*
if (container->type == C_VIEW && swayc_is_fullscreen(container)) {
@@ -591,7 +597,7 @@ static struct sway_container *get_swayc_in_direction_under(
}
if (next->children && next->children->length) {
// TODO consider floating children as well
- return sway_seat_get_focus_inactive(seat, next);
+ return seat_get_focus_inactive(seat, next);
} else {
return next;
}