[PATCH xwayland 3/7] xwayland: Handle wp_tablet_seat events
Carlos Garnacho
carlosg at gnome.org
Fri Nov 4 20:15:13 UTC 2016
From: Jason Gerecke <killertofu at gmail.com>
Whenever the tablet manager is obtained, ensure we create the
corresponding zwp_tablet_seat_v2 for every xwl_seat we have.
Likewise, whenever a new wl_seat is known and there is a tablet
manager available, create the zwp_tablet_seat_v2 right away.
Tablets and tools that we're notified about are simply stored for later
use at this moment.
Signed-off-by: Jason Gerecke <jason.gerecke at wacom.com>
Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
---
hw/xwayland/xwayland-input.c | 66 ++++++++++++++++++++++++++++++++++++++++++++
hw/xwayland/xwayland.h | 15 ++++++++++
2 files changed, 81 insertions(+)
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 408b170..a03462a 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -62,6 +62,9 @@ static void
xwl_seat_destroy_confined_pointer(struct xwl_seat *xwl_seat);
static void
+create_tablet_seat(struct xwl_seat *xwl_seat);
+
+static void
xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl)
{
/* Nothing to do, dix handles all settings */
@@ -1144,6 +1147,10 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version
xorg_list_init(&xwl_seat->touches);
xorg_list_init(&xwl_seat->sync_pending);
+ xorg_list_init(&xwl_seat->tablets);
+ xorg_list_init(&xwl_seat->tablet_tools);
+
+ create_tablet_seat(xwl_seat);
}
void
@@ -1173,12 +1180,71 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
static void
+tablet_seat_handle_add_tablet(void *data,
+ struct zwp_tablet_seat_v2 *tablet_seat,
+ struct zwp_tablet_v2 *tablet)
+{
+ struct xwl_seat *xwl_seat = data;
+ struct xwl_tablet *xwl_tablet;
+
+ xwl_tablet = calloc(sizeof *xwl_tablet, 1);
+ if (xwl_tablet == NULL) {
+ ErrorF("tablet_seat_add_input ENOMEM\n");
+ return;
+ }
+ xwl_tablet->tablet = tablet;
+ xwl_tablet->xwl_seat = xwl_seat;
+
+ xorg_list_add(&xwl_tablet->link, &xwl_seat->tablets);
+}
+
+static void
+tablet_seat_handle_add_tool(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
+ struct zwp_tablet_tool_v2 *tool)
+{
+ struct xwl_seat *xwl_seat = data;
+ struct xwl_tablet_tool *xwl_tablet_tool;
+
+ xwl_tablet_tool = calloc(sizeof *xwl_tablet_tool, 1);
+ if (xwl_tablet_tool == NULL) {
+ ErrorF("tablet_seat_add_tool ENOMEM\n");
+ return;
+ }
+ xwl_tablet_tool->tool = tool;
+ xwl_tablet_tool->xwl_seat = xwl_seat;
+
+ xorg_list_add(&xwl_tablet_tool->link, &xwl_seat->tablet_tools);
+}
+
+static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
+ tablet_seat_handle_add_tablet,
+ tablet_seat_handle_add_tool,
+};
+
+static void
+create_tablet_seat(struct xwl_seat *xwl_seat)
+{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+
+ if (!xwl_screen->tablet_manager)
+ return;
+
+ xwl_seat->tablet_seat = zwp_tablet_manager_v2_get_tablet_seat(xwl_screen->tablet_manager, xwl_seat->seat);
+ zwp_tablet_seat_v2_add_listener(xwl_seat->tablet_seat, &tablet_seat_listener, xwl_seat);
+}
+
+static void
create_tablet_manager(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version)
{
+ struct xwl_seat *xwl_seat;
+
xwl_screen->tablet_manager = wl_registry_bind(xwl_screen->registry,
id,
&zwp_tablet_manager_v2_interface,
min(version,1));
+
+ xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link)
+ create_tablet_seat(xwl_seat);
}
static void
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 09a4989..c02b903 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -175,6 +175,21 @@ struct xwl_seat {
double dx_unaccel;
double dy_unaccel;
} pending_pointer_event;
+
+ struct xorg_list tablets;
+ struct xorg_list tablet_tools;
+};
+
+struct xwl_tablet {
+ struct xorg_list link;
+ struct zwp_tablet_v2 *tablet;
+ struct xwl_seat *xwl_seat;
+};
+
+struct xwl_tablet_tool {
+ struct xorg_list link;
+ struct zwp_tablet_tool_v2 *tool;
+ struct xwl_seat *xwl_seat;
};
struct xwl_output {
--
2.9.3
More information about the xorg-devel
mailing list