summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Pigott <rpigott@berkeley.edu>2020-01-14 17:08:01 -0700
committerDrew DeVault <sir@cmpwn.com>2020-01-22 13:30:52 -0500
commitc52b1cf45ab1be0e6fcc323eb4889c7bd767ba3f (patch)
tree6408bce58a4de66fa7c85b325c33bd7e5ece6730
parentf531e86f7c56183c8c4f9da4b209c7ab207a0f7d (diff)
Fix crash when showing scratchpad hidden split containers
-rw-r--r--include/sway/tree/container.h2
-rw-r--r--sway/commands/focus.c2
-rw-r--r--sway/tree/container.c7
-rw-r--r--sway/tree/root.c5
4 files changed, 15 insertions, 1 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 62c6556bf..5cf5b6b1c 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -357,4 +357,6 @@ void container_raise_floating(struct sway_container *con);
bool container_is_scratchpad_hidden(struct sway_container *con);
+bool container_is_scratchpad_hidden_or_child(struct sway_container *con);
+
#endif
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index d745aab5c..56c3d981c 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -365,7 +365,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
}
if (argc == 0 && container) {
- if (container_is_scratchpad_hidden(container)) {
+ if (container_is_scratchpad_hidden_or_child(container)) {
root_scratchpad_show(container);
}
seat_set_focus_container(seat, container);
diff --git a/sway/tree/container.c b/sway/tree/container.c
index aa819be78..56cdee1da 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1527,3 +1527,10 @@ void container_raise_floating(struct sway_container *con) {
bool container_is_scratchpad_hidden(struct sway_container *con) {
return con->scratchpad && !con->workspace;
}
+
+bool container_is_scratchpad_hidden_or_child(struct sway_container *con) {
+ while (con->parent) {
+ con = con->parent;
+ }
+ return con->scratchpad && !con->workspace;
+}
diff --git a/sway/tree/root.c b/sway/tree/root.c
index 46a140efe..ebd185ec1 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -132,6 +132,11 @@ void root_scratchpad_show(struct sway_container *con) {
if (old_ws) {
container_detach(con);
workspace_consider_destroy(old_ws);
+ } else {
+ // Act on the ancestor of scratchpad hidden split containers
+ while (con->parent) {
+ con = con->parent;
+ }
}
workspace_add_floating(new_ws, con);