aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/libinput/tablet_tool.c8
-rw-r--r--include/wlr/interfaces/wlr_tablet_tool.h6
-rw-r--r--include/wlr/types/wlr_tablet_tool.h2
-rw-r--r--types/wlr_tablet_tool.c14
4 files changed, 16 insertions, 14 deletions
diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c
index efe77f0a..8b3d34ed 100644
--- a/backend/libinput/tablet_tool.c
+++ b/backend/libinput/tablet_tool.c
@@ -10,7 +10,13 @@
struct wlr_tablet_tool *wlr_libinput_tablet_tool_create(
struct libinput_device *libinput_dev) {
assert(libinput_dev);
- return wlr_tablet_tool_create(NULL, NULL);
+ struct wlr_tablet_tool *wlr_tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool));
+ if (!wlr_tablet_tool) {
+ wlr_log(L_ERROR, "Unable to allocate wlr_tablet_tool");
+ return NULL;
+ }
+ wlr_tablet_tool_init(wlr_tablet_tool, NULL);
+ return wlr_tablet_tool;
}
void handle_tablet_tool_axis(struct libinput_event *event,
diff --git a/include/wlr/interfaces/wlr_tablet_tool.h b/include/wlr/interfaces/wlr_tablet_tool.h
index cd326878..43a24fd0 100644
--- a/include/wlr/interfaces/wlr_tablet_tool.h
+++ b/include/wlr/interfaces/wlr_tablet_tool.h
@@ -3,11 +3,11 @@
#include <wlr/types/wlr_tablet_tool.h>
struct wlr_tablet_tool_impl {
- void (*destroy)(struct wlr_tablet_tool_state *tool);
+ void (*destroy)(struct wlr_tablet_tool *tool);
};
-struct wlr_tablet_tool *wlr_tablet_tool_create(struct wlr_tablet_tool_impl *impl,
- struct wlr_tablet_tool_state *state);
+void wlr_tablet_tool_init(struct wlr_tablet_tool *tool,
+ struct wlr_tablet_tool_impl *impl);
void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool);
#endif
diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h
index f99cd065..dcb9c191 100644
--- a/include/wlr/types/wlr_tablet_tool.h
+++ b/include/wlr/types/wlr_tablet_tool.h
@@ -5,11 +5,9 @@
#include <stdint.h>
struct wlr_tablet_tool_impl;
-struct wlr_tablet_tool_state;
struct wlr_tablet_tool {
struct wlr_tablet_tool_impl *impl;
- struct wlr_tablet_tool_state *state;
struct {
struct wl_signal axis;
diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c
index 1e939c3b..9f12a5ba 100644
--- a/types/wlr_tablet_tool.c
+++ b/types/wlr_tablet_tool.c
@@ -4,22 +4,20 @@
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
-struct wlr_tablet_tool *wlr_tablet_tool_create(struct wlr_tablet_tool_impl *impl,
- struct wlr_tablet_tool_state *state) {
- struct wlr_tablet_tool *tool = calloc(1, sizeof(struct wlr_tablet_tool));
+void wlr_tablet_tool_init(struct wlr_tablet_tool *tool,
+ struct wlr_tablet_tool_impl *impl) {
tool->impl = impl;
- tool->state = state;
wl_signal_init(&tool->events.axis);
wl_signal_init(&tool->events.proximity);
wl_signal_init(&tool->events.tip);
wl_signal_init(&tool->events.button);
- return tool;
}
void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool) {
if (!tool) return;
- if (tool->impl) {
- tool->impl->destroy(tool->state);
+ if (tool->impl && tool->impl->destroy) {
+ tool->impl->destroy(tool);
+ } else {
+ free(tool);
}
- free(tool);
}