summaryrefslogtreecommitdiff
path: root/sway/input/seat.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 49fe46ba..4817eae7 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -348,17 +348,42 @@ struct sway_seat *seat_create(struct sway_input_manager *input,
seat->input = input;
wl_list_init(&seat->devices);
- wlr_seat_set_capabilities(seat->wlr_seat,
- WL_SEAT_CAPABILITY_KEYBOARD |
- WL_SEAT_CAPABILITY_POINTER |
- WL_SEAT_CAPABILITY_TOUCH);
-
-
wl_list_insert(&input->seats, &seat->link);
return seat;
}
+static void seat_update_capabilities(struct sway_seat *seat) {
+ uint32_t caps = 0;
+ struct sway_seat_device *seat_device;
+ wl_list_for_each(seat_device, &seat->devices, link) {
+ switch (seat_device->input_device->wlr_device->type) {
+ case WLR_INPUT_DEVICE_KEYBOARD:
+ caps |= WL_SEAT_CAPABILITY_KEYBOARD;
+ break;
+ case WLR_INPUT_DEVICE_POINTER:
+ caps |= WL_SEAT_CAPABILITY_POINTER;
+ break;
+ case WLR_INPUT_DEVICE_TOUCH:
+ caps |= WL_SEAT_CAPABILITY_TOUCH;
+ break;
+ case WLR_INPUT_DEVICE_TABLET_TOOL:
+ caps |= WL_SEAT_CAPABILITY_POINTER;
+ break;
+ case WLR_INPUT_DEVICE_TABLET_PAD:
+ break;
+ }
+ }
+ wlr_seat_set_capabilities(seat->wlr_seat, caps);
+
+ // Hide cursor if seat doesn't have pointer capability
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) {
+ cursor_set_image(seat->cursor, NULL, NULL);
+ } else {
+ cursor_set_image(seat->cursor, "left_ptr", NULL);
+ }
+}
+
static void seat_apply_input_config(struct sway_seat *seat,
struct sway_seat_device *sway_device) {
const char *mapped_to_output = NULL;
@@ -489,6 +514,8 @@ void seat_add_device(struct sway_seat *seat,
wl_list_insert(&seat->devices, &seat_device->link);
seat_configure_device(seat, input_device);
+
+ seat_update_capabilities(seat);
}
void seat_remove_device(struct sway_seat *seat,
@@ -503,6 +530,8 @@ void seat_remove_device(struct sway_seat *seat,
input_device->identifier, seat->wlr_seat->name);
seat_device_destroy(seat_device);
+
+ seat_update_capabilities(seat);
}
void seat_configure_xcursor(struct sway_seat *seat) {
@@ -532,8 +561,7 @@ void seat_configure_xcursor(struct sway_seat *seat) {
output->name, (double)output->scale);
}
- wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager,
- "left_ptr", seat->cursor->cursor);
+ cursor_set_image(seat->cursor, "left_ptr", NULL);
wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x,
seat->cursor->cursor->y);
}