aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-08-12 08:21:18 -0400
committerGitHub <noreply@github.com>2017-08-12 08:21:18 -0400
commit53a53f55b4f2212fbe81e77beca85f45400e12de (patch)
tree3d54d0664fe73de8145ee57af890a818ec5b7e5b /backend/libinput
parent65a899924221c3104800a8676852b34b0cd7223d (diff)
parent3ea878b76e7cf63caf9cddaaabe2faca053d9085 (diff)
Merge pull request #74 from martinetd/more_leaks
More leaks
Diffstat (limited to 'backend/libinput')
-rw-r--r--backend/libinput/backend.c5
-rw-r--r--backend/libinput/events.c17
2 files changed, 19 insertions, 3 deletions
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c
index 19fe8fe7..42c1eac9 100644
--- a/backend/libinput/backend.c
+++ b/backend/libinput/backend.c
@@ -33,6 +33,7 @@ static int wlr_libinput_readable(int fd, uint32_t mask, void *_state) {
struct libinput_event *event;
while ((event = libinput_get_event(state->libinput))) {
wlr_libinput_event(state, event);
+ libinput_event_destroy(event);
}
return 0;
}
@@ -84,7 +85,9 @@ static void wlr_libinput_backend_destroy(struct wlr_backend_state *state) {
for (size_t i = 0; i < state->devices->length; i++) {
list_t *wlr_devices = state->devices->items[i];
for (size_t j = 0; j < wlr_devices->length; j++) {
- wlr_input_device_destroy(wlr_devices->items[j]);
+ struct wlr_input_device *wlr_device = wlr_devices->items[j];
+ wl_signal_emit(&state->backend->events.input_remove, wlr_device);
+ wlr_input_device_destroy(wlr_device);
}
list_free(wlr_devices);
}
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index 0cdf26ec..9afdab21 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -111,8 +111,21 @@ static void handle_device_added(struct wlr_backend_state *state,
static void handle_device_removed(struct wlr_backend_state *state,
struct libinput_device *device) {
- wlr_log(L_DEBUG, "libinput device removed");
- // TODO
+ list_t *devices = libinput_device_get_user_data(device);
+ for (size_t i = 0; i < devices->length; i++) {
+ struct wlr_input_device *wlr_device = devices->items[i];
+ wlr_log(L_DEBUG, "Removing %s [%d:%d]", wlr_device->name,
+ wlr_device->vendor, wlr_device->product);
+ wl_signal_emit(&state->backend->events.input_remove, wlr_device);
+ wlr_input_device_destroy(wlr_device);
+ }
+ for (size_t i = 0; i < state->devices->length; i++) {
+ if (state->devices->items[i] == devices) {
+ list_del(state->devices, i);
+ break;
+ }
+ }
+ list_free(devices);
}
void wlr_libinput_event(struct wlr_backend_state *state,