aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2017-08-14 15:41:14 +0200
committerDominique Martinet <asmadeus@codewreck.org>2017-08-14 16:22:31 +0200
commit0a3246ad979d768933a68b81e738853bd7c964a2 (patch)
tree677e8efcafcf7bdea38bd205898f8e4c2e01b23c /backend/libinput
parente6ad67911bffcd804549bd1812a77a305cc14eb4 (diff)
Refactor out wlr_keyboard_state
Diffstat (limited to 'backend/libinput')
-rw-r--r--backend/libinput/keyboard.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/backend/libinput/keyboard.c b/backend/libinput/keyboard.c
index b231828d..db4ac0ed 100644
--- a/backend/libinput/keyboard.c
+++ b/backend/libinput/keyboard.c
@@ -7,17 +7,21 @@
#include <wlr/util/log.h>
#include "backend/libinput.h"
-struct wlr_keyboard_state {
+struct wlr_libinput_keyboard {
+ struct wlr_keyboard wlr_keyboard;
struct libinput_device *libinput_dev;
};
-static void wlr_libinput_keyboard_set_leds(struct wlr_keyboard_state *kbstate, uint32_t leds) {
- libinput_device_led_update(kbstate->libinput_dev, leds);
+static void wlr_libinput_keyboard_set_leds(struct wlr_keyboard *wlr_kb, uint32_t leds) {
+ struct wlr_libinput_keyboard *wlr_libinput_kb = (struct wlr_libinput_keyboard *)wlr_kb;
+ libinput_device_led_update(wlr_libinput_kb->libinput_dev, leds);
}
-static void wlr_libinput_keyboard_destroy(struct wlr_keyboard_state *kbstate) {
- libinput_device_unref(kbstate->libinput_dev);
- free(kbstate);
+static void wlr_libinput_keyboard_destroy(struct wlr_keyboard *wlr_kb) {
+ struct wlr_libinput_keyboard *wlr_libinput_kb =
+ (struct wlr_libinput_keyboard *)wlr_kb;
+ libinput_device_unref(wlr_libinput_kb->libinput_dev);
+ free(wlr_libinput_kb);
}
struct wlr_keyboard_impl impl = {
@@ -28,11 +32,14 @@ struct wlr_keyboard_impl impl = {
struct wlr_keyboard *wlr_libinput_keyboard_create(
struct libinput_device *libinput_dev) {
assert(libinput_dev);
- struct wlr_keyboard_state *kbstate = calloc(1, sizeof(struct wlr_keyboard_state));
- kbstate->libinput_dev = libinput_dev;
+ struct wlr_libinput_keyboard *wlr_libinput_kb =
+ calloc(1, sizeof(struct wlr_libinput_keyboard));
+ wlr_libinput_kb->libinput_dev = libinput_dev;
libinput_device_ref(libinput_dev);
libinput_device_led_update(libinput_dev, 0);
- return wlr_keyboard_create(&impl, kbstate);
+ struct wlr_keyboard *wlr_kb = &wlr_libinput_kb->wlr_keyboard;
+ wlr_keyboard_init(wlr_kb, &impl);
+ return wlr_kb;
}
void handle_keyboard_key(struct libinput_event *event,