add cleanup listener for keyboards
This commit is contained in:
parent
89e9a4be33
commit
d42d8bda42
14
dwl.c
14
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);
|
||||
@ -395,6 +397,16 @@ chvt(const Arg *arg)
|
||||
wlr_session_change_vt(s, arg->ui);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user