From 2e6eb097b6e23b8923bbfc68b1843d5ccde1955b Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Sun, 29 Jul 2018 20:02:00 +0300 Subject: rootston: focus newly-created surfaces Whenever a new surface is created, we have to update the cursor focus, even if there's no input event. So, we generate one motion event, and reuse the code to update the proper cursor focus. We need to do this for all surface roles - toplevels, popups, subsurfaces. Fixes #1162 --- rootston/input.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'rootston/input.c') diff --git a/rootston/input.c b/rootston/input.c index 84b5acae..de847d78 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -1,5 +1,7 @@ +#define _POSIX_C_SOURCE 199309L #include #include +#include #include #include #include @@ -126,3 +128,16 @@ bool input_view_has_focus(struct roots_input *input, struct roots_view *view) { return false; } + +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + +void input_update_cursor_focus(struct roots_input *input) { + struct roots_seat *seat; + struct timespec now; + wl_list_for_each(seat, &input->seats, link) { + clock_gettime(CLOCK_MONOTONIC, &now); + roots_cursor_update_position(seat->cursor, timespec_to_msec(&now)); + } +} -- cgit v1.2.3