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:
Jonas Ådahl 2014-10-18 18:42:19 +02:00
parent 4361b4ea3f
commit 94e2e2d39f
4 changed files with 44 additions and 1 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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);

View file

@ -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);
}