diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-25 20:56:23 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-26 08:27:07 +1000 |
commit | 27a20a488465468511de9b2307941ac1bc4db8bf (patch) | |
tree | c5c1aff483cb089870ffebec00869347eec29f4c /sway/tree/layout.c | |
parent | Merge pull request #2330 from progandy/set-modifier-locks (diff) | |
download | sway-27a20a488465468511de9b2307941ac1bc4db8bf.tar.gz sway-27a20a488465468511de9b2307941ac1bc4db8bf.tar.zst sway-27a20a488465468511de9b2307941ac1bc4db8bf.zip |
Allow containers to be fullscreen
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 83 |
1 files changed, 49 insertions, 34 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 2b3263f8..ab5acc16 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -66,10 +66,9 @@ static int index_child(const struct sway_container *child) { | |||
66 | 66 | ||
67 | static void container_handle_fullscreen_reparent(struct sway_container *con, | 67 | static void container_handle_fullscreen_reparent(struct sway_container *con, |
68 | struct sway_container *old_parent) { | 68 | struct sway_container *old_parent) { |
69 | if (con->type != C_VIEW || !con->sway_view->is_fullscreen) { | 69 | if (!con->is_fullscreen) { |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | struct sway_view *view = con->sway_view; | ||
73 | struct sway_container *old_workspace = old_parent; | 72 | struct sway_container *old_workspace = old_parent; |
74 | if (old_workspace && old_workspace->type != C_WORKSPACE) { | 73 | if (old_workspace && old_workspace->type != C_WORKSPACE) { |
75 | old_workspace = container_parent(old_workspace, C_WORKSPACE); | 74 | old_workspace = container_parent(old_workspace, C_WORKSPACE); |
@@ -85,19 +84,27 @@ static void container_handle_fullscreen_reparent(struct sway_container *con, | |||
85 | 84 | ||
86 | // Mark the new workspace as fullscreen | 85 | // Mark the new workspace as fullscreen |
87 | if (new_workspace->sway_workspace->fullscreen) { | 86 | if (new_workspace->sway_workspace->fullscreen) { |
88 | view_set_fullscreen(new_workspace->sway_workspace->fullscreen, false); | 87 | container_set_fullscreen( |
88 | new_workspace->sway_workspace->fullscreen, false); | ||
89 | } | 89 | } |
90 | new_workspace->sway_workspace->fullscreen = view; | 90 | new_workspace->sway_workspace->fullscreen = con; |
91 | // Resize view to new output dimensions | 91 | |
92 | // Resize container to new output dimensions | ||
92 | struct sway_container *output = new_workspace->parent; | 93 | struct sway_container *output = new_workspace->parent; |
93 | view->x = output->x; | ||
94 | view->y = output->y; | ||
95 | view->width = output->width; | ||
96 | view->height = output->height; | ||
97 | con->x = output->x; | 94 | con->x = output->x; |
98 | con->y = output->y; | 95 | con->y = output->y; |
99 | con->width = output->width; | 96 | con->width = output->width; |
100 | con->height = output->height; | 97 | con->height = output->height; |
98 | |||
99 | if (con->type == C_VIEW) { | ||
100 | struct sway_view *view = con->sway_view; | ||
101 | view->x = output->x; | ||
102 | view->y = output->y; | ||
103 | view->width = output->width; | ||
104 | view->height = output->height; | ||
105 | } else { | ||
106 | arrange_windows(new_workspace); | ||
107 | } | ||
101 | } | 108 | } |
102 | 109 | ||
103 | void container_insert_child(struct sway_container *parent, | 110 | void container_insert_child(struct sway_container *parent, |
@@ -146,7 +153,7 @@ void container_add_child(struct sway_container *parent, | |||
146 | } | 153 | } |
147 | 154 | ||
148 | struct sway_container *container_remove_child(struct sway_container *child) { | 155 | struct sway_container *container_remove_child(struct sway_container *child) { |
149 | if (child->type == C_VIEW && child->sway_view->is_fullscreen) { | 156 | if (child->is_fullscreen) { |
150 | struct sway_container *workspace = container_parent(child, C_WORKSPACE); | 157 | struct sway_container *workspace = container_parent(child, C_WORKSPACE); |
151 | workspace->sway_workspace->fullscreen = NULL; | 158 | workspace->sway_workspace->fullscreen = NULL; |
152 | } | 159 | } |
@@ -229,10 +236,10 @@ void container_move_to(struct sway_container *container, | |||
229 | if (focus_ws->type != C_WORKSPACE) { | 236 | if (focus_ws->type != C_WORKSPACE) { |
230 | focus_ws = container_parent(focus_ws, C_WORKSPACE); | 237 | focus_ws = container_parent(focus_ws, C_WORKSPACE); |
231 | } | 238 | } |
232 | seat_set_focus(seat, | 239 | if (focus_ws == new_workspace) { |
233 | new_workspace->sway_workspace->fullscreen->swayc); | 240 | struct sway_container *new_focus = seat_get_focus_inactive(seat, |
234 | if (focus_ws != new_workspace) { | 241 | new_workspace->sway_workspace->fullscreen); |
235 | seat_set_focus(seat, focus); | 242 | seat_set_focus(seat, new_focus); |
236 | } | 243 | } |
237 | } | 244 | } |
238 | } | 245 | } |
@@ -375,10 +382,16 @@ void container_move(struct sway_container *container, | |||
375 | struct sway_container *sibling = NULL; | 382 | struct sway_container *sibling = NULL; |
376 | struct sway_container *current = container; | 383 | struct sway_container *current = container; |
377 | struct sway_container *parent = current->parent; | 384 | struct sway_container *parent = current->parent; |
385 | struct sway_container *top = &root_container; | ||
378 | 386 | ||
379 | // If moving a fullscreen view, only consider outputs | 387 | // If moving a fullscreen view, only consider outputs |
380 | if (container->type == C_VIEW && container->sway_view->is_fullscreen) { | 388 | if (container->is_fullscreen) { |
381 | current = container_parent(container, C_OUTPUT); | 389 | current = container_parent(container, C_OUTPUT); |
390 | } else if (container_is_fullscreen_or_child(container)) { | ||
391 | // If we've fullscreened a split container, only allow the child to move | ||
392 | // around within the fullscreen parent. | ||
393 | struct sway_container *ws = container_parent(container, C_WORKSPACE); | ||
394 | top = ws->sway_workspace->fullscreen; | ||
382 | } | 395 | } |
383 | 396 | ||
384 | struct sway_container *new_parent = container_flatten(parent); | 397 | struct sway_container *new_parent = container_flatten(parent); |
@@ -388,7 +401,7 @@ void container_move(struct sway_container *container, | |||
388 | } | 401 | } |
389 | 402 | ||
390 | while (!sibling) { | 403 | while (!sibling) { |
391 | if (current->type == C_ROOT) { | 404 | if (current == top) { |
392 | return; | 405 | return; |
393 | } | 406 | } |
394 | 407 | ||
@@ -452,8 +465,9 @@ void container_move(struct sway_container *container, | |||
452 | if ((index == parent->children->length - 1 && offs > 0) | 465 | if ((index == parent->children->length - 1 && offs > 0) |
453 | || (index == 0 && offs < 0)) { | 466 | || (index == 0 && offs < 0)) { |
454 | if (current->parent == container->parent) { | 467 | if (current->parent == container->parent) { |
455 | if (parent->layout == L_TABBED | 468 | if (!parent->is_fullscreen && |
456 | || parent->layout == L_STACKED) { | 469 | (parent->layout == L_TABBED || |
470 | parent->layout == L_STACKED)) { | ||
457 | move_out_of_tabs_stacks(container, current, | 471 | move_out_of_tabs_stacks(container, current, |
458 | move_dir, offs); | 472 | move_dir, offs); |
459 | return; | 473 | return; |
@@ -474,8 +488,8 @@ void container_move(struct sway_container *container, | |||
474 | sibling = parent->children->items[index + offs]; | 488 | sibling = parent->children->items[index + offs]; |
475 | wlr_log(WLR_DEBUG, "Selecting sibling id:%zd", sibling->id); | 489 | wlr_log(WLR_DEBUG, "Selecting sibling id:%zd", sibling->id); |
476 | } | 490 | } |
477 | } else if (parent->layout == L_TABBED | 491 | } else if (!parent->is_fullscreen && (parent->layout == L_TABBED || |
478 | || parent->layout == L_STACKED) { | 492 | parent->layout == L_STACKED)) { |
479 | move_out_of_tabs_stacks(container, current, move_dir, offs); | 493 | move_out_of_tabs_stacks(container, current, move_dir, offs); |
480 | return; | 494 | return; |
481 | } else { | 495 | } else { |
@@ -707,16 +721,16 @@ struct sway_container *container_get_in_direction( | |||
707 | return NULL; | 721 | return NULL; |
708 | } | 722 | } |
709 | 723 | ||
710 | if (container->type == C_VIEW && container->sway_view->is_fullscreen) { | 724 | if (dir == MOVE_CHILD) { |
711 | if (dir == MOVE_PARENT || dir == MOVE_CHILD) { | 725 | return seat_get_focus_inactive(seat, container); |
726 | } | ||
727 | if (container->is_fullscreen) { | ||
728 | if (dir == MOVE_PARENT) { | ||
712 | return NULL; | 729 | return NULL; |
713 | } | 730 | } |
714 | container = container_parent(container, C_OUTPUT); | 731 | container = container_parent(container, C_OUTPUT); |
715 | parent = container->parent; | 732 | parent = container->parent; |
716 | } else { | 733 | } else { |
717 | if (dir == MOVE_CHILD) { | ||
718 | return seat_get_focus_inactive(seat, container); | ||
719 | } | ||
720 | if (dir == MOVE_PARENT) { | 734 | if (dir == MOVE_PARENT) { |
721 | if (parent->type == C_OUTPUT) { | 735 | if (parent->type == C_OUTPUT) { |
722 | return NULL; | 736 | return NULL; |
@@ -767,7 +781,8 @@ struct sway_container *container_get_in_direction( | |||
767 | } | 781 | } |
768 | sway_assert(next_workspace, "Next container has no workspace"); | 782 | sway_assert(next_workspace, "Next container has no workspace"); |
769 | if (next_workspace->sway_workspace->fullscreen) { | 783 | if (next_workspace->sway_workspace->fullscreen) { |
770 | return next_workspace->sway_workspace->fullscreen->swayc; | 784 | return seat_get_focus_inactive(seat, |
785 | next_workspace->sway_workspace->fullscreen); | ||
771 | } | 786 | } |
772 | if (next->children && next->children->length) { | 787 | if (next->children && next->children->length) { |
773 | // TODO consider floating children as well | 788 | // TODO consider floating children as well |
@@ -1014,13 +1029,13 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) { | |||
1014 | 1029 | ||
1015 | wlr_log(WLR_DEBUG, "Swapping containers %zu and %zu", con1->id, con2->id); | 1030 | wlr_log(WLR_DEBUG, "Swapping containers %zu and %zu", con1->id, con2->id); |
1016 | 1031 | ||
1017 | int fs1 = con1->type == C_VIEW && con1->sway_view->is_fullscreen; | 1032 | int fs1 = con1->is_fullscreen; |
1018 | int fs2 = con2->type == C_VIEW && con2->sway_view->is_fullscreen; | 1033 | int fs2 = con2->is_fullscreen; |
1019 | if (fs1) { | 1034 | if (fs1) { |
1020 | view_set_fullscreen(con1->sway_view, false); | 1035 | container_set_fullscreen(con1, false); |
1021 | } | 1036 | } |
1022 | if (fs2) { | 1037 | if (fs2) { |
1023 | view_set_fullscreen(con2->sway_view, false); | 1038 | container_set_fullscreen(con2, false); |
1024 | } | 1039 | } |
1025 | 1040 | ||
1026 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 1041 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); |
@@ -1053,10 +1068,10 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) { | |||
1053 | prev_workspace_name = stored_prev_name; | 1068 | prev_workspace_name = stored_prev_name; |
1054 | } | 1069 | } |
1055 | 1070 | ||
1056 | if (fs1 && con2->type == C_VIEW) { | 1071 | if (fs1) { |
1057 | view_set_fullscreen(con2->sway_view, true); | 1072 | container_set_fullscreen(con2, true); |
1058 | } | 1073 | } |
1059 | if (fs2 && con1->type == C_VIEW) { | 1074 | if (fs2) { |
1060 | view_set_fullscreen(con1->sway_view, true); | 1075 | container_set_fullscreen(con1, true); |
1061 | } | 1076 | } |
1062 | } | 1077 | } |