]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: add cursor_update_focus()
authorJohan Malm <jgm323@gmail.com>
Sun, 26 Dec 2021 22:09:41 +0000 (22:09 +0000)
committerJohan Malm <jgm323@gmail.com>
Mon, 21 Mar 2022 17:57:20 +0000 (17:57 +0000)
...and call it from desktop_move_to_front() in order force an enter event
on the surface below the cursor when cycling views.

Fixes #162 and #225
Inspired by PR #164 - just restructured it a bit.

Suggested-by: @bi4k8
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
include/labwc.h
src/cursor.c
src/desktop.c

index 07909228618f2670dfaaa93e69c79660b64e61a9..10a8e58aaa216c9822be6ede3a4104d554ebbcec 100644 (file)
@@ -483,6 +483,14 @@ void cursor_rebase(struct seat *seat, uint32_t time_msec);
  */
 void cursor_set(struct seat *seat, const char *cursor_name);
 
+/**
+ * cursor_update_focus - update cursor focus
+ * @server - server
+ * Use it to force an update of the cursor icon and to send an enter event
+ * to the surface below the cursor.
+ */
+void cursor_update_focus(struct server *server);
+
 void cursor_init(struct seat *seat);
 void cursor_finish(struct seat *seat);
 
index 29e8eb5f0b244cf2ef0a21024383a3bd88929bc1..47d4b58e7a8f6a72e82975d113aca6cb93216109 100644 (file)
@@ -321,6 +321,20 @@ process_cursor_motion(struct server *server, uint32_t time)
        }
 }
 
+static uint32_t
+msec(const struct timespec *t)
+{
+       return t->tv_sec * 1000 + t->tv_nsec / 1000000;
+}
+
+void
+cursor_update_focus(struct server *server)
+{
+       struct timespec now;
+       clock_gettime(CLOCK_MONOTONIC, &now);
+       cursor_rebase(&server->seat, msec(&now));
+}
+
 void
 start_drag(struct wl_listener *listener, void *data)
 {
@@ -750,7 +764,6 @@ cursor_axis(struct wl_listener *listener, void *data)
        wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
 
        /* Notify the client with pointer focus of the axis event. */
-       cursor_rebase(seat, event->time_msec);
        wlr_seat_pointer_notify_axis(seat->seat, event->time_msec,
                event->orientation, event->delta, event->delta_discrete,
                event->source);
index d8768de57f13f2fc4bd7c5fc9fc399d683b25a5f..4a69a7c369704942b259073f75f6d4e6190e0430 100644 (file)
@@ -63,6 +63,7 @@ desktop_move_to_front(struct view *view)
 #if HAVE_XWAYLAND
        move_xwayland_sub_views_to_front(view);
 #endif
+       cursor_update_focus(view->server);
 }
 
 static void