aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/root.c
diff options
context:
space:
mode:
authorLibravatar Rouven Czerwinski <rouven@czerwinskis.de>2019-06-16 17:36:00 +0200
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-06-16 12:29:16 -0400
commitddad41f423db14f89f765fc134d45d1ea8a60caf (patch)
tree02a17ffe6af7d5939129f02291036cb1633dddf9 /sway/tree/root.c
parentAdd missing underscore in bindswitch documentation (diff)
downloadsway-ddad41f423db14f89f765fc134d45d1ea8a60caf.tar.gz
sway-ddad41f423db14f89f765fc134d45d1ea8a60caf.tar.zst
sway-ddad41f423db14f89f765fc134d45d1ea8a60caf.zip
Fix sway crashes for scratchpad layouts
Currently container_replace removes the container from the scratchpad and re-adds it afterwards. For the split commands this results in the container being send to the scratchpad, which results in a NULL segfault if the same container should be shown. Pass an optional workspace to root_scratchpad_add_container, if the workspace is passed the window will continue to show on the workspace. If NULL is passed it is sent to the scratchpad. This was an issue if no other window except the scratchpad container was on the workspace. Fixes #4240
Diffstat (limited to 'sway/tree/root.c')
-rw-r--r--sway/tree/root.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c
index 1dabc287..55d78487 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -54,7 +54,7 @@ void root_destroy(struct sway_root *root) {
54 free(root); 54 free(root);
55} 55}
56 56
57void root_scratchpad_add_container(struct sway_container *con) { 57void root_scratchpad_add_container(struct sway_container *con, struct sway_workspace *ws) {
58 if (!sway_assert(!con->scratchpad, "Container is already in scratchpad")) { 58 if (!sway_assert(!con->scratchpad, "Container is already in scratchpad")) {
59 return; 59 return;
60 } 60 }
@@ -77,18 +77,23 @@ void root_scratchpad_add_container(struct sway_container *con) {
77 container_detach(con); 77 container_detach(con);
78 con->scratchpad = true; 78 con->scratchpad = true;
79 list_add(root->scratchpad, con); 79 list_add(root->scratchpad, con);
80 80 if (ws) {
81 struct sway_seat *seat = input_manager_current_seat(); 81 workspace_add_floating(ws, con);
82 struct sway_node *new_focus = NULL;
83 if (parent) {
84 arrange_container(parent);
85 new_focus = seat_get_focus_inactive(seat, &parent->node);
86 } 82 }
87 if (!new_focus) { 83
88 arrange_workspace(workspace); 84 if (!ws) {
89 new_focus = seat_get_focus_inactive(seat, &workspace->node); 85 struct sway_seat *seat = input_manager_current_seat();
86 struct sway_node *new_focus = NULL;
87 if (parent) {
88 arrange_container(parent);
89 new_focus = seat_get_focus_inactive(seat, &parent->node);
90 }
91 if (!new_focus) {
92 arrange_workspace(workspace);
93 new_focus = seat_get_focus_inactive(seat, &workspace->node);
94 }
95 seat_set_focus(seat, new_focus);
90 } 96 }
91 seat_set_focus(seat, new_focus);
92 97
93 ipc_event_window(con, "move"); 98 ipc_event_window(con, "move");
94} 99}