aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.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/container.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/container.c')
-rw-r--r--sway/tree/container.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 2a428ca5..ea20991c 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -67,7 +67,11 @@ void container_update_textures_recursive(struct sway_container *con) {
67 } 67 }
68 68
69 if (con->type == C_WORKSPACE) { 69 if (con->type == C_WORKSPACE) {
70 container_update_textures_recursive(con->sway_workspace->floating); 70 for (int i = 0; i < con->sway_workspace->floating->length; ++i) {
71 struct sway_container *floater =
72 con->sway_workspace->floating->items[i];
73 container_update_textures_recursive(floater);
74 }
71 } 75 }
72 } 76 }
73} 77}
@@ -131,6 +135,7 @@ struct sway_container *container_create(enum sway_container_type type) {
131static void container_workspace_free(struct sway_workspace *ws) { 135static void container_workspace_free(struct sway_workspace *ws) {
132 list_foreach(ws->output_priority, free); 136 list_foreach(ws->output_priority, free);
133 list_free(ws->output_priority); 137 list_free(ws->output_priority);
138 list_free(ws->floating);
134 free(ws); 139 free(ws);
135} 140}
136 141
@@ -222,15 +227,14 @@ static struct sway_container *container_workspace_destroy(
222 for (int i = 0; i < workspace->children->length; i++) { 227 for (int i = 0; i < workspace->children->length; i++) {
223 container_move_to(workspace->children->items[i], new_workspace); 228 container_move_to(workspace->children->items[i], new_workspace);
224 } 229 }
225 struct sway_container *floating = workspace->sway_workspace->floating; 230 list_t *floating = workspace->sway_workspace->floating;
226 for (int i = 0; i < floating->children->length; i++) { 231 for (int i = 0; i < floating->length; i++) {
227 container_move_to(floating->children->items[i], 232 struct sway_container *floater = floating->items[i];
228 new_workspace->sway_workspace->floating); 233 container_remove_child(floater);
234 workspace_add_floating(new_workspace, floater);
229 } 235 }
230 } 236 }
231 237
232 container_destroy_noreaping(workspace->sway_workspace->floating);
233
234 return output; 238 return output;
235} 239}
236 240
@@ -339,10 +343,6 @@ static struct sway_container *container_destroy_noreaping(
339} 343}
340 344
341bool container_reap_empty(struct sway_container *con) { 345bool container_reap_empty(struct sway_container *con) {
342 if (con->layout == L_FLOATING) {
343 // Don't reap the magical floating container that each workspace has
344 return false;
345 }
346 switch (con->type) { 346 switch (con->type) {
347 case C_ROOT: 347 case C_ROOT:
348 case C_OUTPUT: 348 case C_OUTPUT:
@@ -626,9 +626,8 @@ static struct sway_container *floating_container_at(double lx, double ly,
626 } 626 }
627 // Items at the end of the list are on top, so iterate the list in 627 // Items at the end of the list are on top, so iterate the list in
628 // reverse. 628 // reverse.
629 for (int k = ws->floating->children->length - 1; k >= 0; --k) { 629 for (int k = ws->floating->length - 1; k >= 0; --k) {
630 struct sway_container *floater = 630 struct sway_container *floater = ws->floating->items[k];
631 ws->floating->children->items[k];
632 struct wlr_box box = { 631 struct wlr_box box = {
633 .x = floater->x, 632 .x = floater->x,
634 .y = floater->y, 633 .y = floater->y,
@@ -664,9 +663,6 @@ struct sway_container *tiling_container_at(
664 return container_at_tabbed(con, lx, ly, surface, sx, sy); 663 return container_at_tabbed(con, lx, ly, surface, sx, sy);
665 case L_STACKED: 664 case L_STACKED:
666 return container_at_stacked(con, lx, ly, surface, sx, sy); 665 return container_at_stacked(con, lx, ly, surface, sx, sy);
667 case L_FLOATING:
668 sway_assert(false, "Didn't expect to see floating here");
669 return NULL;
670 case L_NONE: 666 case L_NONE:
671 return NULL; 667 return NULL;
672 } 668 }
@@ -880,9 +876,6 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe
880 case L_STACKED: 876 case L_STACKED:
881 lenient_strcat(buffer, "S["); 877 lenient_strcat(buffer, "S[");
882 break; 878 break;
883 case L_FLOATING:
884 lenient_strcat(buffer, "F[");
885 break;
886 case L_NONE: 879 case L_NONE:
887 lenient_strcat(buffer, "D["); 880 lenient_strcat(buffer, "D[");
888 break; 881 break;
@@ -1012,7 +1005,7 @@ void container_set_floating(struct sway_container *container, bool enable) {
1012 1005
1013 if (enable) { 1006 if (enable) {
1014 struct sway_container *old_parent = container_remove_child(container); 1007 struct sway_container *old_parent = container_remove_child(container);
1015 container_add_child(workspace->sway_workspace->floating, container); 1008 workspace_add_floating(workspace, container);
1016 container_init_floating(container); 1009 container_init_floating(container);
1017 if (container->type == C_VIEW) { 1010 if (container->type == C_VIEW) {
1018 view_set_tiled(container->sway_view, false); 1011 view_set_tiled(container->sway_view, false);
@@ -1069,11 +1062,8 @@ void container_set_geometry_from_floating_view(struct sway_container *con) {
1069} 1062}
1070 1063
1071bool container_is_floating(struct sway_container *container) { 1064bool container_is_floating(struct sway_container *container) {
1072 struct sway_container *workspace = container_parent(container, C_WORKSPACE); 1065 return container->parent && container->parent->type == C_WORKSPACE &&
1073 if (!workspace) { 1066 list_find(container->parent->sway_workspace->floating, container) != -1;
1074 return false;
1075 }
1076 return container->parent == workspace->sway_workspace->floating;
1077} 1067}
1078 1068
1079void container_get_box(struct sway_container *container, struct wlr_box *box) { 1069void container_get_box(struct sway_container *container, struct wlr_box *box) {
@@ -1153,7 +1143,7 @@ void container_floating_move_to(struct sway_container *con,
1153 output_get_active_workspace(new_output->sway_output); 1143 output_get_active_workspace(new_output->sway_output);
1154 if (old_workspace != new_workspace) { 1144 if (old_workspace != new_workspace) {
1155 container_remove_child(con); 1145 container_remove_child(con);
1156 container_add_child(new_workspace->sway_workspace->floating, con); 1146 workspace_add_floating(new_workspace, con);
1157 arrange_windows(old_workspace); 1147 arrange_windows(old_workspace);
1158 arrange_windows(new_workspace); 1148 arrange_windows(new_workspace);
1159 workspace_detect_urgent(old_workspace); 1149 workspace_detect_urgent(old_workspace);
@@ -1266,14 +1256,10 @@ void container_set_fullscreen(struct sway_container *container, bool enable) {
1266} 1256}
1267 1257
1268bool container_is_floating_or_child(struct sway_container *container) { 1258bool container_is_floating_or_child(struct sway_container *container) {
1269 do { 1259 while (container->parent && container->parent->type != C_WORKSPACE) {
1270 if (container->parent && container->parent->layout == L_FLOATING) {
1271 return true;
1272 }
1273 container = container->parent; 1260 container = container->parent;
1274 } while (container && container->type != C_WORKSPACE); 1261 }
1275 1262 return container_is_floating(container);
1276 return false;
1277} 1263}
1278 1264
1279bool container_is_fullscreen_or_child(struct sway_container *container) { 1265bool container_is_fullscreen_or_child(struct sway_container *container) {