Commit 7d48b758 authored by Jason Gerecke's avatar Jason Gerecke Committed by Peter Hutterer

xwayland: Bind to wp_tablet_manager if available and get its seats

If we're notified about the existence of the wp_tablet_manager interface,
we bind to it so that we can make use of any tablets that are (or later
become) available. For each seat that exists or comes into existance at
a later point, obtain the associated tablet_seat.
Signed-off-by: Jason Gerecke's avatarJason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Carlos Garnacho's avatarCarlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Acked-by: default avatarPing Cheng <ping.cheng@wacom.com>
parent 89c84191
......@@ -56,6 +56,12 @@ xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator *warp_emul
static void
xwl_seat_destroy_confined_pointer(struct xwl_seat *xwl_seat);
static void
init_tablet_manager_seat(struct xwl_screen *xwl_screen,
struct xwl_seat *xwl_seat);
static void
release_tablet_manager_seat(struct xwl_seat *xwl_seat);
static void
xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl)
{
......@@ -1141,6 +1147,9 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version
xwl_seat->cursor = wl_compositor_create_surface(xwl_screen->compositor);
wl_seat_add_listener(xwl_seat->seat, &seat_listener, xwl_seat);
init_tablet_manager_seat(xwl_screen, xwl_seat);
wl_array_init(&xwl_seat->keys);
xorg_list_init(&xwl_seat->touches);
......@@ -1164,6 +1173,8 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
free (p);
}
release_tablet_manager_seat(xwl_seat);
wl_seat_destroy(xwl_seat->seat);
wl_surface_destroy(xwl_seat->cursor);
if (xwl_seat->cursor_frame_cb)
......@@ -1172,6 +1183,52 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
free(xwl_seat);
}
static void
init_tablet_manager_seat(struct xwl_screen *xwl_screen,
struct xwl_seat *xwl_seat)
{
if (!xwl_screen->tablet_manager)
return;
xwl_seat->tablet_seat =
zwp_tablet_manager_v2_get_tablet_seat(xwl_screen->tablet_manager,
xwl_seat->seat);
}
static void
release_tablet_manager_seat(struct xwl_seat *xwl_seat)
{
if (xwl_seat->tablet_seat) {
zwp_tablet_seat_v2_destroy(xwl_seat->tablet_seat);
xwl_seat->tablet_seat = NULL;
}
}
static void
init_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) {
init_tablet_manager_seat(xwl_screen, xwl_seat);
}
}
void
xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen)
{
if (xwl_screen->tablet_manager) {
zwp_tablet_manager_v2_destroy(xwl_screen->tablet_manager);
xwl_screen->tablet_manager = NULL;
}
}
static void
init_relative_pointer_manager(struct xwl_screen *xwl_screen,
uint32_t id, uint32_t version)
......@@ -1205,6 +1262,8 @@ input_handler(void *data, struct wl_registry *registry, uint32_t id,
init_relative_pointer_manager(xwl_screen, id, version);
} else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0) {
init_pointer_constraints(xwl_screen, id, version);
} else if (strcmp(interface, "zwp_tablet_manager_v2") == 0) {
init_tablet_manager(xwl_screen, id, version);
}
}
......
......@@ -222,6 +222,8 @@ xwl_close_screen(ScreenPtr screen)
&xwl_screen->seat_list, link)
xwl_seat_destroy(xwl_seat);
xwl_screen_release_tablet_manager(xwl_screen);
RemoveNotifyFd(xwl_screen->wayland_fd);
wl_display_disconnect(xwl_screen->display);
......
......@@ -76,6 +76,7 @@ struct xwl_screen {
struct wl_registry *registry;
struct wl_registry *input_registry;
struct wl_compositor *compositor;
struct zwp_tablet_manager_v2 *tablet_manager;
struct wl_shm *shm;
struct wl_shell *shell;
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
......@@ -140,6 +141,7 @@ struct xwl_seat {
struct zwp_relative_pointer_v1 *wp_relative_pointer;
struct wl_keyboard *wl_keyboard;
struct wl_touch *wl_touch;
struct zwp_tablet_seat_v2 *tablet_seat;
struct wl_array keys;
struct xwl_window *focus_window;
uint32_t id;
......@@ -244,6 +246,8 @@ Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
uint32_t id, uint32_t version);
struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
#ifdef XV
/* glamor Xv Adaptor */
Bool xwl_glamor_xv_init(ScreenPtr pScreen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment