Clean up wayland backend tablet support

Mostly address feedback from emersion on PR #1694
Remove const qualifier from char *name, to allow free() call
This commit is contained in:
Markus Ongyerth 2019-07-14 06:48:22 +02:00 committed by Simon Ser
parent 2285e36b0c
commit ebeef0fbe8
4 changed files with 16 additions and 22 deletions

View File

@ -21,10 +21,6 @@
#include "xdg-shell-client-protocol.h" #include "xdg-shell-client-protocol.h"
#include "tablet-unstable-v2-client-protocol.h" #include "tablet-unstable-v2-client-protocol.h"
struct wlr_wl_tablet_seat *wlr_wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend);
struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend) { struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend) {
assert(wlr_backend_is_wl(backend)); assert(wlr_backend_is_wl(backend));
return (struct wlr_wl_backend *)backend; return (struct wlr_wl_backend *)backend;
@ -118,7 +114,7 @@ static bool backend_start(struct wlr_backend *backend) {
} }
if (wl->tablet_manager && wl->seat) { if (wl->tablet_manager && wl->seat) {
wlr_wl_add_tablet_seat(wl->tablet_manager, wl_add_tablet_seat(wl->tablet_manager,
wl->seat, wl); wl->seat, wl);
} }

View File

@ -16,13 +16,10 @@
#include "wlr/util/log.h" #include "wlr/util/log.h"
#include "tablet-unstable-v2-client-protocol.h" #include "tablet-unstable-v2-client-protocol.h"
#include <backend/wayland.h> #include "backend/wayland.h"
struct wlr_wl_tablet_seat { struct wlr_wl_tablet_seat {
struct zwp_tablet_seat_v2 *tablet_seat; struct zwp_tablet_seat_v2 *tablet_seat;
struct wl_list tablets;
struct wl_list tools;
// struct wl_list pads; // wlr_wl_tablet_pad::link
}; };
struct wlr_wl_tablet_tool { struct wlr_wl_tablet_tool {
@ -92,10 +89,6 @@ static uint32_t get_current_time_msec(void) {
return now.tv_nsec / (1000 * 1000) + now.tv_sec * 1000; return now.tv_nsec / (1000 * 1000) + now.tv_sec * 1000;
} }
struct wlr_wl_tablet_seat *wlr_wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend);
static void handle_tablet_pad_ring_source(void *data, static void handle_tablet_pad_ring_source(void *data,
struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2,
uint32_t source) { uint32_t source) {
@ -207,6 +200,7 @@ static void handle_tablet_pad_group_buttons(void *data,
struct wl_array *buttons) { struct wl_array *buttons) {
struct wlr_wl_tablet_pad_group *group = data; struct wlr_wl_tablet_pad_group *group = data;
free(group->group.buttons);
group->group.buttons = calloc(1, buttons->size); group->group.buttons = calloc(1, buttons->size);
if (!group->group.buttons) { if (!group->group.buttons) {
// FIXME: Add actual error handling // FIXME: Add actual error handling
@ -470,6 +464,7 @@ static void handle_tablet_tool_done(void *data,
struct zwp_tablet_tool_v2 *id) { struct zwp_tablet_tool_v2 *id) {
/* empty */ /* empty */
} }
static enum wlr_tablet_tool_type tablet_type_to_wlr_type(enum zwp_tablet_tool_v2_type type) { static enum wlr_tablet_tool_type tablet_type_to_wlr_type(enum zwp_tablet_tool_v2_type type) {
switch (type) { switch (type) {
@ -841,6 +836,8 @@ static void handle_tablet_name(void *data, struct zwp_tablet_v2 *zwp_tablet_v2,
const char *name) { const char *name) {
struct wlr_wl_input_device *dev = data; struct wlr_wl_input_device *dev = data;
struct wlr_tablet *tablet = dev->wlr_input_device.tablet; struct wlr_tablet *tablet = dev->wlr_input_device.tablet;
free(tablet->name);
tablet->name = strdup(name); tablet->name = strdup(name);
} }
@ -894,12 +891,13 @@ static void handle_tab_added(void *data,
struct wlr_wl_backend *backend = data; struct wlr_wl_backend *backend = data;
struct wlr_wl_input_device *dev = create_wl_input_device( struct wlr_wl_input_device *dev = create_wl_input_device(
backend, WLR_INPUT_DEVICE_TABLET_TOOL); backend, WLR_INPUT_DEVICE_TABLET_TOOL);
dev->resource = id;
if (!dev) { if (!dev) {
zwp_tablet_v2_destroy(id); zwp_tablet_v2_destroy(id);
return; return;
} }
dev->resource = id;
struct wlr_input_device *wlr_dev = &dev->wlr_input_device; struct wlr_input_device *wlr_dev = &dev->wlr_input_device;
wlr_dev->tablet = calloc(1, sizeof(*wlr_dev->tablet)); wlr_dev->tablet = calloc(1, sizeof(*wlr_dev->tablet));
@ -918,7 +916,7 @@ static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
.pad_added = handle_pad_added, .pad_added = handle_pad_added,
}; };
struct wlr_wl_tablet_seat *wlr_wl_add_tablet_seat( struct wlr_wl_tablet_seat *wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager, struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend) { struct wl_seat *seat, struct wlr_wl_backend *backend) {
struct wlr_wl_tablet_seat *ret = struct wlr_wl_tablet_seat *ret =
@ -933,9 +931,5 @@ struct wlr_wl_tablet_seat *wlr_wl_add_tablet_seat(
zwp_tablet_seat_v2_add_listener(ret->tablet_seat, zwp_tablet_seat_v2_add_listener(ret->tablet_seat,
&tablet_seat_listener, backend); &tablet_seat_listener, backend);
wl_list_init(&ret->tablets);
wl_list_init(&ret->tools);
//wl_list_init(&ret->pads);
return ret; return ret;
} }

View File

@ -98,4 +98,8 @@ struct wlr_wl_input_device *create_wl_input_device(
extern const struct wl_seat_listener seat_listener; extern const struct wl_seat_listener seat_listener;
struct wlr_wl_tablet_seat *wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend);
#endif #endif

View File

@ -70,7 +70,7 @@ struct wlr_tablet {
struct wl_signal button; struct wl_signal button;
} events; } events;
const char *name; char *name;
struct wlr_list paths; // char * struct wlr_list paths; // char *
void *data; void *data;