From 59dd1dddbabb93569d06fb5612cb8178a9a50c1e Mon Sep 17 00:00:00 2001 From: Las Date: Wed, 8 Aug 2018 13:43:44 +0200 Subject: [PATCH] Update pointer focus when cycling focus --- include/rootston/cursor.h | 2 ++ rootston/cursor.c | 12 +++++++++--- rootston/seat.c | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index 52c72a44..bcbc1c07 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -84,4 +84,6 @@ void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor, void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t time); +void roots_cursor_update_focus(struct roots_cursor *cursor); + #endif diff --git a/rootston/cursor.c b/rootston/cursor.c index 239acf9c..b7dd98ed 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -100,7 +100,7 @@ static void seat_view_deco_button(struct roots_seat_view *view, double sx, } static void roots_passthrough_cursor(struct roots_cursor *cursor, - uint32_t time) { + int64_t time) { bool focus_changed; double sx, sy; struct roots_view *view = NULL; @@ -108,11 +108,13 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor, struct roots_desktop *desktop = seat->input->server->desktop; struct wlr_surface *surface = desktop_surface_at(desktop, cursor->cursor->x, cursor->cursor->y, &sx, &sy, &view); + struct wl_client *client = NULL; if (surface) { client = wl_resource_get_client(surface->resource); } - if (surface && !roots_seat_allow_input(cursor->seat, surface->resource)) { + + if (surface && !roots_seat_allow_input(seat, surface->resource)) { return; } @@ -145,7 +147,7 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor, if (surface) { focus_changed = (seat->seat->pointer_state.focused_surface != surface); wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy); - if (!focus_changed) { + if (!focus_changed && time > 0) { wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy); } } else { @@ -158,6 +160,10 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor, } } +void roots_cursor_update_focus(struct roots_cursor *cursor) { + roots_passthrough_cursor(cursor, -1); +} + void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t time) { struct roots_seat *seat = cursor->seat; diff --git a/rootston/seat.c b/rootston/seat.c index 507254d4..e888bfa5 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -1186,6 +1186,8 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) { wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface, NULL, 0, NULL); } + + roots_cursor_update_focus(seat->cursor); } /** @@ -1220,6 +1222,8 @@ void roots_seat_set_focus_layer(struct roots_seat *seat, wlr_seat_keyboard_notify_enter(seat->seat, layer->surface, NULL, 0, NULL); } + + roots_cursor_update_focus(seat->cursor); } void roots_seat_set_exclusive_client(struct roots_seat *seat,