diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-26 22:42:58 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-28 22:41:04 +1000 |
commit | 936168e740067a8658c7097ff76588b070faa71f (patch) | |
tree | c16935258c2b040f4a49a236893801bfe9331be2 | |
parent | Fix crash when a child of a floating container is in the scratchpad (diff) | |
download | sway-936168e740067a8658c7097ff76588b070faa71f.tar.gz sway-936168e740067a8658c7097ff76588b070faa71f.tar.zst sway-936168e740067a8658c7097ff76588b070faa71f.zip |
Operate on floating split container when a child is focused
-rw-r--r-- | sway/commands/floating.c | 8 | ||||
-rw-r--r-- | sway/commands/scratchpad.c | 12 | ||||
-rw-r--r-- | sway/scratchpad.c | 9 |
3 files changed, 27 insertions, 2 deletions
diff --git a/sway/commands/floating.c b/sway/commands/floating.c index b67e736f..31de5ec3 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c | |||
@@ -29,6 +29,14 @@ struct cmd_results *cmd_floating(int argc, char **argv) { | |||
29 | seat_set_focus(config->handler_context.seat, container); | 29 | seat_set_focus(config->handler_context.seat, container); |
30 | } | 30 | } |
31 | 31 | ||
32 | // If the container is in a floating split container, | ||
33 | // operate on the split container instead of the child. | ||
34 | if (container_is_floating_or_child(container)) { | ||
35 | while (container->parent->layout != L_FLOATING) { | ||
36 | container = container->parent; | ||
37 | } | ||
38 | } | ||
39 | |||
32 | bool wants_floating; | 40 | bool wants_floating; |
33 | if (strcasecmp(argv[0], "enable") == 0) { | 41 | if (strcasecmp(argv[0], "enable") == 0) { |
34 | wants_floating = true; | 42 | wants_floating = true; |
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index ccc07c87..01a91d65 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c | |||
@@ -19,11 +19,19 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | if (config->handler_context.using_criteria) { | 21 | if (config->handler_context.using_criteria) { |
22 | struct sway_container *con = config->handler_context.current_container; | ||
23 | |||
24 | // If the container is in a floating split container, | ||
25 | // operate on the split container instead of the child. | ||
26 | if (container_is_floating_or_child(con)) { | ||
27 | while (con->parent->layout != L_FLOATING) { | ||
28 | con = con->parent; | ||
29 | } | ||
30 | } | ||
31 | |||
22 | // If using criteria, this command is executed for every container which | 32 | // If using criteria, this command is executed for every container which |
23 | // matches the criteria. If this container isn't in the scratchpad, | 33 | // matches the criteria. If this container isn't in the scratchpad, |
24 | // we'll just silently return a success. | 34 | // we'll just silently return a success. |
25 | struct sway_container *con = config->handler_context.current_container; | ||
26 | wlr_log(WLR_INFO, "cmd_scratchpad(%s)", con->name); | ||
27 | if (!con->scratchpad) { | 35 | if (!con->scratchpad) { |
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 36 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
29 | } | 37 | } |
diff --git a/sway/scratchpad.c b/sway/scratchpad.c index 181d9b3b..787af6e1 100644 --- a/sway/scratchpad.c +++ b/sway/scratchpad.c | |||
@@ -110,6 +110,15 @@ void scratchpad_toggle_auto(void) { | |||
110 | struct sway_container *ws = focus->type == C_WORKSPACE ? | 110 | struct sway_container *ws = focus->type == C_WORKSPACE ? |
111 | focus : container_parent(focus, C_WORKSPACE); | 111 | focus : container_parent(focus, C_WORKSPACE); |
112 | 112 | ||
113 | // If the focus is in a floating split container, | ||
114 | // operate on the split container instead of the child. | ||
115 | if (container_is_floating_or_child(focus)) { | ||
116 | while (focus->parent->layout != L_FLOATING) { | ||
117 | focus = focus->parent; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | |||
113 | // Check if the currently focused window is a scratchpad window and should | 122 | // Check if the currently focused window is a scratchpad window and should |
114 | // be hidden again. | 123 | // be hidden again. |
115 | if (focus->scratchpad) { | 124 | if (focus->scratchpad) { |