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

@ -101,6 +101,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) {
bool focus_changed;
double sx, sy;
struct roots_view *view = NULL;
struct roots_seat *seat = cursor->seat;
@ -136,8 +137,11 @@ 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);
wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
if (!focus_changed) {
wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
}
} else {
wlr_seat_pointer_clear_focus(seat->seat);
}
@ -148,8 +152,8 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor,
}
}
static void roots_cursor_update_position(
struct roots_cursor *cursor, uint32_t time) {
void roots_cursor_update_position(struct roots_cursor *cursor,
uint32_t time) {
struct roots_seat *seat = cursor->seat;
struct roots_view *view;
switch (cursor->mode) {
@ -266,13 +270,7 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
}
switch (state) {
case WLR_BUTTON_RELEASED:
if (!is_touch) {
roots_cursor_update_position(cursor, time);
}
break;
case WLR_BUTTON_PRESSED:
if (state == WLR_BUTTON_PRESSED) {
if (view) {
roots_seat_set_focus(seat, view);
}
@ -283,7 +281,6 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
roots_seat_set_focus_layer(seat, layer);
}
}
break;
}
}