aboutsummaryrefslogtreecommitdiff
path: root/rootston/seat.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-01-21 15:09:33 -0500
committerTony Crisci <tony@dubstepdish.com>2018-01-21 15:09:33 -0500
commit7474f005917fbb98cad08e8078c1da0c27742174 (patch)
tree276559dbe3c24ecc6626258132666ae736427a36 /rootston/seat.c
parent61bd79200cc3892b143b7321886db77e97c9f69f (diff)
parent79f2c8719364529056229b99bf9e49a994699fe7 (diff)
Merge branch 'master' into decorations
Diffstat (limited to 'rootston/seat.c')
-rw-r--r--rootston/seat.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/rootston/seat.c b/rootston/seat.c
index 06c0caa6..41ae6c9f 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -293,11 +293,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
return NULL;
}
- wlr_seat_set_capabilities(seat->seat,
- WL_SEAT_CAPABILITY_KEYBOARD |
- WL_SEAT_CAPABILITY_POINTER |
- WL_SEAT_CAPABILITY_TOUCH);
-
wl_list_insert(&input->seats, &seat->link);
seat->seat_destroy.notify = roots_seat_handle_seat_destroy;
@@ -306,6 +301,28 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
return seat;
}
+static void seat_update_capabilities(struct roots_seat *seat) {
+ uint32_t caps = 0;
+ if (!wl_list_empty(&seat->keyboards)) {
+ caps |= WL_SEAT_CAPABILITY_KEYBOARD;
+ }
+ if (!wl_list_empty(&seat->pointers) || !wl_list_empty(&seat->tablet_tools)) {
+ caps |= WL_SEAT_CAPABILITY_POINTER;
+ }
+ if (!wl_list_empty(&seat->touch)) {
+ caps |= WL_SEAT_CAPABILITY_TOUCH;
+ }
+ wlr_seat_set_capabilities(seat->seat, caps);
+
+ // Hide cursor if seat doesn't have pointer capability
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) {
+ wlr_cursor_set_image(seat->cursor->cursor, NULL, 0, 0, 0, 0, 0, 0);
+ } else {
+ wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager,
+ seat->cursor->default_xcursor, seat->cursor->cursor);
+ }
+}
+
static void seat_add_keyboard(struct roots_seat *seat,
struct wlr_input_device *device) {
assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
@@ -404,6 +421,8 @@ void roots_seat_add_device(struct roots_seat *seat,
seat_add_tablet_tool(seat, device);
break;
}
+
+ seat_update_capabilities(seat);
}
static void seat_remove_keyboard(struct roots_seat *seat,
@@ -480,6 +499,8 @@ void roots_seat_remove_device(struct roots_seat *seat,
seat_remove_tablet_tool(seat, device);
break;
}
+
+ seat_update_capabilities(seat);
}
void roots_seat_configure_xcursor(struct roots_seat *seat) {
@@ -655,7 +676,16 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
seat->has_focus = true;
wl_list_remove(&seat_view->link);
wl_list_insert(&seat->views, &seat_view->link);
- wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface);
+
+ struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat);
+ if (keyboard != NULL) {
+ wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface,
+ keyboard->keycodes, keyboard->num_keycodes,
+ &keyboard->modifiers);
+ } else {
+ wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface,
+ NULL, 0, NULL);
+ }
}
void roots_seat_cycle_focus(struct roots_seat *seat) {