]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: Allow re-enter for cursor_update_focus()
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 11 Sep 2022 05:08:28 +0000 (07:08 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 11 Sep 2022 12:24:27 +0000 (13:24 +0100)
This allows forcing an application to re-set their desired cursor image.

include/labwc.h
src/cursor.c
src/desktop.c
src/view.c
src/xwayland-unmanaged.c

index 93f1e01ca4ce87882df585a6518d1714a540ab8a..6032d472c163370df3c9b446446d878b003ffa79 100644 (file)
@@ -532,10 +532,13 @@ void cursor_set(struct seat *seat, const char *cursor_name);
 /**
  * cursor_update_focus - update cursor focus, may update the cursor icon
  * @server - server
- * Use it to force an update of the cursor icon and to send an enter event
- * to the surface below the cursor.
+ * @force_reenter - re-enter a surface if it already owns the cursor focus
+ *
+ * This can be used to give the mouse focus to the surface under the cursor
+ * or to force an update of the cursor icon by sending an exit and enter
+ * event to an already focused surface when @force_reenter is true.
  */
-void cursor_update_focus(struct server *server);
+void cursor_update_focus(struct server *server, bool force_reenter);
 
 void cursor_init(struct seat *seat);
 void cursor_finish(struct seat *seat);
index fc5a32049d93f79fa2f43bc8607f7b830194a7f0..c20dc0a95e8857a0eb71d41116992c36219d4149 100644 (file)
@@ -365,7 +365,7 @@ msec(const struct timespec *t)
 }
 
 void
-cursor_update_focus(struct server *server)
+cursor_update_focus(struct server *server, bool force_reenter)
 {
        double sx, sy;
        struct wlr_scene_node *node = NULL;
@@ -386,7 +386,7 @@ cursor_update_focus(struct server *server)
        ssd_update_button_hover(node, &seat->server->ssd_hover_state);
 
        /* Focus surface under cursor if it isn't already focused */
-       cursor_rebase(seat, node, surface, sx, sy, msec(&now), false);
+       cursor_rebase(seat, node, surface, sx, sy, msec(&now), force_reenter);
 }
 
 void
@@ -848,7 +848,7 @@ cursor_axis(struct wl_listener *listener, void *data)
        wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
 
        /* Make sure we are sending the events to the surface under the cursor */
-       cursor_update_focus(seat->server);
+       cursor_update_focus(seat->server, false);
 
        /* Notify the client with pointer focus of the axis event. */
        wlr_seat_pointer_notify_axis(seat->seat, event->time_msec,
index e6d09080d3cba2754683e7c049105ddd1236db73..20e73ff98bc57c75c07a10143a812c57de64b9ea 100644 (file)
@@ -65,7 +65,7 @@ desktop_move_to_front(struct view *view)
 #if HAVE_XWAYLAND
        move_xwayland_sub_views_to_front(view);
 #endif
-       cursor_update_focus(view->server);
+       cursor_update_focus(view->server, false);
 }
 
 static void
index 0f5a83516b29a7bc6861d9322471c39718b933b2..088d3647a864a42fcf106efb8ba46edff81b2d37 100644 (file)
@@ -149,7 +149,7 @@ view_moved(struct view *view)
        wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y);
        view_discover_output(view);
        ssd_update_geometry(view);
-       cursor_update_focus(view->server);
+       cursor_update_focus(view->server, false);
 }
 
 /* N.B. Use view_move() if not resizing. */
index b09b6196c46bc115f5c67dc00b9796c423a65b6d..db6022d6d1db3ad3ee255ca79e5e571dad659a9b 100644 (file)
@@ -11,7 +11,7 @@ unmanaged_handle_request_configure(struct wl_listener *listener, void *data)
        wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, ev->width, ev->height);
        if (unmanaged->node) {
                wlr_scene_node_set_position(unmanaged->node, ev->x, ev->y);
-               cursor_update_focus(unmanaged->server);
+               cursor_update_focus(unmanaged->server, false);
        }
 }
 
@@ -23,7 +23,7 @@ unmanaged_handle_set_geometry(struct wl_listener *listener, void *data)
        struct wlr_xwayland_surface *xsurface = unmanaged->xwayland_surface;
        if (unmanaged->node) {
                wlr_scene_node_set_position(unmanaged->node, xsurface->x, xsurface->y);
-               cursor_update_focus(unmanaged->server);
+               cursor_update_focus(unmanaged->server, false);
        }
 }
 
@@ -51,7 +51,7 @@ unmanaged_handle_map(struct wl_listener *listener, void *data)
                        unmanaged->server->unmanaged_tree,
                        xsurface->surface)->buffer->node;
        wlr_scene_node_set_position(unmanaged->node, xsurface->x, xsurface->y);
-       cursor_update_focus(unmanaged->server);
+       cursor_update_focus(unmanaged->server, false);
 }
 
 static void
@@ -105,7 +105,7 @@ unmanaged_handle_unmap(struct wl_listener *listener, void *data)
                seat_reset_pressed(seat);
        }
        unmanaged->node = NULL;
-       cursor_update_focus(unmanaged->server);
+       cursor_update_focus(unmanaged->server, false);
 
        if (seat->seat->keyboard_state.focused_surface == xsurface->surface) {
                focus_next_surface(unmanaged->server, xsurface);