aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2017-08-14 15:59:59 +0200
committerDominique Martinet <asmadeus@codewreck.org>2017-08-14 16:22:31 +0200
commita289940bff8bcda5cc6aeb1d88f4f1e5c2c38317 (patch)
treed9b9c318b7140a191a5d27f0dbeb1db2deb08cfd
parent53e7bebd2381318b9edcbc8d305d4ec2bed9b3ce (diff)
Refactor out wlr_tablet_pad_state
-rw-r--r--backend/libinput/tablet_pad.c8
-rw-r--r--include/wlr/interfaces/wlr_tablet_pad.h6
-rw-r--r--include/wlr/types/wlr_tablet_pad.h2
-rw-r--r--types/wlr_tablet_pad.c14
4 files changed, 16 insertions, 14 deletions
diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c
index 9713bb1d..efad1068 100644
--- a/backend/libinput/tablet_pad.c
+++ b/backend/libinput/tablet_pad.c
@@ -10,7 +10,13 @@
struct wlr_tablet_pad *wlr_libinput_tablet_pad_create(
struct libinput_device *libinput_dev) {
assert(libinput_dev);
- return wlr_tablet_pad_create(NULL, NULL);
+ struct wlr_tablet_pad *wlr_tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
+ if (!wlr_tablet_pad) {
+ wlr_log(L_ERROR, "Unable to allocate wlr_tablet_pad");
+ return NULL;
+ }
+ wlr_tablet_pad_init(wlr_tablet_pad, NULL);
+ return wlr_tablet_pad;
}
void handle_tablet_pad_button(struct libinput_event *event,
diff --git a/include/wlr/interfaces/wlr_tablet_pad.h b/include/wlr/interfaces/wlr_tablet_pad.h
index 09274c6c..81af3c3f 100644
--- a/include/wlr/interfaces/wlr_tablet_pad.h
+++ b/include/wlr/interfaces/wlr_tablet_pad.h
@@ -3,11 +3,11 @@
#include <wlr/types/wlr_tablet_pad.h>
struct wlr_tablet_pad_impl {
- void (*destroy)(struct wlr_tablet_pad_state *pad);
+ void (*destroy)(struct wlr_tablet_pad *pad);
};
-struct wlr_tablet_pad *wlr_tablet_pad_create(struct wlr_tablet_pad_impl *impl,
- struct wlr_tablet_pad_state *state);
+void wlr_tablet_pad_init(struct wlr_tablet_pad *pad,
+ struct wlr_tablet_pad_impl *impl);
void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad);
#endif
diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h
index d2365086..6c14c669 100644
--- a/include/wlr/types/wlr_tablet_pad.h
+++ b/include/wlr/types/wlr_tablet_pad.h
@@ -11,11 +11,9 @@
*/
struct wlr_tablet_pad_impl;
-struct wlr_tablet_pad_state;
struct wlr_tablet_pad {
struct wlr_tablet_pad_impl *impl;
- struct wlr_tablet_pad_state *state;
struct {
struct wl_signal button;
diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c
index 80c6187d..b7f03493 100644
--- a/types/wlr_tablet_pad.c
+++ b/types/wlr_tablet_pad.c
@@ -4,21 +4,19 @@
#include <wlr/types/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
-struct wlr_tablet_pad *wlr_tablet_pad_create(struct wlr_tablet_pad_impl *impl,
- struct wlr_tablet_pad_state *state) {
- struct wlr_tablet_pad *pad = calloc(1, sizeof(struct wlr_tablet_pad));
+void wlr_tablet_pad_init(struct wlr_tablet_pad *pad,
+ struct wlr_tablet_pad_impl *impl) {
pad->impl = impl;
- pad->state = state;
wl_signal_init(&pad->events.button);
wl_signal_init(&pad->events.ring);
wl_signal_init(&pad->events.strip);
- return pad;
}
void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) {
if (!pad) return;
- if (pad->impl) {
- pad->impl->destroy(pad->state);
+ if (pad->impl && pad->impl->destroy) {
+ pad->impl->destroy(pad);
+ } else {
+ free(pad);
}
- free(pad);
}