diff --git a/meson.build b/meson.build index 0d199e86..1f0acff7 100644 --- a/meson.build +++ b/meson.build @@ -213,7 +213,7 @@ endif have_libwacom = get_option('libwacom') if have_libwacom config_h.set('HAVE_LIBWACOM', 1) - dep_libwacom = dependency('libwacom', version : '>= 0.27') + dep_libwacom = dependency('libwacom', version : '>= 2.14') if cc.has_header_symbol('libwacom/libwacom.h', 'WACOM_BUTTON_DIAL_MODESWITCH', dependencies : dep_libwacom) config_h.set('HAVE_LIBWACOM_BUTTON_DIAL_MODESWITCH', '1') diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 41495ce4..6d2f911f 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -31,12 +31,6 @@ #include "evdev-tablet.h" -#ifdef HAVE_LIBWACOM -#include -#else -typedef void *WacomStylus; -#endif - enum notify { DONT_NOTIFY, DO_NOTIFY, @@ -1401,14 +1395,20 @@ tablet_new_tool(struct tablet_dispatch *tablet, struct libinput_tablet_tool *tool = zalloc(sizeof *tool); const WacomStylus *s = NULL; #ifdef HAVE_LIBWACOM - WacomDeviceDatabase *db; + WacomDevice *device = tablet->libwacom_device; - db = tablet_libinput_context(tablet)->libwacom.db; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - if (db) - s = libwacom_stylus_get_for_id(db, tool_id); -#pragma GCC diagnostic pop + if (device) { + int nstyli; + const WacomStylus **styli = libwacom_get_styli(device, &nstyli); + + for (int i = 0; i < nstyli; i++) { + const WacomStylus *stylus = styli[i]; + if (libwacom_stylus_get_id(stylus) == (int)tool_id) { + s = stylus; + break; + } + } + } #endif *tool = (struct libinput_tablet_tool){ @@ -2451,6 +2451,11 @@ tablet_destroy(struct evdev_dispatch *dispatch) libinput_tablet_tool_unref(tool); } +#ifdef HAVE_LIBWACOM + if (tablet->libwacom_device) + libwacom_destroy(tablet->libwacom_device); +#endif + libinput_libwacom_unref(li); free(tablet); @@ -2939,12 +2944,12 @@ static int tablet_init(struct tablet_dispatch *tablet, struct evdev_device *device) { static unsigned int tablet_ids = 0; - struct libinput *li = evdev_libinput_context(device); struct libevdev *evdev = device->evdev; enum libinput_tablet_tool_axis axis; int rc = -1; WacomDevice *wacom = NULL; #ifdef HAVE_LIBWACOM + struct libinput *li = evdev_libinput_context(device); WacomDeviceDatabase *db = libinput_libwacom_ref(li); if (db) { char event_path[64]; @@ -2968,6 +2973,7 @@ tablet_init(struct tablet_dispatch *tablet, struct evdev_device *device) evdev_device_get_id_vendor(device), evdev_device_get_id_product(device)); } + tablet->libwacom_device = wacom; } #endif @@ -3020,8 +3026,6 @@ tablet_init(struct tablet_dispatch *tablet, struct evdev_device *device) rc = 0; out: #ifdef HAVE_LIBWACOM - if (wacom) - libwacom_destroy(wacom); if (db) libinput_libwacom_unref(li); #endif diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h index 091a9de4..8a28cf17 100644 --- a/src/evdev-tablet.h +++ b/src/evdev-tablet.h @@ -62,6 +62,7 @@ struct tablet_dispatch { struct evdev_dispatch base; struct evdev_device *device; unsigned int tablet_id; /* incremental ID */ + WacomDevice *libwacom_device; unsigned int status; unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_TOOL_AXIS_MAX + 1)]; diff --git a/src/libinput-private.h b/src/libinput-private.h index b49a5838..f4290b65 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -33,6 +33,8 @@ #ifdef HAVE_LIBWACOM #include +#else +typedef void *WacomStylus; #endif #include "util-bits.h"