aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-19 15:07:07 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-19 16:18:33 +1000
commit2b5a404ac920339a2b9ce32d4718272dee4668b9 (patch)
tree681f45a530a1f8d5966161291c3cb482e52edb6e /sway/tree/layout.c
parentMerge pull request #2453 from ianyfan/commands (diff)
downloadsway-2b5a404ac920339a2b9ce32d4718272dee4668b9.tar.gz
sway-2b5a404ac920339a2b9ce32d4718272dee4668b9.tar.zst
sway-2b5a404ac920339a2b9ce32d4718272dee4668b9.zip
Replace hacky L_FLOATING container with a list
Workspaces previously had a magical `workspace->floating` container, which had a layout of L_FLOATING and whose children were actual floating views. This allowed some conveniences, but was a hacky solution because the container has to be exempt from focus, coordinate transactions with the workspace, and omit emitting IPC events (which we didn't do). This commit changes it to be a list directly in the sway_workspace. The L_FLOATING layout is no longer used so this has been removed as well. * Fixes incorrect check in the swap command (it checked if the containers had the L_FLOATING layout, but this layout applied to the magical container). * Introduces workspace_add_floating
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 49ec806e..2f22a3dd 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -117,9 +117,11 @@ struct sway_container *container_remove_child(struct sway_container *child) {
117 } 117 }
118 118
119 struct sway_container *parent = child->parent; 119 struct sway_container *parent = child->parent;
120 int index = index_child(child); 120 list_t *list = container_is_floating(child) ?
121 parent->sway_workspace->floating : parent->children;
122 int index = list_find(list, child);
121 if (index != -1) { 123 if (index != -1) {
122 list_del(parent->children, index); 124 list_del(list, index);
123 } 125 }
124 child->parent = NULL; 126 child->parent = NULL;
125 container_notify_subtree_changed(parent); 127 container_notify_subtree_changed(parent);
@@ -160,7 +162,8 @@ void container_move_to(struct sway_container *container,
160 struct sway_container *old_output = 162 struct sway_container *old_output =
161 container_parent(container, C_OUTPUT); 163 container_parent(container, C_OUTPUT);
162 old_parent = container_remove_child(container); 164 old_parent = container_remove_child(container);
163 container_add_child(new_ws->sway_workspace->floating, container); 165 workspace_add_floating(new_ws, container);
166 container_handle_fullscreen_reparent(container, old_parent);
164 // If changing output, center it within the workspace 167 // If changing output, center it within the workspace
165 if (old_output != new_ws->parent && !container->is_fullscreen) { 168 if (old_output != new_ws->parent && !container->is_fullscreen) {
166 container_floating_move_to_center(container); 169 container_floating_move_to_center(container);
@@ -431,9 +434,6 @@ void container_move(struct sway_container *container,
431 if ((index == parent->children->length - 1 && offs > 0) 434 if ((index == parent->children->length - 1 && offs > 0)
432 || (index == 0 && offs < 0)) { 435 || (index == 0 && offs < 0)) {
433 if (current->parent == container->parent) { 436 if (current->parent == container->parent) {
434 if (parent->parent->layout == L_FLOATING) {
435 return;
436 }
437 if (!parent->is_fullscreen && 437 if (!parent->is_fullscreen &&
438 (parent->layout == L_TABBED || 438 (parent->layout == L_TABBED ||
439 parent->layout == L_STACKED)) { 439 parent->layout == L_STACKED)) {
@@ -457,14 +457,10 @@ void container_move(struct sway_container *container,
457 sibling = parent->children->items[index + offs]; 457 sibling = parent->children->items[index + offs];
458 wlr_log(WLR_DEBUG, "Selecting sibling id:%zd", sibling->id); 458 wlr_log(WLR_DEBUG, "Selecting sibling id:%zd", sibling->id);
459 } 459 }
460 } else if (!parent->is_fullscreen && 460 } else if (!parent->is_fullscreen && (parent->layout == L_TABBED ||
461 parent->parent->layout != L_FLOATING &&
462 (parent->layout == L_TABBED ||
463 parent->layout == L_STACKED)) { 461 parent->layout == L_STACKED)) {
464 move_out_of_tabs_stacks(container, current, move_dir, offs); 462 move_out_of_tabs_stacks(container, current, move_dir, offs);
465 return; 463 return;
466 } else if (parent->parent->layout == L_FLOATING) {
467 return;
468 } else { 464 } else {
469 wlr_log(WLR_DEBUG, "Moving up to find a parallel container"); 465 wlr_log(WLR_DEBUG, "Moving up to find a parallel container");
470 current = current->parent; 466 current = current->parent;
@@ -802,13 +798,15 @@ struct sway_container *container_replace_child(struct sway_container *child,
802 if (parent == NULL) { 798 if (parent == NULL) {
803 return NULL; 799 return NULL;
804 } 800 }
805 int i = index_child(child);
806 801
807 // TODO floating 802 list_t *list = container_is_floating(child) ?
803 parent->sway_workspace->floating : parent->children;
804 int i = list_find(list, child);
805
808 if (new_child->parent) { 806 if (new_child->parent) {
809 container_remove_child(new_child); 807 container_remove_child(new_child);
810 } 808 }
811 parent->children->items[i] = new_child; 809 list->items[i] = new_child;
812 new_child->parent = parent; 810 new_child->parent = parent;
813 child->parent = NULL; 811 child->parent = NULL;
814 812
@@ -973,7 +971,8 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) {
973 "Cannot swap ancestor and descendant")) { 971 "Cannot swap ancestor and descendant")) {
974 return; 972 return;
975 } 973 }
976 if (!sway_assert(con1->layout != L_FLOATING && con2->layout != L_FLOATING, 974 if (!sway_assert(!container_is_floating(con1)
975 && !container_is_floating(con2),
977 "Swapping with floating containers is not supported")) { 976 "Swapping with floating containers is not supported")) {
978 return; 977 return;
979 } 978 }