[gtk+/wip/wayland-tablet: 554/555] wayland: Translate pen buttons into button events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/wayland-tablet: 554/555] wayland: Translate pen buttons into button events
- Date: Tue, 29 Mar 2016 18:22:02 +0000 (UTC)
commit 09177df51d8f10411f8533c31a28ec756f55c155
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jun 22 18:28:46 2015 +0200
wayland: Translate pen buttons into button events
up/down already take GDK_BUTTON_PRIMARY, we translate BTN_STYLUS(2)
into GDK_BUTTON_MIDDLE/SECONDARY.
gdk/wayland/gdkdevice-wayland.c | 42 +++++++++++++++++++++++++++++++++-----
1 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 959ef46..abaa4d6 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -40,6 +40,7 @@
#include <sys/time.h>
#include <sys/mman.h>
+#include <linux/input.h>
#define BUTTON_BASE (BTN_LEFT - 1) /* Used to translate to 1-indexed buttons */
@@ -3273,6 +3274,40 @@ tablet_tool_handle_tilt (void *data,
}
static void
+tablet_tool_handle_button (void *data,
+ struct zwp_tablet_tool_v1 *wp_tablet_tool,
+ uint32_t serial,
+ uint32_t button,
+ uint32_t state)
+{
+ GdkWaylandTabletToolData *tool = data;
+ GdkWaylandTabletData *tablet = tool->current_tablet;
+ GdkEventType evtype;
+ guint n_button;
+
+ if (!tablet->pointer_info.focus)
+ return;
+
+ tablet->pointer_info.press_serial = serial;
+
+ if (button == BTN_STYLUS)
+ n_button = GDK_BUTTON_SECONDARY;
+ else if (button == BTN_STYLUS2)
+ n_button = GDK_BUTTON_MIDDLE;
+ else
+ return;
+
+ if (state == ZWP_TABLET_TOOL_V1_BUTTON_STATE_PRESSED)
+ evtype = GDK_BUTTON_PRESS;
+ else if (state == ZWP_TABLET_TOOL_V1_BUTTON_STATE_RELEASED)
+ evtype = GDK_BUTTON_RELEASE;
+ else
+ return;
+
+ tablet_create_button_event_frame (tablet, evtype, n_button);
+}
+
+static void
tablet_tool_handle_rotation (void *data,
struct zwp_tablet_tool_v1 *wp_tablet_tool,
int32_t degrees)
@@ -3339,11 +3374,6 @@ tablet_tool_handle_frame (void *data,
gdk_wayland_tablet_flush_frame_event (tablet, time);
}
-static void
-tablet_handler_placeholder ()
-{
-}
-
static const struct zwp_tablet_tool_v1_listener tablet_tool_listener = {
tablet_tool_handle_type,
tablet_tool_handle_hardware_serial,
@@ -3362,7 +3392,7 @@ static const struct zwp_tablet_tool_v1_listener tablet_tool_listener = {
tablet_tool_handle_rotation,
tablet_tool_handle_slider,
tablet_tool_handle_wheel,
- tablet_handler_placeholder, /* button_state */
+ tablet_tool_handle_button,
tablet_tool_handle_frame,
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]