]> 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>
Sun, 26 Dec 2021 22:09:41 +0000 (22:09 +0000)
...and call it from desktop_move_to_front() in order force an enter event
on the surface below the cursor when cycling views.

Inspired by PR #164 - just restructured it a bit.

Suggested-by: @bi4k8
include/labwc.h
src/cursor.c
src/desktop.c

index 345ff878ff9dfa2ba6945d3487197850b22e17eb..f71512e4c3245f88fcdfe9972ee9ea1ff50f42d9 100644 (file)
@@ -441,6 +441,15 @@ void cursor_rebase(struct seat *seat, uint32_t time_msec);
  * @cursor_name - name of cursor, for example "left_ptr" or "grab"
  */
 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 keyboard_init(struct seat *seat);
index f2c923a4e8d0cf76a3dabf364b49b93c63c171d8..c2b3a19ff3c64bb36f4c5cb4fb25c5ef9472eade 100644 (file)
@@ -256,6 +256,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);
+       process_cursor_motion(server, msec(&now));
+}
+
 void
 start_drag(struct wl_listener *listener, void *data)
 {
index ba4aec952ef92ccb4d8d8f09de83ac57fcd27bb9..9c09598c95832f828d32a84c7e94d4899a932b1c 100644 (file)
@@ -61,6 +61,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