[PATCH v2 weston 11/13] tablet: Add binding to activate surfaces using the tablet tool
Peter Hutterer
peter.hutterer at who-t.net
Wed Feb 3 05:28:15 UTC 2016
From: Stephen Chandler Paul <thatslyude at gmail.com>
Co-authored-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
desktop-shell/shell.c | 14 ++++++++++++++
src/bindings.c | 39 ++++++++++++++++++++++++++++++++++++++-
src/compositor.c | 1 +
src/compositor.h | 16 ++++++++++++++++
src/input.c | 6 ++++++
5 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 958c7ea..c1425e3 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -5446,6 +5446,18 @@ touch_to_activate_binding(struct weston_touch *touch, uint32_t time,
}
static void
+tablet_tool_activate_binding(struct weston_tablet_tool *tool,
+ uint32_t button, void *data)
+{
+ if (tool->grab != &tool->default_grab)
+ return;
+ if (tool->focus == NULL)
+ return;
+
+ activate_binding(tool->seat, data, tool->focus);
+}
+
+static void
unfocus_all_seats(struct desktop_shell *shell)
{
struct weston_seat *seat, *next;
@@ -6748,6 +6760,8 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
weston_compositor_add_touch_binding(ec, 0,
touch_to_activate_binding,
shell);
+ weston_compositor_add_tablet_tool_binding(ec, BTN_TOUCH, 0,
+ tablet_tool_activate_binding, shell);
weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
MODIFIER_SUPER | MODIFIER_ALT,
surface_opacity_binding, NULL);
diff --git a/src/bindings.c b/src/bindings.c
index cc68cfe..64e151b 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -135,6 +135,24 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
}
WL_EXPORT struct weston_binding *
+weston_compositor_add_tablet_tool_binding(struct weston_compositor *compositor,
+ uint32_t button, uint32_t modifier,
+ weston_tablet_tool_binding_handler_t handler,
+ void *data)
+{
+ struct weston_binding *binding;
+
+ binding = weston_compositor_add_binding(compositor, 0, button, 0,
+ modifier, handler, data);
+ if (binding == NULL)
+ return NULL;
+
+ wl_list_insert(compositor->tablet_tool_binding_list.prev, &binding->link);
+
+ return binding;
+}
+
+WL_EXPORT struct weston_binding *
weston_compositor_add_axis_binding(struct weston_compositor *compositor,
uint32_t axis, uint32_t modifier,
weston_axis_binding_handler_t handler,
@@ -387,7 +405,26 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
}
}
-int
+WL_EXPORT void
+weston_compositor_run_tablet_tool_binding(struct weston_compositor *compositor,
+ struct weston_tablet_tool *tool,
+ uint32_t button,
+ enum zwp_tablet_tool_v1_button_state state)
+{
+ struct weston_binding *b;
+
+ if (state != ZWP_TABLET_TOOL_V1_BUTTON_STATE_PRESSED)
+ return;
+
+ wl_list_for_each(b, &compositor->tablet_tool_binding_list, link) {
+ if (b->modifier == tool->seat->modifier_state) {
+ weston_tablet_tool_binding_handler_t handler = b->handler;
+ handler(tool, button, b->data);
+ }
+ }
+}
+
+WL_EXPORT int
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer,
uint32_t time,
diff --git a/src/compositor.c b/src/compositor.c
index f419818..d93917b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4773,6 +4773,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
wl_list_init(&ec->modifier_binding_list);
wl_list_init(&ec->button_binding_list);
wl_list_init(&ec->touch_binding_list);
+ wl_list_init(&ec->tablet_tool_binding_list);
wl_list_init(&ec->axis_binding_list);
wl_list_init(&ec->debug_binding_list);
wl_list_init(&ec->tablet_manager_resource_list);
diff --git a/src/compositor.h b/src/compositor.h
index 6806d06..bd6af4d 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -869,6 +869,7 @@ struct weston_compositor {
struct wl_list modifier_binding_list;
struct wl_list button_binding_list;
struct wl_list touch_binding_list;
+ struct wl_list tablet_tool_binding_list;
struct wl_list axis_binding_list;
struct wl_list debug_binding_list;
@@ -1459,6 +1460,16 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
weston_touch_binding_handler_t binding,
void *data);
+typedef void (*weston_tablet_tool_binding_handler_t)(struct weston_tablet_tool *tool,
+ uint32_t button,
+ void *data);
+struct weston_binding *
+weston_compositor_add_tablet_tool_binding(struct weston_compositor *compositor,
+ uint32_t button,
+ enum weston_keyboard_modifier modifier,
+ weston_tablet_tool_binding_handler_t binding,
+ void *data);
+
typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
uint32_t time,
struct weston_pointer_axis_event *event,
@@ -1505,6 +1516,11 @@ void
weston_compositor_run_touch_binding(struct weston_compositor *compositor,
struct weston_touch *touch, uint32_t time,
int touch_type);
+void
+weston_compositor_run_tablet_tool_binding(struct weston_compositor *compositor,
+ struct weston_tablet_tool *tool,
+ uint32_t button,
+ enum zwp_tablet_tool_v1_button_state state);
int
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer, uint32_t time,
diff --git a/src/input.c b/src/input.c
index b58d7f3..11ed0c4 100644
--- a/src/input.c
+++ b/src/input.c
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
+#include <linux/input.h>
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
@@ -2657,6 +2658,9 @@ notify_tablet_tool_button(struct weston_tablet_tool *tool,
}
tool->grab_serial = wl_display_next_serial(compositor->wl_display);
+
+ weston_compositor_run_tablet_tool_binding(compositor, tool, button, state);
+
grab->interface->button(grab, time, button, state);
}
@@ -2674,6 +2678,8 @@ notify_tablet_tool_down(struct weston_tablet_tool *tool,
tool->grab_x = tool->x;
tool->grab_y = tool->y;
+ weston_compositor_run_tablet_tool_binding(compositor, tool, BTN_TOUCH,
+ ZWP_TABLET_TOOL_V1_BUTTON_STATE_PRESSED);
grab->interface->down(grab, time);
}
--
2.5.0
More information about the wayland-devel
mailing list