]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: assume views wanting decorations also want focus
authorJohn Lindgren <john@jlindgren.net>
Mon, 16 Oct 2023 01:33:18 +0000 (21:33 -0400)
committerJohn Lindgren <john@jlindgren.net>
Mon, 16 Oct 2023 21:13:52 +0000 (17:13 -0400)
Assume that Globally Active xwayland views do want focus if they want
window decorations (according to _MOTIF_WM_HINTS). This is a stop-gap
fix to ensure that various applications (mainly Java-based ones such as
IntelliJ IDEA) get focus normally and appear in the window switcher. It
would be better to match based on _NET_WM_WINDOW_TYPE instead, but that
property isn't currently available through wlroots API.

Fixes (partially): 7e72bf975fb65c8290b398d21b2ad9d87a22880f
("view/xwayland: avoid focusing views that don't want focus")

src/xwayland.c

index a8109bfec528f8e546522331495fcf99ce86a312..4b1fc7ee1e6802c8f51fc20a57914664d23ddfd9 100644 (file)
@@ -66,12 +66,24 @@ xwayland_view_wants_focus(struct view *view)
         * should respond with a SetInputFocus request.
         *
         * [Currently, labwc does not fully support clients voluntarily
-        * taking focus via the WM_TAKE_FOCUS + SetInputFocus mechanism
-        * and avoids automatically focusing Globally Active windows.
-        * This may change in future.]
+        * taking focus via the WM_TAKE_FOCUS + SetInputFocus mechanism.
+        * Instead, we try to guess whether the window wants focus based
+        * on some heuristics -- see below.]
         */
        case WLR_ICCCM_INPUT_MODEL_GLOBAL:
-               return VIEW_WANTS_FOCUS_OFFER;
+               /*
+                * Assume the window does want focus if it wants window
+                * decorations (according to _MOTIF_WM_HINTS). This is
+                * a stop-gap fix to ensure that various applications
+                * (mainly Java-based ones such as IntelliJ IDEA) get
+                * focus normally and appear in the window switcher. It
+                * would be better to match based on _NET_WM_WINDOW_TYPE
+                * instead, but that property isn't currently available
+                * through wlroots API.
+                */
+               return (xsurface->decorations ==
+                       WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) ?
+                       VIEW_WANTS_FOCUS_ALWAYS : VIEW_WANTS_FOCUS_OFFER;
 
        /*
         * No Input - The client never expects keyboard input.