]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/workspaces.c: prevent re-focus for always-on-top views
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 29 Dec 2022 03:50:21 +0000 (04:50 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 29 Dec 2022 17:58:25 +0000 (18:58 +0100)
Before this patch a focused always-on-top view lost its keyboard
focus when switching workspaces. Now the view keeps its focus.

include/view.h
src/view.c
src/workspaces.c

index f65f7f90a5c3006a527772a980f45fa72bafb136..cf3637cf4af873925420da2dd9354f2a7b533a0e 100644 (file)
@@ -143,6 +143,7 @@ void view_set_fullscreen(struct view *view, bool fullscreen,
 void view_toggle_maximize(struct view *view);
 void view_toggle_decorations(struct view *view);
 void view_toggle_always_on_top(struct view *view);
+bool view_is_always_on_top(struct view *view);
 void view_move_to_workspace(struct view *view, struct workspace *workspace);
 void view_set_decorations(struct view *view, bool decorations);
 void view_toggle_fullscreen(struct view *view);
index b367045eba86ecd5ed37a847f0fa7270c79b78db..f520b3e6f5b48e0c6dcd8244c917ad618e2dc029 100644 (file)
@@ -522,9 +522,10 @@ view_toggle_decorations(struct view *view)
        view_set_decorations(view, !view->ssd_enabled);
 }
 
-static bool
-is_always_on_top(struct view *view)
+bool
+view_is_always_on_top(struct view *view)
 {
+       assert(view);
        return view->scene_tree->node.parent ==
                view->server->view_tree_always_on_top;
 }
@@ -533,7 +534,7 @@ void
 view_toggle_always_on_top(struct view *view)
 {
        assert(view);
-       if (is_always_on_top(view)) {
+       if (view_is_always_on_top(view)) {
                view->workspace = view->server->workspace_current;
                wlr_scene_node_reparent(&view->scene_tree->node,
                        view->workspace->tree);
index 90614e5d0490c411349fd5c1eb303668189bf411..e3c149de8878c92e621606ecd45511d72f1cfe75 100644 (file)
@@ -13,6 +13,7 @@
 #include "common/list.h"
 #include "common/mem.h"
 #include "labwc.h"
+#include "view.h"
 #include "workspaces.h"
 
 /* Internal helpers */
@@ -259,13 +260,14 @@ workspaces_switch_to(struct workspace *target)
        /* Make sure new views will spawn on the new workspace */
        server->workspace_current = target;
 
-       /**
+       /*
         * Make sure we are focusing what the user sees.
-        *
-        * TODO: This is an issue for always-on-top views as they will
-        * loose keyboard focus once switching to another workspace.
+        * Only refocus if the focus is not already on an always-on-top view.
         */
-       desktop_focus_topmost_mapped_view(target->server);
+       struct view *view = desktop_focused_view(server);
+       if (!view || !view_is_always_on_top(view)) {
+               desktop_focus_topmost_mapped_view(server);
+       }
 
        /* And finally show the OSD */
        _osd_show(server);