[PATCH weston 11/17] compositor: Keep track of what views were activated by clicking
Jonas Ådahl
jadahl at gmail.com
Tue Dec 2 05:49:19 PST 2014
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 at gmail.com>
---
desktop-shell/shell.c | 3 ++-
src/compositor.c | 2 ++
src/compositor.h | 13 ++++++++++++-
src/input.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index abe64f6..aa8f9da 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4886,7 +4886,7 @@ activate(struct desktop_shell *shell, struct weston_view *view,
main_surface = weston_surface_get_main_surface(es);
- weston_surface_activate(es, seat);
+ weston_view_activate(view, seat, flags);
state = ensure_focus_state(shell, seat);
if (state == NULL)
@@ -4966,6 +4966,7 @@ click_to_activate_binding(struct weston_seat *seat,
return;
activate_binding(seat, data, seat->pointer->focus,
+ WESTON_ACTIVATE_FLAG_CLICKED |
WESTON_ACTIVATE_FLAG_CONFIGURE);
}
diff --git a/src/compositor.c b/src/compositor.c
index 17e930c..790018a 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4051,6 +4051,8 @@ weston_compositor_init(struct weston_compositor *ec,
ec->output_id_pool = 0;
+ ec->activate_serial = 1;
+
if (!wl_global_create(display, &wl_compositor_interface, 3,
ec, compositor_bind))
return -1;
diff --git a/src/compositor.h b/src/compositor.h
index 4982187..6bcddf5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -685,6 +685,8 @@ struct weston_compositor {
clockid_t presentation_clock;
int exit_code;
+
+ unsigned int activate_serial;
};
struct weston_buffer {
@@ -777,6 +779,8 @@ struct weston_view {
struct weston_plane *plane;
struct weston_view *parent_view;
+ unsigned int click_to_activate_serial;
+
pixman_region32_t clip;
float alpha; /* part of geometry, see below */
@@ -972,7 +976,8 @@ 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 << 0,
+ WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 1,
};
void
@@ -1024,6 +1029,12 @@ weston_spring_done(struct weston_spring *spring);
void
weston_surface_activate(struct weston_surface *surface,
struct weston_seat *seat);
+
+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/src/input.c b/src/input.c
index 67f5cf4..d82628c 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1048,12 +1048,29 @@ 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)
+{
+ if (++c->activate_serial == 0)
+ ++c->activate_serial;
+}
+
WL_EXPORT void
weston_surface_activate(struct weston_surface *surface,
struct weston_seat *seat)
{
struct weston_compositor *compositor = seat->compositor;
+ inc_activate_serial(compositor);
+
if (seat->keyboard) {
weston_keyboard_set_focus(seat->keyboard, surface);
wl_data_device_set_keyboard_focus(seat);
@@ -1063,6 +1080,20 @@ weston_surface_activate(struct weston_surface *surface,
}
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_surface_activate(view->surface, seat);
+}
+
+WL_EXPORT void
notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
enum wl_pointer_button_state state)
{
--
1.8.5.1
More information about the wayland-devel
mailing list