mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-26 11:39:47 +01:00
Refactor out wlr_tablet_pad_state
This commit is contained in:
parent
53e7bebd23
commit
a289940bff
4 changed files with 16 additions and 14 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue