aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/rootston/keyboard.h5
-rw-r--r--rootston/keyboard.c3
-rw-r--r--rootston/seat.c42
3 files changed, 38 insertions, 12 deletions
diff --git a/include/rootston/keyboard.h b/include/rootston/keyboard.h
index e3caf8fb..4dd70a65 100644
--- a/include/rootston/keyboard.h
+++ b/include/rootston/keyboard.h
@@ -11,8 +11,6 @@ struct roots_keyboard {
struct roots_seat *seat;
struct wlr_input_device *device;
struct keyboard_config *config;
- struct wl_list seat_link;
- // XXX temporary
struct wl_list link;
struct wl_listener keyboard_key;
@@ -24,8 +22,7 @@ struct roots_keyboard {
struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device,
struct roots_input *input);
-void roots_keyboard_destroy(struct wlr_input_device *device,
- struct roots_input *input);
+void roots_keyboard_destroy(struct roots_keyboard *keyboard);
void roots_keyboard_handle_key(struct roots_keyboard *keyboard,
struct wlr_event_keyboard_key *event);
diff --git a/rootston/keyboard.c b/rootston/keyboard.c
index ef5eb8ab..a770f00f 100644
--- a/rootston/keyboard.c
+++ b/rootston/keyboard.c
@@ -225,8 +225,7 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device,
return keyboard;
}
-void roots_keyboard_destroy(struct wlr_input_device *device, struct roots_input *input) {
- struct roots_keyboard *keyboard = device->data;
+void roots_keyboard_destroy(struct roots_keyboard *keyboard) {
wl_list_remove(&keyboard->link);
free(keyboard->config);
free(keyboard);
diff --git a/rootston/seat.c b/rootston/seat.c
index 7fcffc29..e860c093 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -271,7 +271,7 @@ static void seat_add_keyboard(struct roots_seat *seat, struct wlr_input_device *
struct roots_keyboard *keyboard = roots_keyboard_create(device, seat->input);
keyboard->seat = seat;
- wl_list_insert(&seat->keyboards, &keyboard->seat_link);
+ wl_list_insert(&seat->keyboards, &keyboard->link);
keyboard->keyboard_key.notify = handle_keyboard_key;
wl_signal_add(&keyboard->device->keyboard->events.key,
@@ -354,17 +354,39 @@ void roots_seat_add_device(struct roots_seat *seat,
static void seat_remove_keyboard(struct roots_seat *seat,
struct wlr_input_device *device) {
- // TODO
+ struct roots_keyboard *keyboard;
+ wl_list_for_each(keyboard, &seat->keyboards, link) {
+ if (keyboard->device == device) {
+ roots_keyboard_destroy(keyboard);
+ return;
+ }
+ }
}
static void seat_remove_pointer(struct roots_seat *seat,
struct wlr_input_device *device) {
- // TODO
+ struct roots_pointer *pointer;
+ wl_list_for_each(pointer, &seat->pointers, link) {
+ if (pointer->device == device) {
+ wl_list_remove(&pointer->link);
+ wlr_cursor_detach_input_device(seat->cursor->cursor, device);
+ free(pointer);
+ return;
+ }
+ }
}
static void seat_remove_touch(struct roots_seat *seat,
struct wlr_input_device *device) {
- // TODO
+ struct roots_touch *touch;
+ wl_list_for_each(touch, &seat->touch, link) {
+ if (touch->device == device) {
+ wl_list_remove(&touch->link);
+ wlr_cursor_detach_input_device(seat->cursor->cursor, device);
+ free(touch);
+ return;
+ }
+ }
}
static void seat_remove_tablet_pad(struct roots_seat *seat,
@@ -374,7 +396,15 @@ static void seat_remove_tablet_pad(struct roots_seat *seat,
static void seat_remove_tablet_tool(struct roots_seat *seat,
struct wlr_input_device *device) {
- // TODO
+ struct roots_tablet_tool *tablet_tool;
+ wl_list_for_each(tablet_tool, &seat->tablet_tools, link) {
+ if (tablet_tool->device == device) {
+ wl_list_remove(&tablet_tool->link);
+ wlr_cursor_detach_input_device(seat->cursor->cursor, device);
+ free(tablet_tool);
+ return;
+ }
+ }
}
void roots_seat_remove_device(struct roots_seat *seat,
@@ -410,7 +440,7 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) {
bool roots_seat_has_meta_pressed(struct roots_seat *seat) {
struct roots_keyboard *keyboard;
- wl_list_for_each(keyboard, &seat->keyboards, seat_link) {
+ wl_list_for_each(keyboard, &seat->keyboards, link) {
if (!keyboard->config->meta_key) {
continue;
}