diff options
-rw-r--r-- | include/wlr/types/wlr_seat.h | 13 | ||||
-rw-r--r-- | rootston/seat.c | 11 | ||||
-rw-r--r-- | types/wlr_data_device.c | 3 | ||||
-rw-r--r-- | types/wlr_seat.c | 45 | ||||
-rw-r--r-- | types/wlr_xdg_shell_v6.c | 4 |
5 files changed, 47 insertions, 29 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index f5b4afde..c2a89f33 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -68,7 +68,8 @@ struct wlr_seat_keyboard_grab; struct wlr_keyboard_grab_interface { void (*enter)(struct wlr_seat_keyboard_grab *grab, - struct wlr_surface *surface); + struct wlr_surface *surface, uint32_t keycodes[], + size_t num_keycodes, struct wlr_keyboard_modifiers *modifiers); void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time, uint32_t key, uint32_t state); void (*modifiers)(struct wlr_seat_keyboard_grab *grab, @@ -396,8 +397,9 @@ void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat, * focused surface for this keyboard. Defers to any current grab of the seat's * keyboard. */ -void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat, - struct wlr_surface *surface); +void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers); /** * Send a keyboard enter event to the given surface and consider it to be the @@ -406,8 +408,9 @@ void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat, * `wlr_seat_keyboard_notify_enter()` to change keyboard focus to respect * keyboard grabs. */ -void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, - struct wlr_surface *surface); +void wlr_seat_keyboard_enter(struct wlr_seat *seat, + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers); /** * Clear the focused surface for the keyboard and leave all entered surfaces. diff --git a/rootston/seat.c b/rootston/seat.c index 2728ca96..0972fce2 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -616,7 +616,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) { diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index 3c48119a..5a6bc198 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -585,7 +585,8 @@ const struct wlr_touch_grab_interface wlr_data_device_touch_drag_interface = { }; static void keyboard_drag_enter(struct wlr_seat_keyboard_grab *grab, - struct wlr_surface *surface) { + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers) { // nothing has keyboard focus during drags } diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 6ed92493..4378675c 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -282,8 +282,9 @@ static const struct wlr_pointer_grab_interface default_pointer_grab_impl = { }; static void default_keyboard_enter(struct wlr_seat_keyboard_grab *grab, - struct wlr_surface *surface) { - wlr_seat_keyboard_enter(grab->seat, surface); + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers) { + wlr_seat_keyboard_enter(grab->seat, surface, keycodes, num_keycodes, modifiers); } static void default_keyboard_key(struct wlr_seat_keyboard_grab *grab, @@ -851,14 +852,19 @@ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat, uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &client->keyboards) { - wl_keyboard_send_modifiers(resource, serial, - modifiers->depressed, modifiers->latched, - modifiers->locked, modifiers->group); + if (modifiers == NULL) { + wl_keyboard_send_modifiers(resource, serial, 0, 0, 0, 0); + } else { + wl_keyboard_send_modifiers(resource, serial, + modifiers->depressed, modifiers->latched, + modifiers->locked, modifiers->group); + } } } void wlr_seat_keyboard_enter(struct wlr_seat *seat, - struct wlr_surface *surface) { + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers) { if (seat->keyboard_state.focused_surface == surface) { // this surface already got an enter notify return; @@ -886,19 +892,17 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat, } // enter the current surface - if (client != NULL && seat->keyboard_state.keyboard != NULL) { - struct wlr_keyboard *keyboard = seat->keyboard_state.keyboard; - + if (client != NULL) { struct wl_array keys; wl_array_init(&keys); - for (size_t i = 0; i < keyboard->num_keycodes; ++i) { + for (size_t i = 0; i < num_keycodes; ++i) { uint32_t *p = wl_array_add(&keys, sizeof(uint32_t)); if (!p) { wlr_log(L_ERROR, "Cannot allocate memory, skipping keycode: %d\n", - keyboard->keycodes[i]); + keycodes[i]); continue; } - *p = keyboard->keycodes[i]; + *p = keycodes[i]; } uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; @@ -930,24 +934,23 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat, seat->keyboard_state.focused_client = client; seat->keyboard_state.focused_surface = surface; - if (client != NULL && seat->keyboard_state.keyboard != NULL) { + if (client != NULL) { // tell new client about any modifier change last, // as it targets seat->keyboard_state.focused_client - wlr_seat_keyboard_send_modifiers(seat, - seat->keyboard_state.keyboard->modifiers); + wlr_seat_keyboard_send_modifiers(seat, modifiers); } } -void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, struct - wlr_surface *surface) { +void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers) { struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab; - grab->interface->enter(grab, surface); + grab->interface->enter(grab, surface, keycodes, num_keycodes, modifiers); } void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) { - struct wl_array keys; - wl_array_init(&keys); - wlr_seat_keyboard_enter(seat, NULL); + // TODO respect grabs here? + wlr_seat_keyboard_enter(seat, NULL, NULL, 0, NULL); } bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat) { diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index fd09b467..59b152bd 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -103,7 +103,9 @@ static const struct wlr_pointer_grab_interface xdg_pointer_grab_impl = { .axis = xdg_pointer_grab_axis, }; -static void xdg_keyboard_grab_enter(struct wlr_seat_keyboard_grab *grab, struct wlr_surface *surface) { +static void xdg_keyboard_grab_enter(struct wlr_seat_keyboard_grab *grab, + struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, + struct wlr_keyboard_modifiers *modifiers) { // keyboard focus should remain on the popup } |