diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 4a44f966..9b77add9 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -5183,7 +5183,7 @@ activate(struct desktop_shell *shell, struct weston_view *view, * Leave fullscreen surfaces on unrelated outputs alone. */ lower_fullscreen_layer(shell, shsurf->output); - weston_seat_set_keyboard_focus(seat, es); + weston_view_activate(view, seat, flags); state = ensure_focus_state(shell, seat); if (state == NULL) @@ -5258,6 +5258,7 @@ click_to_activate_binding(struct weston_pointer *pointer, uint32_t time, return; activate_binding(pointer->seat, data, pointer->focus, + WESTON_ACTIVATE_FLAG_CLICKED | WESTON_ACTIVATE_FLAG_CONFIGURE); } diff --git a/libweston/compositor.c b/libweston/compositor.c index 96eeb17a..4a0bfef2 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4685,6 +4685,8 @@ weston_compositor_create(struct wl_display *display, void *user_data) ec->output_id_pool = 0; ec->repaint_msec = DEFAULT_REPAINT_WINDOW; + ec->activate_serial = 1; + if (!wl_global_create(ec->wl_display, &wl_compositor_interface, 4, ec, compositor_bind)) goto fail; diff --git a/libweston/compositor.h b/libweston/compositor.h index 0ce79092..b1f8203d 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -802,6 +802,8 @@ struct weston_compositor { clockid_t presentation_clock; int32_t repaint_msec; + unsigned int activate_serial; + int exit_code; void *user_data; @@ -900,6 +902,8 @@ struct weston_view { /* For weston_layer inheritance from another view */ struct weston_view *parent_view; + unsigned int click_to_activate_serial; + pixman_region32_t clip; /* See weston_view_damage_below() */ float alpha; /* part of geometry, see below */ @@ -1127,6 +1131,7 @@ enum weston_key_state_update { enum weston_activate_flag { WESTON_ACTIVATE_FLAG_NONE = 0, WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0, + WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1, }; void @@ -1177,6 +1182,11 @@ weston_spring_update(struct weston_spring *spring, uint32_t msec); int weston_spring_done(struct weston_spring *spring); +void +weston_view_activate(struct weston_view *view, + struct weston_seat *seat, + uint32_t flags); + void notify_motion(struct weston_seat *seat, uint32_t time, struct weston_pointer_motion_event *event); diff --git a/libweston/input.c b/libweston/input.c index b9c79d49..c34e27ff 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -1296,6 +1296,35 @@ notify_motion_absolute(struct weston_seat *seat, pointer->grab->interface->motion(pointer->grab, time, &event); } +static unsigned int +peek_next_activate_serial(struct weston_compositor *c) +{ + unsigned serial = c->activate_serial + 1; + + return serial == 0 ? 1 : serial; +} + +static void +inc_activate_serial(struct weston_compositor *c) +{ + c->activate_serial = peek_next_activate_serial (c); +} + +WL_EXPORT void +weston_view_activate(struct weston_view *view, + struct weston_seat *seat, + uint32_t flags) +{ + struct weston_compositor *compositor = seat->compositor; + + if (flags & WESTON_ACTIVATE_FLAG_CLICKED) { + view->click_to_activate_serial = + peek_next_activate_serial(compositor); + } + + weston_seat_set_keyboard_focus(seat, view->surface); +} + WL_EXPORT void notify_button(struct weston_seat *seat, uint32_t time, int32_t button, enum wl_pointer_button_state state) @@ -2767,5 +2796,6 @@ weston_seat_set_keyboard_focus(struct weston_seat *seat, wl_data_device_set_keyboard_focus(seat); } + inc_activate_serial(compositor); wl_signal_emit(&compositor->activate_signal, surface); }