diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-25 15:39:14 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-01 23:14:58 +1000 |
commit | dc83b158e12ae33f03165cfd64a50aa7f0a52e26 (patch) | |
tree | a618595ef3b8c2eb29004cf8479742dc012a4561 /sway/tree/container.c | |
parent | Fix unfullscreening a floating view (diff) | |
download | sway-dc83b158e12ae33f03165cfd64a50aa7f0a52e26.tar.gz sway-dc83b158e12ae33f03165cfd64a50aa7f0a52e26.tar.zst sway-dc83b158e12ae33f03165cfd64a50aa7f0a52e26.zip |
Fix issues with sticky containers and workspaces
* Attach sticky containers to new workspaces when switching
* Fire the close event *before* we start destroying the workspace to
prevent a crash
Because the sticky container now follows the visible workspace, this
simplifies the rendering and container_at logic.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index fd7ee2c3..532722e8 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -64,16 +64,6 @@ void container_create_notify(struct sway_container *container) { | |||
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | static void container_close_notify(struct sway_container *container) { | ||
68 | if (container == NULL) { | ||
69 | return; | ||
70 | } | ||
71 | // TODO send ipc event type based on the container type | ||
72 | if (container->type == C_VIEW || container->type == C_WORKSPACE) { | ||
73 | ipc_event_window(container, "close"); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | static void container_update_textures_recursive(struct sway_container *con) { | 67 | static void container_update_textures_recursive(struct sway_container *con) { |
78 | container_update_title_textures(con); | 68 | container_update_title_textures(con); |
79 | 69 | ||
@@ -143,7 +133,6 @@ static void _container_destroy(struct sway_container *cont) { | |||
143 | } | 133 | } |
144 | 134 | ||
145 | wl_signal_emit(&cont->events.destroy, cont); | 135 | wl_signal_emit(&cont->events.destroy, cont); |
146 | container_close_notify(cont); | ||
147 | 136 | ||
148 | struct sway_container *parent = cont->parent; | 137 | struct sway_container *parent = cont->parent; |
149 | if (cont->children != NULL && cont->children->length) { | 138 | if (cont->children != NULL && cont->children->length) { |
@@ -151,6 +140,7 @@ static void _container_destroy(struct sway_container *cont) { | |||
151 | // container_remove_child, which removes child from this container | 140 | // container_remove_child, which removes child from this container |
152 | while (cont->children != NULL && cont->children->length > 0) { | 141 | while (cont->children != NULL && cont->children->length > 0) { |
153 | struct sway_container *child = cont->children->items[0]; | 142 | struct sway_container *child = cont->children->items[0]; |
143 | ipc_event_window(child, "close"); | ||
154 | container_remove_child(child); | 144 | container_remove_child(child); |
155 | _container_destroy(child); | 145 | _container_destroy(child); |
156 | } | 146 | } |
@@ -188,12 +178,11 @@ static struct sway_container *container_workspace_destroy( | |||
188 | return NULL; | 178 | return NULL; |
189 | } | 179 | } |
190 | 180 | ||
181 | wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name); | ||
182 | ipc_event_window(workspace, "close"); | ||
183 | |||
191 | struct sway_container *parent = workspace->parent; | 184 | struct sway_container *parent = workspace->parent; |
192 | if (workspace_is_empty(workspace)) { | 185 | if (!workspace_is_empty(workspace) && output) { |
193 | // destroy the WS if there are no children | ||
194 | wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name); | ||
195 | ipc_event_workspace(workspace, NULL, "empty"); | ||
196 | } else if (output) { | ||
197 | // Move children to a different workspace on this output | 186 | // Move children to a different workspace on this output |
198 | struct sway_container *new_workspace = NULL; | 187 | struct sway_container *new_workspace = NULL; |
199 | for (int i = 0; i < output->children->length; i++) { | 188 | for (int i = 0; i < output->children->length; i++) { |
@@ -357,10 +346,12 @@ struct sway_container *container_destroy(struct sway_container *con) { | |||
357 | if (con->children->length) { | 346 | if (con->children->length) { |
358 | for (int i = 0; i < con->children->length; ++i) { | 347 | for (int i = 0; i < con->children->length; ++i) { |
359 | struct sway_container *child = con->children->items[0]; | 348 | struct sway_container *child = con->children->items[0]; |
349 | ipc_event_window(child, "close"); | ||
360 | container_remove_child(child); | 350 | container_remove_child(child); |
361 | container_add_child(parent, child); | 351 | container_add_child(parent, child); |
362 | } | 352 | } |
363 | } | 353 | } |
354 | ipc_event_window(con, "close"); | ||
364 | _container_destroy(con); | 355 | _container_destroy(con); |
365 | break; | 356 | break; |
366 | case C_VIEW: | 357 | case C_VIEW: |
@@ -635,20 +626,20 @@ struct sway_container *floating_container_at(double lx, double ly, | |||
635 | for (int j = 0; j < output->children->length; ++j) { | 626 | for (int j = 0; j < output->children->length; ++j) { |
636 | struct sway_container *workspace = output->children->items[j]; | 627 | struct sway_container *workspace = output->children->items[j]; |
637 | struct sway_workspace *ws = workspace->sway_workspace; | 628 | struct sway_workspace *ws = workspace->sway_workspace; |
638 | bool ws_is_visible = workspace_is_visible(workspace); | 629 | if (!workspace_is_visible(workspace)) { |
630 | continue; | ||
631 | } | ||
639 | for (int k = 0; k < ws->floating->children->length; ++k) { | 632 | for (int k = 0; k < ws->floating->children->length; ++k) { |
640 | struct sway_container *floater = | 633 | struct sway_container *floater = |
641 | ws->floating->children->items[k]; | 634 | ws->floating->children->items[k]; |
642 | if (ws_is_visible || floater->is_sticky) { | 635 | struct wlr_box box = { |
643 | struct wlr_box box = { | 636 | .x = floater->x, |
644 | .x = floater->x, | 637 | .y = floater->y, |
645 | .y = floater->y, | 638 | .width = floater->width, |
646 | .width = floater->width, | 639 | .height = floater->height, |
647 | .height = floater->height, | 640 | }; |
648 | }; | 641 | if (wlr_box_contains_point(&box, lx, ly)) { |
649 | if (wlr_box_contains_point(&box, lx, ly)) { | 642 | return container_at(floater, lx, ly, surface, sx, sy); |
650 | return container_at(floater, lx, ly, surface, sx, sy); | ||
651 | } | ||
652 | } | 643 | } |
653 | } | 644 | } |
654 | } | 645 | } |