diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-06 19:26:56 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-06 19:26:56 +1000 |
commit | 908095ef9a479cafaf7d815824f243b4576ff1bb (patch) | |
tree | 812b58eae73d0816610e93c6595facb42b141536 /sway/commands/focus.c | |
parent | Merge pull request #2578 from RyanDwyer/fix-binding-reload (diff) | |
download | sway-908095ef9a479cafaf7d815824f243b4576ff1bb.tar.gz sway-908095ef9a479cafaf7d815824f243b4576ff1bb.tar.zst sway-908095ef9a479cafaf7d815824f243b4576ff1bb.zip |
Introduce seat_set_focus_container and seat_set_focus_workspace
These are the same as seat_set_focus, but accept a specific type rather
than using nodes. Doing this adds more typesafety and lets us avoid
using &con->node which looks a little ugly.
This fixes a crash that pretty much nobody would ever come across. If
you have a bindsym for "focus" with no arguments and run it from an
empty workspace, sway would crash because it assumes `container` is not
NULL.
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r-- | sway/commands/focus.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 58721b7e..668a0c7b 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -179,7 +179,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws, | |||
179 | new_focus = seat_get_focus_inactive_tiling(seat, ws); | 179 | new_focus = seat_get_focus_inactive_tiling(seat, ws); |
180 | } | 180 | } |
181 | if (new_focus) { | 181 | if (new_focus) { |
182 | seat_set_focus(seat, &new_focus->node); | 182 | seat_set_focus_container(seat, new_focus); |
183 | } else { | 183 | } else { |
184 | return cmd_results_new(CMD_FAILURE, "focus", | 184 | return cmd_results_new(CMD_FAILURE, "focus", |
185 | "Failed to find a %s container in workspace", | 185 | "Failed to find a %s container in workspace", |
@@ -230,8 +230,8 @@ struct cmd_results *cmd_focus(int argc, char **argv) { | |||
230 | "Command 'focus' cannot be used above the workspace level"); | 230 | "Command 'focus' cannot be used above the workspace level"); |
231 | } | 231 | } |
232 | 232 | ||
233 | if (argc == 0) { | 233 | if (argc == 0 && container) { |
234 | seat_set_focus(seat, node); | 234 | seat_set_focus_container(seat, container); |
235 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 235 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
236 | } | 236 | } |
237 | 237 | ||