aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-07-23 18:13:42 -0400
committerDevin J. Pohly <djpohly@gmail.com>2020-07-23 18:13:42 -0400
commitd42d8bda42d2cd4a8da986a895b27d13b6960c1a (patch)
treeb016274d936960cfe4a061485c4325a815a578eb
parent89e9a4be33c5cf6c56435c4617563fe740074d39 (diff)
add cleanup listener for keyboards
-rw-r--r--dwl.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 07f74a8..41beaf1 100644
--- a/dwl.c
+++ b/dwl.c
@@ -99,6 +99,7 @@ typedef struct {
struct wl_listener modifiers;
struct wl_listener key;
+ struct wl_listener destroy;
} Keyboard;
typedef struct {
@@ -153,6 +154,7 @@ static void arrange(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
+static void cleanupkeyboard(struct wl_listener *listener, void *data);
static void cleanupmon(struct wl_listener *listener, void *data);
static void createkeyboard(struct wlr_input_device *device);
static void createmon(struct wl_listener *listener, void *data);
@@ -396,6 +398,16 @@ chvt(const Arg *arg)
}
void
+cleanupkeyboard(struct wl_listener *listener, void *data)
+{
+ struct wlr_input_device *device = data;
+ Keyboard *kb = device->data;
+
+ wl_list_remove(&kb->destroy.link);
+ free(kb);
+}
+
+void
cleanupmon(struct wl_listener *listener, void *data)
{
struct wlr_output *wlr_output = data;
@@ -430,6 +442,8 @@ createkeyboard(struct wlr_input_device *device)
wl_signal_add(&device->keyboard->events.modifiers, &kb->modifiers);
kb->key.notify = keypress;
wl_signal_add(&device->keyboard->events.key, &kb->key);
+ kb->destroy.notify = cleanupkeyboard;
+ wl_signal_add(&device->events.destroy, &kb->destroy);
wlr_seat_set_keyboard(seat, device);