cursor: Allow re-enter for cursor_update_focus()

This allows forcing an application to re-set their desired cursor image.
This commit is contained in:
Consolatis 2022-09-11 07:08:28 +02:00 committed by Johan Malm
parent 1483158b26
commit c0f0e0c46e
5 changed files with 15 additions and 12 deletions

View 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);

View 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,

View 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

View 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. */

View 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);