rename wlr_tablet_tool to wlr_tablet

The previous naming was based on the input-device capability names from
libinput.
With code that uses the libinput_tablet_tool and mapping into tablet-v2,
this is confusing, so the name is changed to follow the names used in
the protocol.
master
Markus Ongyerth 7 years ago
parent b84288af16
commit d9e978e1b3

@ -60,12 +60,12 @@ struct wlr_input_device *wlr_headless_add_input_device(
wlr_touch_init(wlr_device->touch, NULL); wlr_touch_init(wlr_device->touch, NULL);
break; break;
case WLR_INPUT_DEVICE_TABLET_TOOL: case WLR_INPUT_DEVICE_TABLET_TOOL:
wlr_device->tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool)); wlr_device->tablet = calloc(1, sizeof(struct wlr_tablet));
if (wlr_device->tablet_tool == NULL) { if (wlr_device->tablet == NULL) {
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool"); wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet");
goto error; goto error;
} }
wlr_tablet_tool_init(wlr_device->tablet_tool, NULL); wlr_tablet_init(wlr_device->tablet, NULL);
break; break;
case WLR_INPUT_DEVICE_TABLET_PAD: case WLR_INPUT_DEVICE_TABLET_PAD:
wlr_device->tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad)); wlr_device->tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));

@ -130,8 +130,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
if (!wlr_dev) { if (!wlr_dev) {
goto fail; goto fail;
} }
wlr_dev->tablet_tool = create_libinput_tablet_tool(libinput_dev); wlr_dev->tablet = create_libinput_tablet(libinput_dev);
if (!wlr_dev->tablet_tool) { if (!wlr_dev->tablet) {
free(wlr_dev); free(wlr_dev);
goto fail; goto fail;
} }

@ -13,14 +13,14 @@
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h" #include "util/signal.h"
static struct wlr_tablet_tool_impl tool_impl; static struct wlr_tablet_impl tablet_impl;
static bool tablet_tool_is_libinput(struct wlr_tablet_tool *tool) { static bool tablet_is_libinput(struct wlr_tablet *tablet) {
return tool->impl == &tool_impl; return tablet->impl == &tablet_impl;
} }
struct wlr_libinput_tablet_tool { struct wlr_libinput_tablet_tool {
struct wlr_tablet_tool_tool wlr_tool; struct wlr_tablet_tool wlr_tool;
struct libinput_tablet_tool *libinput_tool; struct libinput_tablet_tool *libinput_tool;
@ -38,7 +38,7 @@ struct tablet_tool_list_elem {
}; };
struct wlr_libinput_tablet { struct wlr_libinput_tablet {
struct wlr_tablet_tool wlr_tool; struct wlr_tablet wlr_tablet;
struct wl_list tools; // tablet_tool_list_elem::link struct wl_list tools; // tablet_tool_list_elem::link
}; };
@ -51,10 +51,10 @@ static void destroy_tool_tool(struct wlr_libinput_tablet_tool *tool) {
} }
static void destroy_tablet_tool(struct wlr_tablet_tool *tool) { static void destroy_tablet(struct wlr_tablet *wlr_tablet) {
assert(tablet_tool_is_libinput(tool)); assert(tablet_is_libinput(wlr_tablet));
struct wlr_libinput_tablet *tablet = struct wlr_libinput_tablet *tablet =
wl_container_of(tool, tablet, wlr_tool); wl_container_of(wlr_tablet, tablet, wlr_tablet);
struct tablet_tool_list_elem *pos; struct tablet_tool_list_elem *pos;
struct tablet_tool_list_elem *tmp; struct tablet_tool_list_elem *tmp;
@ -71,29 +71,29 @@ static void destroy_tablet_tool(struct wlr_tablet_tool *tool) {
free(tablet); free(tablet);
} }
static struct wlr_tablet_tool_impl tool_impl = { static struct wlr_tablet_impl tablet_impl = {
.destroy = destroy_tablet_tool, .destroy = destroy_tablet,
}; };
struct wlr_tablet_tool *create_libinput_tablet_tool( struct wlr_tablet *create_libinput_tablet(
struct libinput_device *libinput_dev) { struct libinput_device *libinput_dev) {
assert(libinput_dev); assert(libinput_dev);
struct wlr_libinput_tablet *libinput_tablet_tool = struct wlr_libinput_tablet *libinput_tablet =
calloc(1, sizeof(struct wlr_libinput_tablet)); calloc(1, sizeof(struct wlr_libinput_tablet));
if (!libinput_tablet_tool) { if (!libinput_tablet) {
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool"); wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool");
return NULL; return NULL;
} }
struct wlr_tablet_tool *wlr_tablet_tool = &libinput_tablet_tool->wlr_tool; struct wlr_tablet *wlr_tablet = &libinput_tablet->wlr_tablet;
wlr_list_init(&wlr_tablet_tool->paths); wlr_list_init(&wlr_tablet->paths);
struct udev_device *udev = libinput_device_get_udev_device(libinput_dev); struct udev_device *udev = libinput_device_get_udev_device(libinput_dev);
wlr_list_push(&wlr_tablet_tool->paths, strdup(udev_device_get_syspath(udev))); wlr_list_push(&wlr_tablet->paths, strdup(udev_device_get_syspath(udev)));
wlr_tablet_tool->name = strdup(libinput_device_get_name(libinput_dev)); wlr_tablet->name = strdup(libinput_device_get_name(libinput_dev));
wl_list_init(&libinput_tablet_tool->tools); wl_list_init(&libinput_tablet->tools);
wlr_tablet_tool_init(wlr_tablet_tool, &tool_impl); wlr_tablet_init(wlr_tablet, &tablet_impl);
return wlr_tablet_tool; return wlr_tablet;
} }
static enum wlr_tablet_tool_type wlr_type_from_libinput_type( static enum wlr_tablet_tool_type wlr_type_from_libinput_type(
@ -154,11 +154,11 @@ static struct wlr_libinput_tablet_tool *get_wlr_tablet_tool(
} }
static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool, static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool,
struct wlr_tablet_tool *wlr_dev) { struct wlr_tablet *wlr_dev) {
assert(tablet_tool_is_libinput(wlr_dev)); assert(tablet_is_libinput(wlr_dev));
struct tablet_tool_list_elem *pos; struct wlr_libinput_tablet *tablet = wl_container_of(wlr_dev, tablet, wlr_tablet);
struct wlr_libinput_tablet *tablet = wl_container_of(wlr_dev, tablet, wlr_tool);
struct tablet_tool_list_elem *pos;
wl_list_for_each(pos, &tablet->tools, link) { wl_list_for_each(pos, &tablet->tools, link) {
if (pos->tool == tool) { // We already have a ref if (pos->tool == tool) { // We already have a ref
// XXX: We *could* optimize the tool to the front of // XXX: We *could* optimize the tool to the front of
@ -173,7 +173,8 @@ static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool,
struct tablet_tool_list_elem *new = struct tablet_tool_list_elem *new =
calloc(1, sizeof(struct tablet_tool_list_elem)); calloc(1, sizeof(struct tablet_tool_list_elem));
if (!new) {// TODO: Should we at least log? if (!new) {
wlr_log(WLR_ERROR, "Failed to allocate memory for tracking tablet tool");
return; return;
} }
@ -195,7 +196,7 @@ void handle_tablet_tool_axis(struct libinput_event *event,
struct wlr_event_tablet_tool_axis wlr_event = { 0 }; struct wlr_event_tablet_tool_axis wlr_event = { 0 };
struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool(
libinput_event_tablet_tool_get_tool(tevent)); libinput_event_tablet_tool_get_tool(tevent));
ensure_tool_reference(tool, wlr_dev->tablet_tool); ensure_tool_reference(tool, wlr_dev->tablet);
wlr_event.device = wlr_dev; wlr_event.device = wlr_dev;
wlr_event.tool = &tool->wlr_tool; wlr_event.tool = &tool->wlr_tool;
@ -239,7 +240,7 @@ void handle_tablet_tool_axis(struct libinput_event *event,
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent); wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
} }
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.axis, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet->events.axis, &wlr_event);
} }
void handle_tablet_tool_proximity(struct libinput_event *event, void handle_tablet_tool_proximity(struct libinput_event *event,
@ -255,7 +256,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
struct wlr_event_tablet_tool_proximity wlr_event = { 0 }; struct wlr_event_tablet_tool_proximity wlr_event = { 0 };
struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool(
libinput_event_tablet_tool_get_tool(tevent)); libinput_event_tablet_tool_get_tool(tevent));
ensure_tool_reference(tool, wlr_dev->tablet_tool); ensure_tool_reference(tool, wlr_dev->tablet);
wlr_event.tool = &tool->wlr_tool; wlr_event.tool = &tool->wlr_tool;
wlr_event.device = wlr_dev; wlr_event.device = wlr_dev;
@ -269,7 +270,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
wlr_event.state = WLR_TABLET_TOOL_PROXIMITY_IN; wlr_event.state = WLR_TABLET_TOOL_PROXIMITY_IN;
break; break;
} }
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.proximity, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet->events.proximity, &wlr_event);
if (libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) { if (libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) {
handle_tablet_tool_axis(event, libinput_dev); handle_tablet_tool_axis(event, libinput_dev);
@ -281,9 +282,9 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) { libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) {
// The tool isn't unique, it can't be on multiple tablets // The tool isn't unique, it can't be on multiple tablets
assert(tool->pad_refs == 1); assert(tool->pad_refs == 1);
assert(tablet_tool_is_libinput(wlr_dev->tablet_tool)); assert(tablet_is_libinput(wlr_dev->tablet));
struct wlr_libinput_tablet *tablet = struct wlr_libinput_tablet *tablet =
wl_container_of(wlr_dev->tablet_tool, tablet, wlr_tool); wl_container_of(wlr_dev->tablet, tablet, wlr_tablet);
struct tablet_tool_list_elem *pos; struct tablet_tool_list_elem *pos;
struct tablet_tool_list_elem *tmp; struct tablet_tool_list_elem *tmp;
@ -313,7 +314,7 @@ void handle_tablet_tool_tip(struct libinput_event *event,
struct wlr_event_tablet_tool_tip wlr_event = { 0 }; struct wlr_event_tablet_tool_tip wlr_event = { 0 };
struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool(
libinput_event_tablet_tool_get_tool(tevent)); libinput_event_tablet_tool_get_tool(tevent));
ensure_tool_reference(tool, wlr_dev->tablet_tool); ensure_tool_reference(tool, wlr_dev->tablet);
wlr_event.device = wlr_dev; wlr_event.device = wlr_dev;
wlr_event.tool = &tool->wlr_tool; wlr_event.tool = &tool->wlr_tool;
@ -327,7 +328,7 @@ void handle_tablet_tool_tip(struct libinput_event *event,
wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN; wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN;
break; break;
} }
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.tip, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet->events.tip, &wlr_event);
} }
void handle_tablet_tool_button(struct libinput_event *event, void handle_tablet_tool_button(struct libinput_event *event,
@ -344,7 +345,7 @@ void handle_tablet_tool_button(struct libinput_event *event,
struct wlr_event_tablet_tool_button wlr_event = { 0 }; struct wlr_event_tablet_tool_button wlr_event = { 0 };
struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool(
libinput_event_tablet_tool_get_tool(tevent)); libinput_event_tablet_tool_get_tool(tevent));
ensure_tool_reference(tool, wlr_dev->tablet_tool); ensure_tool_reference(tool, wlr_dev->tablet);
wlr_event.device = wlr_dev; wlr_event.device = wlr_dev;
wlr_event.tool = &tool->wlr_tool; wlr_event.tool = &tool->wlr_tool;
@ -359,5 +360,5 @@ void handle_tablet_tool_button(struct libinput_event *event,
wlr_event.state = WLR_BUTTON_PRESSED; wlr_event.state = WLR_BUTTON_PRESSED;
break; break;
} }
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.button, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet->events.button, &wlr_event);
} }

@ -326,11 +326,11 @@ void new_input_notify(struct wl_listener *listener, void *data) {
tstate->destroy.notify = tablet_tool_destroy_notify; tstate->destroy.notify = tablet_tool_destroy_notify;
wl_signal_add(&device->events.destroy, &tstate->destroy); wl_signal_add(&device->events.destroy, &tstate->destroy);
tstate->axis.notify = tablet_tool_axis_notify; tstate->axis.notify = tablet_tool_axis_notify;
wl_signal_add(&device->tablet_tool->events.axis, &tstate->axis); wl_signal_add(&device->tablet->events.axis, &tstate->axis);
tstate->proximity.notify = tablet_tool_proximity_notify; tstate->proximity.notify = tablet_tool_proximity_notify;
wl_signal_add(&device->tablet_tool->events.proximity, &tstate->proximity); wl_signal_add(&device->tablet->events.proximity, &tstate->proximity);
tstate->button.notify = tablet_tool_button_notify; tstate->button.notify = tablet_tool_button_notify;
wl_signal_add(&device->tablet_tool->events.button, &tstate->button); wl_signal_add(&device->tablet->events.button, &tstate->button);
wl_list_insert(&sample->tablet_tools, &tstate->link); wl_list_insert(&sample->tablet_tools, &tstate->link);
break; break;
default: default:

@ -65,7 +65,7 @@ void handle_touch_motion(struct libinput_event *event,
void handle_touch_cancel(struct libinput_event *event, void handle_touch_cancel(struct libinput_event *event,
struct libinput_device *device); struct libinput_device *device);
struct wlr_tablet_tool *create_libinput_tablet_tool( struct wlr_tablet *create_libinput_tablet(
struct libinput_device *device); struct libinput_device *device);
void handle_tablet_tool_axis(struct libinput_event *event, void handle_tablet_tool_axis(struct libinput_event *event,
struct libinput_device *device); struct libinput_device *device);

@ -3,12 +3,12 @@
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
struct wlr_tablet_tool_impl { struct wlr_tablet_impl {
void (*destroy)(struct wlr_tablet_tool *tool); void (*destroy)(struct wlr_tablet *tablet);
}; };
void wlr_tablet_tool_init(struct wlr_tablet_tool *tool, void wlr_tablet_init(struct wlr_tablet *tablet,
struct wlr_tablet_tool_impl *impl); struct wlr_tablet_impl *impl);
void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool); void wlr_tablet_destroy(struct wlr_tablet *tablet);
#endif #endif

@ -39,7 +39,7 @@ struct wlr_input_device {
struct wlr_keyboard *keyboard; struct wlr_keyboard *keyboard;
struct wlr_pointer *pointer; struct wlr_pointer *pointer;
struct wlr_touch *touch; struct wlr_touch *touch;
struct wlr_tablet_tool *tablet_tool; struct wlr_tablet *tablet;
struct wlr_tablet_pad *tablet_pad; struct wlr_tablet_pad *tablet_pad;
}; };

@ -15,13 +15,13 @@ enum wlr_tablet_tool_type {
WLR_TABLET_TOOL_TYPE_ERASER, /**< Eraser */ WLR_TABLET_TOOL_TYPE_ERASER, /**< Eraser */
WLR_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */ WLR_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */
WLR_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g. WLR_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g.
Wacom Inking Pen */ Wacom Inking Pen */
WLR_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */ WLR_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */
WLR_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */ WLR_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */
WLR_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */ WLR_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */
}; };
struct wlr_tablet_tool_tool { struct wlr_tablet_tool {
enum wlr_tablet_tool_type type; enum wlr_tablet_tool_type type;
uint64_t hardware_serial; uint64_t hardware_serial;
uint64_t hardware_wacom; uint64_t hardware_wacom;
@ -41,10 +41,10 @@ struct wlr_tablet_tool_tool {
void *data; void *data;
}; };
struct wlr_tablet_tool_impl; struct wlr_tablet_impl;
struct wlr_tablet_tool { struct wlr_tablet {
struct wlr_tablet_tool_impl *impl; struct wlr_tablet_impl *impl;
struct { struct {
struct wl_signal axis; struct wl_signal axis;
@ -73,7 +73,7 @@ enum wlr_tablet_tool_axes {
struct wlr_event_tablet_tool_axis { struct wlr_event_tablet_tool_axis {
struct wlr_input_device *device; struct wlr_input_device *device;
struct wlr_tablet_tool_tool *tool; struct wlr_tablet_tool *tool;
uint32_t time_msec; uint32_t time_msec;
uint32_t updated_axes; uint32_t updated_axes;
@ -96,7 +96,7 @@ enum wlr_tablet_tool_proximity_state {
struct wlr_event_tablet_tool_proximity { struct wlr_event_tablet_tool_proximity {
struct wlr_input_device *device; struct wlr_input_device *device;
struct wlr_tablet_tool_tool *tool; struct wlr_tablet_tool *tool;
uint32_t time_msec; uint32_t time_msec;
// From 0..1 // From 0..1
double x, y; double x, y;
@ -110,7 +110,7 @@ enum wlr_tablet_tool_tip_state {
struct wlr_event_tablet_tool_tip { struct wlr_event_tablet_tool_tip {
struct wlr_input_device *device; struct wlr_input_device *device;
struct wlr_tablet_tool_tool *tool; struct wlr_tablet_tool *tool;
uint32_t time_msec; uint32_t time_msec;
// From 0..1 // From 0..1
double x, y; double x, y;
@ -119,7 +119,7 @@ struct wlr_event_tablet_tool_tip {
struct wlr_event_tablet_tool_button { struct wlr_event_tablet_tool_button {
struct wlr_input_device *device; struct wlr_input_device *device;
struct wlr_tablet_tool_tool *tool; struct wlr_tablet_tool *tool;
uint32_t time_msec; uint32_t time_msec;
uint32_t button; uint32_t button;
enum wlr_button_state state; enum wlr_button_state state;

@ -26,7 +26,7 @@ struct wlr_tablet_manager_v2 {
struct wlr_tablet_v2_tablet { struct wlr_tablet_v2_tablet {
struct wl_list link; // wlr_tablet_seat_v2::tablets struct wl_list link; // wlr_tablet_seat_v2::tablets
struct wlr_tablet_tool *wlr_tool; struct wlr_tablet *wlr_tablet;
struct wlr_input_device *wlr_device; struct wlr_input_device *wlr_device;
struct wl_list clients; // wlr_tablet_client_v2::tablet_link struct wl_list clients; // wlr_tablet_client_v2::tablet_link
@ -37,7 +37,7 @@ struct wlr_tablet_v2_tablet {
struct wlr_tablet_v2_tablet_tool { struct wlr_tablet_v2_tablet_tool {
struct wl_list link; // wlr_tablet_seat_v2::tablets struct wl_list link; // wlr_tablet_seat_v2::tablets
struct wlr_tablet_tool_tool *wlr_tool; struct wlr_tablet_tool *wlr_tool;
struct wl_list clients; // wlr_tablet_tool_client_v2::tool_link struct wl_list clients; // wlr_tablet_tool_client_v2::tool_link
struct wl_listener tool_destroy; struct wl_listener tool_destroy;
@ -105,7 +105,7 @@ struct wlr_tablet_v2_tablet_pad *wlr_tablet_pad_create(
struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create( struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create(
struct wlr_tablet_manager_v2 *manager, struct wlr_tablet_manager_v2 *manager,
struct wlr_seat *wlr_seat, struct wlr_seat *wlr_seat,
struct wlr_tablet_tool_tool *wlr_tool); struct wlr_tablet_tool *wlr_tool);
struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display); struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display);
void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager); void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager);

@ -103,7 +103,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
static void handle_tablet_tool_position(struct roots_cursor *cursor, static void handle_tablet_tool_position(struct roots_cursor *cursor,
struct roots_tablet_tool *tool, struct roots_tablet_tool *tool,
struct wlr_tablet_tool_tool *tool_tool, struct wlr_tablet_tool *tool_tool,
bool change_x, bool change_y, bool change_x, bool change_y,
double x, double y, double dx, double dy) { double x, double y, double dx, double dy) {
if (!change_x && !change_y) { if (!change_x && !change_y) {
@ -264,7 +264,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat); wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
struct wlr_event_tablet_tool_proximity *event = data; struct wlr_event_tablet_tool_proximity *event = data;
struct wlr_tablet_tool_tool *tool = event->tool; struct wlr_tablet_tool *tool = event->tool;
if (!tool->data) { if (!tool->data) {
struct roots_tablet_tool_tool *roots_tool = struct roots_tablet_tool_tool *roots_tool =
calloc(1, sizeof(struct roots_tablet_tool_tool)); calloc(1, sizeof(struct roots_tablet_tool_tool));

@ -59,13 +59,13 @@ struct wlr_tablet_v2_tablet *wlr_tablet_create(
if (!seat) { if (!seat) {
return NULL; return NULL;
} }
struct wlr_tablet_tool *tool = wlr_device->tablet_tool; struct wlr_tablet *wlr_tablet = wlr_device->tablet;
struct wlr_tablet_v2_tablet *tablet = calloc(1, sizeof(struct wlr_tablet_v2_tablet)); struct wlr_tablet_v2_tablet *tablet = calloc(1, sizeof(struct wlr_tablet_v2_tablet));
if (!tablet) { if (!tablet) {
return NULL; return NULL;
} }
tablet->wlr_tool = tool; tablet->wlr_tablet = wlr_tablet;
tablet->wlr_device = wlr_device; tablet->wlr_device = wlr_device;
wl_list_init(&tablet->clients); wl_list_init(&tablet->clients);
@ -107,14 +107,15 @@ void add_tablet_client(struct wlr_tablet_seat_client_v2 *seat,
zwp_tablet_seat_v2_send_tablet_added(seat->resource, client->resource); zwp_tablet_seat_v2_send_tablet_added(seat->resource, client->resource);
// Send the expected events // Send the expected events
if (tablet->wlr_tool->name) { if (tablet->wlr_tablet->name) {
zwp_tablet_v2_send_name(client->resource, tablet->wlr_tool->name); zwp_tablet_v2_send_name(client->resource,
tablet->wlr_tablet->name);
} }
zwp_tablet_v2_send_id(client->resource, zwp_tablet_v2_send_id(client->resource,
tablet->wlr_device->vendor, tablet->wlr_device->product); tablet->wlr_device->vendor, tablet->wlr_device->product);
for (size_t i = 0; i < tablet->wlr_tool->paths.length; ++i) { for (size_t i = 0; i < tablet->wlr_tablet->paths.length; ++i) {
zwp_tablet_v2_send_path(client->resource, zwp_tablet_v2_send_path(client->resource,
tablet->wlr_tool->paths.items[i]); tablet->wlr_tablet->paths.items[i]);
} }
zwp_tablet_v2_send_done(client->resource); zwp_tablet_v2_send_done(client->resource);

@ -192,7 +192,7 @@ static void handle_wlr_tablet_tool_destroy(struct wl_listener *listener, void *d
struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create( struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create(
struct wlr_tablet_manager_v2 *manager, struct wlr_tablet_manager_v2 *manager,
struct wlr_seat *wlr_seat, struct wlr_seat *wlr_seat,
struct wlr_tablet_tool_tool *wlr_tool) { struct wlr_tablet_tool *wlr_tool) {
struct wlr_tablet_seat_v2 *seat = get_or_create_tablet_seat(manager, wlr_seat); struct wlr_tablet_seat_v2 *seat = get_or_create_tablet_seat(manager, wlr_seat);
if (!seat) { if (!seat) {
return NULL; return NULL;

@ -551,19 +551,19 @@ static struct wlr_cursor_device *cursor_device_create(
wl_signal_add(&device->touch->events.cancel, &c_device->touch_cancel); wl_signal_add(&device->touch->events.cancel, &c_device->touch_cancel);
c_device->touch_cancel.notify = handle_touch_cancel; c_device->touch_cancel.notify = handle_touch_cancel;
} else if (device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { } else if (device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
wl_signal_add(&device->tablet_tool->events.tip, wl_signal_add(&device->tablet->events.tip,
&c_device->tablet_tool_tip); &c_device->tablet_tool_tip);
c_device->tablet_tool_tip.notify = handle_tablet_tool_tip; c_device->tablet_tool_tip.notify = handle_tablet_tool_tip;
wl_signal_add(&device->tablet_tool->events.proximity, wl_signal_add(&device->tablet->events.proximity,
&c_device->tablet_tool_proximity); &c_device->tablet_tool_proximity);
c_device->tablet_tool_proximity.notify = handle_tablet_tool_proximity; c_device->tablet_tool_proximity.notify = handle_tablet_tool_proximity;
wl_signal_add(&device->tablet_tool->events.axis, wl_signal_add(&device->tablet->events.axis,
&c_device->tablet_tool_axis); &c_device->tablet_tool_axis);
c_device->tablet_tool_axis.notify = handle_tablet_tool_axis; c_device->tablet_tool_axis.notify = handle_tablet_tool_axis;
wl_signal_add(&device->tablet_tool->events.button, wl_signal_add(&device->tablet->events.button,
&c_device->tablet_tool_button); &c_device->tablet_tool_button);
c_device->tablet_tool_button.notify = handle_tablet_tool_button; c_device->tablet_tool_button.notify = handle_tablet_tool_button;
} }

@ -44,7 +44,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
wlr_touch_destroy(dev->touch); wlr_touch_destroy(dev->touch);
break; break;
case WLR_INPUT_DEVICE_TABLET_TOOL: case WLR_INPUT_DEVICE_TABLET_TOOL:
wlr_tablet_tool_destroy(dev->tablet_tool); wlr_tablet_destroy(dev->tablet);
break; break;
case WLR_INPUT_DEVICE_TABLET_PAD: case WLR_INPUT_DEVICE_TABLET_PAD:
wlr_tablet_pad_destroy(dev->tablet_pad); wlr_tablet_pad_destroy(dev->tablet_pad);

@ -4,26 +4,26 @@
#include <wlr/interfaces/wlr_tablet_tool.h> #include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
void wlr_tablet_tool_init(struct wlr_tablet_tool *tool, void wlr_tablet_init(struct wlr_tablet *tablet,
struct wlr_tablet_tool_impl *impl) { struct wlr_tablet_impl *impl) {
tool->impl = impl; tablet->impl = impl;
wl_signal_init(&tool->events.axis); wl_signal_init(&tablet->events.axis);
wl_signal_init(&tool->events.proximity); wl_signal_init(&tablet->events.proximity);
wl_signal_init(&tool->events.tip); wl_signal_init(&tablet->events.tip);
wl_signal_init(&tool->events.button); wl_signal_init(&tablet->events.button);
} }
void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool) { void wlr_tablet_destroy(struct wlr_tablet *tablet) {
if (!tool) { if (!tablet) {
return; return;
} }
wlr_list_for_each(&tool->paths, free); wlr_list_for_each(&tablet->paths, free);
wlr_list_finish(&tool->paths); wlr_list_finish(&tablet->paths);
if (tool->impl && tool->impl->destroy) { if (tablet->impl && tablet->impl->destroy) {
tool->impl->destroy(tool); tablet->impl->destroy(tablet);
} else { } else {
free(tool); free(tablet);
} }
} }

Loading…
Cancel
Save