mirror of
https://github.com/swaywm/sway.git
synced 2026-04-29 06:46:22 -04:00
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.
This commit is contained in:
parent
bea9f9c63f
commit
908095ef9a
12 changed files with 42 additions and 25 deletions
|
|
@ -179,7 +179,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
|
|||
new_focus = seat_get_focus_inactive_tiling(seat, ws);
|
||||
}
|
||||
if (new_focus) {
|
||||
seat_set_focus(seat, &new_focus->node);
|
||||
seat_set_focus_container(seat, new_focus);
|
||||
} else {
|
||||
return cmd_results_new(CMD_FAILURE, "focus",
|
||||
"Failed to find a %s container in workspace",
|
||||
|
|
@ -230,8 +230,8 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
|
|||
"Command 'focus' cannot be used above the workspace level");
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
seat_set_focus(seat, node);
|
||||
if (argc == 0 && container) {
|
||||
seat_set_focus_container(seat, container);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue