From 7af74c88a89773b1012b3f97681fc90350c6a1bb Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sat, 10 Sep 2022 19:19:02 +0200 Subject: [PATCH] cursor: Prevent resetting cursor icon during Move or Resize Reported-by: @Flrian --- src/cursor.c | 20 +++++++++++++++++--- src/interactive.c | 9 +++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/cursor.c b/src/cursor.c index c20dc0a9..10647e91 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -38,8 +38,16 @@ cursor_rebase(struct seat *seat, struct wlr_scene_node *node, return; } + if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) { + /* Prevent resetting focus / cursor image when moving or resizing */ + return; + } + + struct wlr_surface *focused_surface = + seat->seat->pointer_state.focused_surface; + if (surface) { - if (!force && surface == seat->seat->pointer_state.focused_surface) { + if (!force && surface == focused_surface) { /* * Usually we prevent re-entering an already focused surface * because it sends useless leave and enter events. @@ -56,8 +64,8 @@ cursor_rebase(struct seat *seat, struct wlr_scene_node *node, wlr_seat_pointer_notify_clear_focus(seat->seat); wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy); wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy); - } else { - cursor_set(seat, "left_ptr"); + } else if (focused_surface) { + cursor_set(seat, XCURSOR_DEFAULT); wlr_seat_pointer_notify_clear_focus(seat->seat); } } @@ -66,6 +74,12 @@ static void request_cursor_notify(struct wl_listener *listener, void *data) { struct seat *seat = wl_container_of(listener, seat, request_cursor); + + if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) { + /* Prevent setting a cursor image when moving or resizing */ + return; + } + /* * This event is raised by the seat when a client provides a cursor * image diff --git a/src/interactive.c b/src/interactive.c index be469f7b..c56a17d7 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -134,5 +134,14 @@ interactive_end(struct view *view) view_snap_to_edge(view, "down"); } } + /* + * First set the cursor image in case we moved / resized via SSD. + * Then allow an application to set its own image in case there + * is a surface below the cursor (e.g. moved / resized via 'Alt' + * modifier). If there is no surface below the cursor the second + * call is a no-op. + */ + cursor_set(&view->server->seat, XCURSOR_DEFAULT); + cursor_update_focus(view->server, true); } }