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
This commit is contained in:
Ilia Bozhinov 2018-07-29 20:02:00 +03:00
parent f1b65b34a6
commit 2e6eb097b6
8 changed files with 37 additions and 11 deletions

View file

@ -1,5 +1,7 @@
#define _POSIX_C_SOURCE 199309L
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <wayland-server.h>
#include <wlr/backend/libinput.h>
#include <wlr/config.h>
@ -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));
}
}