cursor: send clear_focus on hide and enter event on unhide

Clear the focus when we hide the cursor and show it again during the unhide
action. The unhide function will rebase the cursor after the unhide.

Tested by looking at the WAYLAND_DEBUG=1 output of termite.

Also call cursor_handle_activity before sending pointer events to send the enter
events to the surface if the cursor was hidden before.

Fixes #3431
This commit is contained in:
Rouven Czerwinski 2019-01-15 18:09:34 +01:00 committed by Brian Ashworth
parent 023c92423e
commit f7309778a7
1 changed files with 6 additions and 4 deletions

View File

@ -275,6 +275,7 @@ static int hide_notify(void *data) {
struct sway_cursor *cursor = data;
wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0);
cursor->hidden = true;
wlr_seat_pointer_clear_focus(cursor->seat->wlr_seat);
return 1;
}
@ -313,6 +314,7 @@ void cursor_unhide(struct sway_cursor *cursor) {
cursor->image = NULL;
cursor_set_image(cursor, image, cursor->image_client);
}
cursor_rebase(cursor);
}
void cursor_send_pointer_motion(struct sway_cursor *cursor,
@ -388,10 +390,10 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor,
static void handle_cursor_motion(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
struct wlr_event_pointer_motion *event = data;
cursor_handle_activity(cursor);
wlr_cursor_move(cursor->cursor, event->device,
event->delta_x, event->delta_y);
cursor_send_pointer_motion(cursor, event->time_msec);
cursor_handle_activity(cursor);
transaction_commit_dirty();
}
@ -400,9 +402,9 @@ static void handle_cursor_motion_absolute(
struct sway_cursor *cursor =
wl_container_of(listener, cursor, motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data;
cursor_handle_activity(cursor);
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
cursor_send_pointer_motion(cursor, event->time_msec);
cursor_handle_activity(cursor);
transaction_commit_dirty();
}
@ -698,9 +700,9 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
static void handle_cursor_button(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, button);
struct wlr_event_pointer_button *event = data;
cursor_handle_activity(cursor);
dispatch_cursor_button(cursor, event->device,
event->time_msec, event->button, event->state);
cursor_handle_activity(cursor);
transaction_commit_dirty();
}
@ -814,8 +816,8 @@ void dispatch_cursor_axis(struct sway_cursor *cursor,
static void handle_cursor_axis(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
struct wlr_event_pointer_axis *event = data;
dispatch_cursor_axis(cursor, event);
cursor_handle_activity(cursor);
dispatch_cursor_axis(cursor, event);
transaction_commit_dirty();
}