|
|
314a7ca |
From 6f79f4993d351a891a715e994ab9574542e64b35 Mon Sep 17 00:00:00 2001
|
|
|
314a7ca |
From: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
314a7ca |
Date: Tue, 7 Feb 2017 15:04:46 +1000
|
|
|
314a7ca |
Subject: [PATCH xserver 09/12] xwayland: add tablet pad support
|
|
|
314a7ca |
|
|
|
314a7ca |
Hooked up a bit differently to the other tools. Those tools can be static for
|
|
|
314a7ca |
all and be re-used. The wacom driver initializes the pad with the correct
|
|
|
314a7ca |
number of buttons though and we can't do this until we have the pad done event.
|
|
|
314a7ca |
|
|
|
314a7ca |
If the tablet is removed and we plug a different one in, we should initialize
|
|
|
314a7ca |
that correctly, so unlike the other tools the pad is properly removed and
|
|
|
314a7ca |
re-initialized on plug.
|
|
|
314a7ca |
|
|
|
314a7ca |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
314a7ca |
Acked-by: Ping Cheng <ping.cheng@wacom.com>
|
|
|
314a7ca |
(cherry picked from commit 8475e6360ce31551d50fd63a26f7a44d1e8928f2)
|
|
|
314a7ca |
---
|
|
|
314a7ca |
hw/xwayland/xwayland-input.c | 417 +++++++++++++++++++++++++++++++++++++++++++
|
|
|
314a7ca |
hw/xwayland/xwayland.h | 28 +++
|
|
|
314a7ca |
2 files changed, 445 insertions(+)
|
|
|
314a7ca |
|
|
|
314a7ca |
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
|
|
|
314a7ca |
index 77cd42789..8011b965c 100644
|
|
|
314a7ca |
--- a/hw/xwayland/xwayland-input.c
|
|
|
314a7ca |
+++ b/hw/xwayland/xwayland-input.c
|
|
|
314a7ca |
@@ -1341,6 +1341,7 @@ tablet_handle_removed(void *data, struct zwp_tablet_v2 *tablet)
|
|
|
314a7ca |
DisableDevice(xwl_seat->eraser, TRUE);
|
|
|
314a7ca |
if (xwl_seat->puck)
|
|
|
314a7ca |
DisableDevice(xwl_seat->puck, TRUE);
|
|
|
314a7ca |
+ /* pads are removed separately */
|
|
|
314a7ca |
}
|
|
|
314a7ca |
|
|
|
314a7ca |
zwp_tablet_v2_destroy(tablet);
|
|
|
314a7ca |
@@ -1701,6 +1702,418 @@ static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = {
|
|
|
314a7ca |
};
|
|
|
314a7ca |
|
|
|
314a7ca |
static void
|
|
|
314a7ca |
+tablet_pad_ring_destroy(struct xwl_tablet_pad_ring *ring)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ zwp_tablet_pad_ring_v2_destroy(ring->ring);
|
|
|
314a7ca |
+ xorg_list_del(&ring->link);
|
|
|
314a7ca |
+ free(ring);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_ring_source(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2,
|
|
|
314a7ca |
+ uint32_t source)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_ring_angle(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2,
|
|
|
314a7ca |
+ wl_fixed_t degrees)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad_ring *ring = data;
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = ring->group->pad;
|
|
|
314a7ca |
+ double deg = wl_fixed_to_double(degrees);
|
|
|
314a7ca |
+ ValuatorMask mask;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ valuator_mask_zero(&mask);
|
|
|
314a7ca |
+ valuator_mask_set(&mask, 5 + ring->index, deg/360.0 * 71);
|
|
|
314a7ca |
+ QueuePointerEvents(pad->xdevice, MotionNotify, 0, 0, &mask);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_ring_stop(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_ring_frame(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2,
|
|
|
314a7ca |
+ uint32_t time)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static const struct zwp_tablet_pad_ring_v2_listener tablet_pad_ring_listener = {
|
|
|
314a7ca |
+ tablet_pad_ring_source,
|
|
|
314a7ca |
+ tablet_pad_ring_angle,
|
|
|
314a7ca |
+ tablet_pad_ring_stop,
|
|
|
314a7ca |
+ tablet_pad_ring_frame,
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_strip_destroy(struct xwl_tablet_pad_strip *strip)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ zwp_tablet_pad_strip_v2_destroy(strip->strip);
|
|
|
314a7ca |
+ xorg_list_del(&strip->link);
|
|
|
314a7ca |
+ free(strip);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_strip_source(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2,
|
|
|
314a7ca |
+ uint32_t source)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_strip_position(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2,
|
|
|
314a7ca |
+ uint32_t position)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad_strip *strip = data;
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = strip->group->pad;
|
|
|
314a7ca |
+ ValuatorMask mask;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ valuator_mask_zero(&mask);
|
|
|
314a7ca |
+ valuator_mask_set(&mask, 3 + strip->index, position/65535.0 * 2048);
|
|
|
314a7ca |
+ QueuePointerEvents(pad->xdevice, MotionNotify, 0, 0, &mask);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_strip_stop(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_strip_frame(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2,
|
|
|
314a7ca |
+ uint32_t time)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static const struct zwp_tablet_pad_strip_v2_listener tablet_pad_strip_listener = {
|
|
|
314a7ca |
+ tablet_pad_strip_source,
|
|
|
314a7ca |
+ tablet_pad_strip_position,
|
|
|
314a7ca |
+ tablet_pad_strip_stop,
|
|
|
314a7ca |
+ tablet_pad_strip_frame,
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_destroy(struct xwl_tablet_pad_group *group)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad_ring *r, *tr;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_strip *s, *ts;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ xorg_list_for_each_entry_safe(r, tr,
|
|
|
314a7ca |
+ &group->pad_group_ring_list,
|
|
|
314a7ca |
+ link)
|
|
|
314a7ca |
+ tablet_pad_ring_destroy(r);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ xorg_list_for_each_entry_safe(s, ts,
|
|
|
314a7ca |
+ &group->pad_group_strip_list,
|
|
|
314a7ca |
+ link)
|
|
|
314a7ca |
+ tablet_pad_strip_destroy(s);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ zwp_tablet_pad_group_v2_destroy(group->group);
|
|
|
314a7ca |
+ xorg_list_del(&group->link);
|
|
|
314a7ca |
+ free(group);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_buttons(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2,
|
|
|
314a7ca |
+ struct wl_array *buttons)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_ring(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_ring_v2 *wp_ring)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ static unsigned int ring_index = 0;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_group *group = data;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_ring *ring;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ ring = calloc(1, sizeof *ring);
|
|
|
314a7ca |
+ if (ring == NULL) {
|
|
|
314a7ca |
+ ErrorF("%s ENOMEM\n", __func__);
|
|
|
314a7ca |
+ return;
|
|
|
314a7ca |
+ }
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ ring->index = ring_index++;
|
|
|
314a7ca |
+ ring->group = group;
|
|
|
314a7ca |
+ ring->ring = wp_ring;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ xorg_list_add(&ring->link, &group->pad_group_ring_list);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ zwp_tablet_pad_ring_v2_add_listener(wp_ring, &tablet_pad_ring_listener,
|
|
|
314a7ca |
+ ring);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_strip(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_strip_v2 *wp_strip)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ static unsigned int strip_index = 0;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_group *group = data;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_strip *strip;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ strip = calloc(1, sizeof *strip);
|
|
|
314a7ca |
+ if (strip == NULL) {
|
|
|
314a7ca |
+ ErrorF("%s ENOMEM\n", __func__);
|
|
|
314a7ca |
+ return;
|
|
|
314a7ca |
+ }
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ strip->index = strip_index++;
|
|
|
314a7ca |
+ strip->group = group;
|
|
|
314a7ca |
+ strip->strip = wp_strip;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ xorg_list_add(&strip->link, &group->pad_group_strip_list);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ zwp_tablet_pad_strip_v2_add_listener(wp_strip, &tablet_pad_strip_listener,
|
|
|
314a7ca |
+ strip);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_modes(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2,
|
|
|
314a7ca |
+ uint32_t modes)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_done(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group_mode_switch(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2,
|
|
|
314a7ca |
+ uint32_t time,
|
|
|
314a7ca |
+ uint32_t serial,
|
|
|
314a7ca |
+ uint32_t mode)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static struct zwp_tablet_pad_group_v2_listener tablet_pad_group_listener = {
|
|
|
314a7ca |
+ tablet_pad_group_buttons,
|
|
|
314a7ca |
+ tablet_pad_group_ring,
|
|
|
314a7ca |
+ tablet_pad_group_strip,
|
|
|
314a7ca |
+ tablet_pad_group_modes,
|
|
|
314a7ca |
+ tablet_pad_group_done,
|
|
|
314a7ca |
+ tablet_pad_group_mode_switch,
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static int
|
|
|
314a7ca |
+xwl_tablet_pad_proc(DeviceIntPtr device, int what)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = device->public.devicePrivate;
|
|
|
314a7ca |
+ /* Axis layout mirrors that of xf86-input-wacom to have better
|
|
|
314a7ca |
+ compatibility with existing clients */
|
|
|
314a7ca |
+#define NAXES 7
|
|
|
314a7ca |
+ Atom axes_labels[NAXES] = { 0 };
|
|
|
314a7ca |
+ BYTE map[MAX_BUTTONS + 1];
|
|
|
314a7ca |
+ int i = 0;
|
|
|
314a7ca |
+ Atom btn_labels[MAX_BUTTONS] = { 0 }; /* btn labels are meaningless */
|
|
|
314a7ca |
+ int nbuttons;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ switch (what) {
|
|
|
314a7ca |
+ case DEVICE_INIT:
|
|
|
314a7ca |
+ device->public.on = FALSE;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
|
|
|
314a7ca |
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
|
|
|
314a7ca |
+ /* The others have no good mapping */
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels,
|
|
|
314a7ca |
+ GetMotionHistorySize(), Absolute))
|
|
|
314a7ca |
+ return BadValue;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ for (i = 1; i <= MAX_BUTTONS; i++)
|
|
|
314a7ca |
+ map[i] = i;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ /* We need at least 7 buttons to allow scrolling */
|
|
|
314a7ca |
+ nbuttons = min(max(pad->nbuttons + 4, 7), MAX_BUTTONS);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ if (!InitButtonClassDeviceStruct(device, nbuttons,
|
|
|
314a7ca |
+ btn_labels, map))
|
|
|
314a7ca |
+ return BadValue;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ /* Valuators */
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 0, axes_labels[0],
|
|
|
314a7ca |
+ 0, 100, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 1, axes_labels[1],
|
|
|
314a7ca |
+ 0, 100, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+ /* Pressure - unused, for backwards compat only */
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 2, axes_labels[2],
|
|
|
314a7ca |
+ 0, 2048, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+ /* strip x */
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 3, axes_labels[3],
|
|
|
314a7ca |
+ 0, 2048, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+ /* strip y */
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 4, axes_labels[4],
|
|
|
314a7ca |
+ 0, 2048, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+ /* ring */
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 5, axes_labels[5],
|
|
|
314a7ca |
+ 0, 71, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+ /* ring2 */
|
|
|
314a7ca |
+ InitValuatorAxisStruct(device, 6, axes_labels[6],
|
|
|
314a7ca |
+ 0, 71, 1, 0, 1, Absolute);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
|
|
|
314a7ca |
+ return BadValue;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ return Success;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ case DEVICE_ON:
|
|
|
314a7ca |
+ device->public.on = TRUE;
|
|
|
314a7ca |
+ return Success;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ case DEVICE_OFF:
|
|
|
314a7ca |
+ case DEVICE_CLOSE:
|
|
|
314a7ca |
+ device->public.on = FALSE;
|
|
|
314a7ca |
+ return Success;
|
|
|
314a7ca |
+ }
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ return BadMatch;
|
|
|
314a7ca |
+#undef NAXES
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_group(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *pad_group)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = data;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_group *group;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ group = calloc(1, sizeof *group);
|
|
|
314a7ca |
+ if (pad == NULL) {
|
|
|
314a7ca |
+ ErrorF("%s ENOMEM\n", __func__);
|
|
|
314a7ca |
+ return;
|
|
|
314a7ca |
+ }
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ group->pad = pad;
|
|
|
314a7ca |
+ group->group = pad_group;
|
|
|
314a7ca |
+ xorg_list_init(&group->pad_group_ring_list);
|
|
|
314a7ca |
+ xorg_list_init(&group->pad_group_strip_list);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ xorg_list_add(&group->link, &pad->pad_group_list);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ zwp_tablet_pad_group_v2_add_listener(pad_group,
|
|
|
314a7ca |
+ &tablet_pad_group_listener,
|
|
|
314a7ca |
+ group);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_path(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2,
|
|
|
314a7ca |
+ const char *path)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_buttons(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2,
|
|
|
314a7ca |
+ uint32_t buttons)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = data;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ pad->nbuttons = buttons;
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_done(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = data;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ pad->xdevice = add_device(pad->seat, "xwayland-pad",
|
|
|
314a7ca |
+ xwl_tablet_pad_proc);
|
|
|
314a7ca |
+ pad->xdevice->public.devicePrivate = pad;
|
|
|
314a7ca |
+ ActivateDevice(pad->xdevice, TRUE);
|
|
|
314a7ca |
+ EnableDevice(pad->xdevice, TRUE);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_button(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2,
|
|
|
314a7ca |
+ uint32_t time,
|
|
|
314a7ca |
+ uint32_t button,
|
|
|
314a7ca |
+ uint32_t state)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = data;
|
|
|
314a7ca |
+ ValuatorMask mask;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ button++; /* wayland index vs X's 1-offset */
|
|
|
314a7ca |
+ /* skip scroll wheel buttons 4-7 */
|
|
|
314a7ca |
+ button = button > 3 ? button + 4 : button;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ valuator_mask_zero(&mask);
|
|
|
314a7ca |
+ QueuePointerEvents(pad->xdevice,
|
|
|
314a7ca |
+ state ? ButtonPress : ButtonRelease, button, 0, &mask);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_enter(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2,
|
|
|
314a7ca |
+ uint32_t serial,
|
|
|
314a7ca |
+ struct zwp_tablet_v2 *tablet,
|
|
|
314a7ca |
+ struct wl_surface *surface)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ /* pairs the pad with the tablet but also to set the focus. We
|
|
|
314a7ca |
+ * don't care about the pairing and always use X's focus */
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_leave(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2,
|
|
|
314a7ca |
+ uint32_t serial,
|
|
|
314a7ca |
+ struct wl_surface *surface)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ /* pairs the pad with the tablet but also to set the focus. We
|
|
|
314a7ca |
+ * don't care about the pairing and always use X's focus */
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
+tablet_pad_removed(void *data,
|
|
|
314a7ca |
+ struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2)
|
|
|
314a7ca |
+{
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad = data;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_group *g, *tg;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ xorg_list_for_each_entry_safe(g, tg, &pad->pad_group_list, link)
|
|
|
314a7ca |
+ tablet_pad_group_destroy(g);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ RemoveDevice(pad->xdevice, TRUE);
|
|
|
314a7ca |
+ xorg_list_del(&pad->link);
|
|
|
314a7ca |
+ zwp_tablet_pad_v2_destroy(pad->pad);
|
|
|
314a7ca |
+ free(pad);
|
|
|
314a7ca |
+}
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static const struct zwp_tablet_pad_v2_listener tablet_pad_listener = {
|
|
|
314a7ca |
+ tablet_pad_group,
|
|
|
314a7ca |
+ tablet_pad_path,
|
|
|
314a7ca |
+ tablet_pad_buttons,
|
|
|
314a7ca |
+ tablet_pad_done,
|
|
|
314a7ca |
+ tablet_pad_button,
|
|
|
314a7ca |
+ tablet_pad_enter,
|
|
|
314a7ca |
+ tablet_pad_leave,
|
|
|
314a7ca |
+ tablet_pad_removed,
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+static void
|
|
|
314a7ca |
tablet_seat_handle_add_tablet(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
|
|
|
314a7ca |
struct zwp_tablet_v2 *tablet)
|
|
|
314a7ca |
{
|
|
|
314a7ca |
@@ -1769,8 +2182,12 @@ tablet_seat_handle_add_pad(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
|
|
|
314a7ca |
|
|
|
314a7ca |
xwl_tablet_pad->pad = pad;
|
|
|
314a7ca |
xwl_tablet_pad->seat = xwl_seat;
|
|
|
314a7ca |
+ xorg_list_init(&xwl_tablet_pad->pad_group_list);
|
|
|
314a7ca |
|
|
|
314a7ca |
xorg_list_add(&xwl_tablet_pad->link, &xwl_seat->tablet_pads);
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ zwp_tablet_pad_v2_add_listener(pad, &tablet_pad_listener,
|
|
|
314a7ca |
+ xwl_tablet_pad);
|
|
|
314a7ca |
}
|
|
|
314a7ca |
|
|
|
314a7ca |
static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
|
|
|
314a7ca |
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
|
|
|
314a7ca |
index 02a218c43..250564f73 100644
|
|
|
314a7ca |
--- a/hw/xwayland/xwayland.h
|
|
|
314a7ca |
+++ b/hw/xwayland/xwayland.h
|
|
|
314a7ca |
@@ -216,10 +216,38 @@ struct xwl_tablet_tool {
|
|
|
314a7ca |
struct xwl_cursor cursor;
|
|
|
314a7ca |
};
|
|
|
314a7ca |
|
|
|
314a7ca |
+struct xwl_tablet_pad_ring {
|
|
|
314a7ca |
+ unsigned int index;
|
|
|
314a7ca |
+ struct xorg_list link;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_group *group;
|
|
|
314a7ca |
+ struct zwp_tablet_pad_ring_v2 *ring;
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+struct xwl_tablet_pad_strip {
|
|
|
314a7ca |
+ unsigned int index;
|
|
|
314a7ca |
+ struct xorg_list link;
|
|
|
314a7ca |
+ struct xwl_tablet_pad_group *group;
|
|
|
314a7ca |
+ struct zwp_tablet_pad_strip_v2 *strip;
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+struct xwl_tablet_pad_group {
|
|
|
314a7ca |
+ struct xorg_list link;
|
|
|
314a7ca |
+ struct xwl_tablet_pad *pad;
|
|
|
314a7ca |
+ struct zwp_tablet_pad_group_v2 *group;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ struct xorg_list pad_group_ring_list;
|
|
|
314a7ca |
+ struct xorg_list pad_group_strip_list;
|
|
|
314a7ca |
+};
|
|
|
314a7ca |
+
|
|
|
314a7ca |
struct xwl_tablet_pad {
|
|
|
314a7ca |
struct xorg_list link;
|
|
|
314a7ca |
struct zwp_tablet_pad_v2 *pad;
|
|
|
314a7ca |
struct xwl_seat *seat;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ DeviceIntPtr xdevice;
|
|
|
314a7ca |
+
|
|
|
314a7ca |
+ unsigned int nbuttons;
|
|
|
314a7ca |
+ struct xorg_list pad_group_list;
|
|
|
314a7ca |
};
|
|
|
314a7ca |
|
|
|
314a7ca |
struct xwl_output {
|
|
|
314a7ca |
--
|
|
|
314a7ca |
2.13.5
|
|
|
314a7ca |
|