]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: Prevent resetting cursor icon during Move or Resize
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sat, 10 Sep 2022 17:19:02 +0000 (19:19 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 11 Sep 2022 12:24:27 +0000 (13:24 +0100)
Reported-by: @Flrian
src/cursor.c
src/interactive.c

index c20dc0a95e8857a0eb71d41116992c36219d4149..10647e9169f24ecc52c495038b37d8d5d114414c 100644 (file)
@@ -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
index be469f7be87072f3b83ec102afebd4a9384f805c..c56a17d7d8418d7c30dd86c47a47e0a896e90cfc 100644 (file)
@@ -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);
        }
 }