From 94f65e354d09ded037e6ba724dc3eeed6d63778f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 9 Aug 2019 10:18:54 +0900 Subject: [PATCH] Add libinput-1.14 support This libinput version adds a new tablet tool type. --- backend/libinput/tablet_tool.c | 4 ++++ include/wlr/types/wlr_tablet_tool.h | 25 +++++++++++++++++-------- meson.build | 9 +++++++++ types/tablet_v2/wlr_tablet_v2_tool.c | 20 +++++++++++++++++++- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 4e87b700..ff48f6a3 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -113,6 +113,10 @@ static enum wlr_tablet_tool_type wlr_type_from_libinput_type( return WLR_TABLET_TOOL_TYPE_MOUSE; case LIBINPUT_TABLET_TOOL_TYPE_LENS: return WLR_TABLET_TOOL_TYPE_LENS; +#if LIBINPUT_MINOR >= 14 + case LIBINPUT_TABLET_TOOL_TYPE_TOTEM: + return WLR_TABLET_TOOL_TYPE_TOTEM; +#endif } assert(false && "UNREACHABLE"); diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h index f732ad40..bd797915 100644 --- a/include/wlr/types/wlr_tablet_tool.h +++ b/include/wlr/types/wlr_tablet_tool.h @@ -19,14 +19,23 @@ * tablet-unstable-v2 headers, so we can't include them */ enum wlr_tablet_tool_type { - WLR_TABLET_TOOL_TYPE_PEN = 1, /**< A generic pen */ - WLR_TABLET_TOOL_TYPE_ERASER, /**< Eraser */ - WLR_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */ - WLR_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g. - Wacom Inking Pen */ - WLR_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */ - WLR_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */ - WLR_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */ + /** A generic pen */ + WLR_TABLET_TOOL_TYPE_PEN = 1, + /** Eraser */ + WLR_TABLET_TOOL_TYPE_ERASER, + /** A paintbrush-like tool */ + WLR_TABLET_TOOL_TYPE_BRUSH, + /** Physical drawing tool, e.g. Wacom Inking Pen */ + WLR_TABLET_TOOL_TYPE_PENCIL, + /** An airbrush-like tool */ + WLR_TABLET_TOOL_TYPE_AIRBRUSH, + /** A mouse bound to the tablet */ + WLR_TABLET_TOOL_TYPE_MOUSE, + /** A mouse tool with a lens */ + WLR_TABLET_TOOL_TYPE_LENS, + /** A rotary device with positional and rotation data */ + WLR_TABLET_TOOL_TYPE_TOTEM, + }; struct wlr_tablet_tool { diff --git a/meson.build b/meson.build index dfada444..5dda5540 100644 --- a/meson.build +++ b/meson.build @@ -128,6 +128,15 @@ if logind.found() wlr_deps += logind endif +if libinput.found() + ver = libinput.version().split('.') + add_project_arguments([ + '-DLIBINPUT_MAJOR=' + ver[0], + '-DLIBINPUT_MINOR=' + ver[1], + '-DLIBINPUT_PATCH=' + ver[2], + ], language: 'c') +endif + subdir('protocol') subdir('render') diff --git a/types/tablet_v2/wlr_tablet_v2_tool.c b/types/tablet_v2/wlr_tablet_v2_tool.c index 7b989fbf..2decf4d7 100644 --- a/types/tablet_v2/wlr_tablet_v2_tool.c +++ b/types/tablet_v2/wlr_tablet_v2_tool.c @@ -42,7 +42,7 @@ static void handle_tablet_tool_v2_set_cursor(struct wl_client *client, .hotspot_x = hotspot_x, .hotspot_y = hotspot_y, .seat_client = tool->seat->seat_client, - }; + }; wl_signal_emit(&tool->tool->events.set_cursor, &evt); } @@ -73,6 +73,9 @@ static enum zwp_tablet_tool_v2_type tablet_type_from_wlr_type( return ZWP_TABLET_TOOL_V2_TYPE_MOUSE; case WLR_TABLET_TOOL_TYPE_LENS: return ZWP_TABLET_TOOL_V2_TYPE_LENS; + default: + /* We skip these devices earlier on */ + assert(false && "Unreachable"); } assert(false && "Unreachable"); @@ -196,6 +199,21 @@ struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create( struct wlr_tablet_manager_v2 *manager, struct wlr_seat *wlr_seat, struct wlr_tablet_tool *wlr_tool) { + switch (wlr_tool->type) { + case WLR_TABLET_TOOL_TYPE_PEN: + case WLR_TABLET_TOOL_TYPE_ERASER: + case WLR_TABLET_TOOL_TYPE_BRUSH: + case WLR_TABLET_TOOL_TYPE_PENCIL: + case WLR_TABLET_TOOL_TYPE_AIRBRUSH: + case WLR_TABLET_TOOL_TYPE_MOUSE: + case WLR_TABLET_TOOL_TYPE_LENS: + /* supported */ + break; + default: + /* Unsupported */ + return NULL; + } + struct wlr_tablet_seat_v2 *seat = get_or_create_tablet_seat(manager, wlr_seat); if (!seat) { return NULL;