aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.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/container.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/container.c')
-rw-r--r--sway/tree/container.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index c4d21f0a..89a47151 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1378,10 +1378,12 @@ void container_replace(struct sway_container *container,
1378 struct sway_container *replacement) { 1378 struct sway_container *replacement) {
1379 enum sway_fullscreen_mode fullscreen = container->fullscreen_mode; 1379 enum sway_fullscreen_mode fullscreen = container->fullscreen_mode;
1380 bool scratchpad = container->scratchpad; 1380 bool scratchpad = container->scratchpad;
1381 struct sway_workspace *ws = NULL;
1381 if (fullscreen != FULLSCREEN_NONE) { 1382 if (fullscreen != FULLSCREEN_NONE) {
1382 container_fullscreen_disable(container); 1383 container_fullscreen_disable(container);
1383 } 1384 }
1384 if (scratchpad) { 1385 if (scratchpad) {
1386 ws = container->workspace;
1385 root_scratchpad_show(container); 1387 root_scratchpad_show(container);
1386 root_scratchpad_remove_container(container); 1388 root_scratchpad_remove_container(container);
1387 } 1389 }
@@ -1390,7 +1392,7 @@ void container_replace(struct sway_container *container,
1390 container_detach(container); 1392 container_detach(container);
1391 } 1393 }
1392 if (scratchpad) { 1394 if (scratchpad) {
1393 root_scratchpad_add_container(replacement); 1395 root_scratchpad_add_container(replacement, ws);
1394 } 1396 }
1395 switch (fullscreen) { 1397 switch (fullscreen) {
1396 case FULLSCREEN_WORKSPACE: 1398 case FULLSCREEN_WORKSPACE: