commands/focus: handle NULL workspace in focus_mode

Avoid executing `focus tiling` on a container that is in the scratchpad,
and therefore has a NULL workspace.
This commit is contained in:
Scott Leggett 2026-05-27 09:35:39 +08:00
parent f1b40bc288
commit c269413c17
No known key found for this signature in database

View file

@ -260,6 +260,10 @@ static struct sway_node *node_get_in_direction_floating(
static struct cmd_results *focus_mode(struct sway_workspace *ws, static struct cmd_results *focus_mode(struct sway_workspace *ws,
struct sway_seat *seat, bool floating) { struct sway_seat *seat, bool floating) {
if (!ws) {
return cmd_results_new(CMD_FAILURE,
"Target container is not in a workspace");
}
struct sway_container *new_focus = NULL; struct sway_container *new_focus = NULL;
if (floating) { if (floating) {
new_focus = seat_get_focus_inactive_floating(seat, ws); new_focus = seat_get_focus_inactive_floating(seat, ws);