From e14176106dd45d5492e1700a5c6543d0bc2a03c7 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Wed, 27 May 2026 01:08:09 +0800 Subject: [PATCH] tree/container: prevent floating windows from inheriting workspace focus When switching to an empty workspace, the workspace itself receives keyboard focus. Previously, being children of the workspace, unfocused floating sticky windows would inherit this visual focus state and render with active titlebars and borders, despite not having keyboard focus. This change ensures floating windows are excluded from inheriting a workspace's visual focus state. --- sway/tree/container.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 6880841bd..7d9bd50f6 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -126,6 +126,17 @@ static bool container_is_focused(struct sway_container *con, void *data) { return con->current.focused; } +static bool container_is_current_floating(struct sway_container *container) { + if (!container->current.parent && container->current.workspace && + list_find(container->current.workspace->floating, container) != -1) { + return true; + } + if (container->scratchpad) { + return true; + } + return false; +} + static bool container_has_focused_child(struct sway_container *con) { return container_find_child(con, container_is_focused, NULL); } @@ -134,7 +145,7 @@ static bool container_is_current_parent_focused(struct sway_container *con) { if (con->current.parent) { struct sway_container *parent = con->current.parent; return parent->current.focused || container_is_current_parent_focused(parent); - } else if (con->current.workspace) { + } else if (con->current.workspace && !container_is_current_floating(con)) { struct sway_workspace *ws = con->current.workspace; return ws->current.focused; } @@ -173,17 +184,6 @@ static struct border_colors *container_get_current_colors( return colors; } -static bool container_is_current_floating(struct sway_container *container) { - if (!container->current.parent && container->current.workspace && - list_find(container->current.workspace->floating, container) != -1) { - return true; - } - if (container->scratchpad) { - return true; - } - return false; -} - // scene rect wants premultiplied colors static void scene_rect_set_color(struct wlr_scene_rect *rect, const float color[4], float opacity) {