compositor: Keep track of what views were activated by clicking
Adds a weston_view_activate() that can be passed an additional active flag WESTON_ACTIVATE_CLICKED, that the shell passes when a view was activated by clicking. This allows shell-independent components implement heuristics depending on how a view was activated. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -5183,7 +5183,7 @@ activate(struct desktop_shell *shell, struct weston_view *view,
|
|||||||
* Leave fullscreen surfaces on unrelated outputs alone. */
|
* Leave fullscreen surfaces on unrelated outputs alone. */
|
||||||
lower_fullscreen_layer(shell, shsurf->output);
|
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);
|
state = ensure_focus_state(shell, seat);
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
@@ -5258,6 +5258,7 @@ click_to_activate_binding(struct weston_pointer *pointer, uint32_t time,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
activate_binding(pointer->seat, data, pointer->focus,
|
activate_binding(pointer->seat, data, pointer->focus,
|
||||||
|
WESTON_ACTIVATE_FLAG_CLICKED |
|
||||||
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4685,6 +4685,8 @@ weston_compositor_create(struct wl_display *display, void *user_data)
|
|||||||
ec->output_id_pool = 0;
|
ec->output_id_pool = 0;
|
||||||
ec->repaint_msec = DEFAULT_REPAINT_WINDOW;
|
ec->repaint_msec = DEFAULT_REPAINT_WINDOW;
|
||||||
|
|
||||||
|
ec->activate_serial = 1;
|
||||||
|
|
||||||
if (!wl_global_create(ec->wl_display, &wl_compositor_interface, 4,
|
if (!wl_global_create(ec->wl_display, &wl_compositor_interface, 4,
|
||||||
ec, compositor_bind))
|
ec, compositor_bind))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|||||||
@@ -802,6 +802,8 @@ struct weston_compositor {
|
|||||||
clockid_t presentation_clock;
|
clockid_t presentation_clock;
|
||||||
int32_t repaint_msec;
|
int32_t repaint_msec;
|
||||||
|
|
||||||
|
unsigned int activate_serial;
|
||||||
|
|
||||||
int exit_code;
|
int exit_code;
|
||||||
|
|
||||||
void *user_data;
|
void *user_data;
|
||||||
@@ -900,6 +902,8 @@ struct weston_view {
|
|||||||
/* For weston_layer inheritance from another view */
|
/* For weston_layer inheritance from another view */
|
||||||
struct weston_view *parent_view;
|
struct weston_view *parent_view;
|
||||||
|
|
||||||
|
unsigned int click_to_activate_serial;
|
||||||
|
|
||||||
pixman_region32_t clip; /* See weston_view_damage_below() */
|
pixman_region32_t clip; /* See weston_view_damage_below() */
|
||||||
float alpha; /* part of geometry, see below */
|
float alpha; /* part of geometry, see below */
|
||||||
|
|
||||||
@@ -1127,6 +1131,7 @@ enum weston_key_state_update {
|
|||||||
enum weston_activate_flag {
|
enum weston_activate_flag {
|
||||||
WESTON_ACTIVATE_FLAG_NONE = 0,
|
WESTON_ACTIVATE_FLAG_NONE = 0,
|
||||||
WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
|
WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
|
||||||
|
WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1177,6 +1182,11 @@ weston_spring_update(struct weston_spring *spring, uint32_t msec);
|
|||||||
int
|
int
|
||||||
weston_spring_done(struct weston_spring *spring);
|
weston_spring_done(struct weston_spring *spring);
|
||||||
|
|
||||||
|
void
|
||||||
|
weston_view_activate(struct weston_view *view,
|
||||||
|
struct weston_seat *seat,
|
||||||
|
uint32_t flags);
|
||||||
|
|
||||||
void
|
void
|
||||||
notify_motion(struct weston_seat *seat, uint32_t time,
|
notify_motion(struct weston_seat *seat, uint32_t time,
|
||||||
struct weston_pointer_motion_event *event);
|
struct weston_pointer_motion_event *event);
|
||||||
|
|||||||
@@ -1296,6 +1296,35 @@ notify_motion_absolute(struct weston_seat *seat,
|
|||||||
pointer->grab->interface->motion(pointer->grab, time, &event);
|
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
|
WL_EXPORT void
|
||||||
notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
|
notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
|
||||||
enum wl_pointer_button_state state)
|
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);
|
wl_data_device_set_keyboard_focus(seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inc_activate_serial(compositor);
|
||||||
wl_signal_emit(&compositor->activate_signal, surface);
|
wl_signal_emit(&compositor->activate_signal, surface);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user