]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: update focus on entering SSD if followMouse=yes
authortokyo4j <hrak1529@gmail.com>
Sun, 30 Nov 2025 11:45:30 +0000 (20:45 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sun, 30 Nov 2025 11:55:54 +0000 (20:55 +0900)
This fixes a known regression in 885919fc that cursor entering the
titlebar (and other SSD parts) doesn't update the keyboard focus even when
followMouse=yes.

include/labwc.h
src/input/cursor.c

index 999db395afeafd7d8ca2a3a8eb5289385855e7c1..62863defa4f15f5e22c67529ff99a95fc610704b 100644 (file)
@@ -78,6 +78,9 @@ struct seat {
         */
        struct cursor_context_saved pressed;
 
+       /* Cursor context of the last cursor motion */
+       struct cursor_context_saved last_cursor_ctx;
+
        struct lab_set bound_buttons;
 
        struct {
index d3221513907f01a45a0d8159523797fa09da4b4b..2a681a6ea2d2880bc8e3dbf953e60db857620170 100644 (file)
@@ -664,9 +664,6 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
                }
        }
 
-       struct wlr_surface *old_focused_surface =
-               seat->seat->pointer_state.focused_surface;
-
        /*
         * Cursor context that is actually interacting with cursor and should
         * be notified to the client. E.g. it is cleared when menu is open,
@@ -675,19 +672,28 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
        struct cursor_context notified_ctx = {0};
        cursor_update_common(server, &ctx, &notified_ctx);
 
-       struct wlr_surface *new_focused_surface =
-               seat->seat->pointer_state.focused_surface;
-
-       if (rc.focus_follow_mouse && new_focused_surface
-                       && old_focused_surface != new_focused_surface) {
+       if (rc.focus_follow_mouse) {
                /*
-                * If followMouse=yes, update the keyboard focus when the
-                * cursor enters a surface
+                * If followMouse=yes, entering a surface or view updates
+                * keyboard focus. Note that moving the cursor between a
+                * surface and a SSD within the same view doesn't update
+                * keyboard focus, and that entering a surface/view doesn't
+                * update keyboard focus if implicit grab is active.
                 */
-               desktop_focus_view_or_surface(seat,
-                       view_from_wlr_surface(new_focused_surface),
-                       new_focused_surface, rc.raise_on_focus);
+               bool entering = false;
+               if (notified_ctx.view) {
+                       entering = notified_ctx.view
+                                       != seat->last_cursor_ctx.ctx.view;
+               } else if (notified_ctx.surface) {
+                       entering = notified_ctx.surface
+                                       != seat->last_cursor_ctx.ctx.surface;
+               }
+               if (entering) {
+                       desktop_focus_view_or_surface(seat, notified_ctx.view,
+                               notified_ctx.surface, rc.raise_on_focus);
+               }
        }
+       cursor_context_save(&seat->last_cursor_ctx, &notified_ctx);
 
        *sx = notified_ctx.sx;
        *sy = notified_ctx.sy;