Skip to content

Commit e4e579e

Browse files
RedSoxFanddevault
authored andcommitted
workspace_get_initial_output: handle focused layer
When a layer surface is focused, `seat_get_focused_workspace` will be NULL. This changes `workspace_get_initial_output` to use output of the focus inactive. If the focus inactive is also NULL, then either the first output or the noop output will be used as fallbacks.
1 parent 40023d4 commit e4e579e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sway/tree/workspace.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ struct sway_output *workspace_get_initial_output(const char *name) {
4242
}
4343
}
4444
}
45-
// Otherwise put it on the focused output
45+
// Otherwise try to put it on the focused output
4646
struct sway_seat *seat = input_manager_current_seat();
47-
struct sway_workspace *focus = seat_get_focused_workspace(seat);
48-
return focus->output;
47+
struct sway_node *focus = seat_get_focus_inactive(seat, &root->node);
48+
if (focus && focus->type == N_WORKSPACE) {
49+
return focus->sway_workspace->output;
50+
} else if (focus && focus->type == N_CONTAINER) {
51+
return focus->sway_container->workspace->output;
52+
}
53+
// Fallback to the first output or noop output for headless
54+
return root->outputs->length ? root->outputs->items[0] : root->noop_output;
4955
}
5056

5157
static void prevent_invalid_outer_gaps(struct sway_workspace *ws) {

0 commit comments

Comments
 (0)