seat: take wlr_keyboard in wlr_seat_set_keyboard()

Signed-off-by: Leonardo Hernández Hernández <leohdz172@protonmail.com>
master
Leonardo Hernández Hernández 3 years ago committed by Kirill Primak
parent 4cc2a03620
commit 4519117a68

@ -474,7 +474,7 @@ bool wlr_seat_pointer_has_grab(struct wlr_seat *seat);
/**
* Set this keyboard as the active keyboard for the seat.
*/
void wlr_seat_set_keyboard(struct wlr_seat *seat, struct wlr_input_device *dev);
void wlr_seat_set_keyboard(struct wlr_seat *seat, struct wlr_keyboard *keyboard);
/**
* Get the active keyboard for the seat.

@ -91,7 +91,7 @@ struct tinywl_view {
struct tinywl_keyboard {
struct wl_list link;
struct tinywl_server *server;
struct wlr_input_device *device;
struct wlr_keyboard *wlr_keyboard;
struct wl_listener modifiers;
struct wl_listener key;
@ -149,10 +149,10 @@ static void keyboard_handle_modifiers(
* same seat. You can swap out the underlying wlr_keyboard like this and
* wlr_seat handles this transparently.
*/
wlr_seat_set_keyboard(keyboard->server->seat, keyboard->device);
wlr_seat_set_keyboard(keyboard->server->seat, keyboard->wlr_keyboard);
/* Send modifiers to the client. */
wlr_seat_keyboard_notify_modifiers(keyboard->server->seat,
&keyboard->device->keyboard->modifiers);
&keyboard->wlr_keyboard->modifiers);
}
static bool handle_keybinding(struct tinywl_server *server, xkb_keysym_t sym) {
@ -196,10 +196,10 @@ static void keyboard_handle_key(
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
int nsyms = xkb_state_key_get_syms(
keyboard->device->keyboard->xkb_state, keycode, &syms);
keyboard->wlr_keyboard->xkb_state, keycode, &syms);
bool handled = false;
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard);
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->wlr_keyboard);
if ((modifiers & WLR_MODIFIER_ALT) &&
event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
/* If alt is held down and this button was _pressed_, we attempt to
@ -211,7 +211,7 @@ static void keyboard_handle_key(
if (!handled) {
/* Otherwise, we pass it along to the client. */
wlr_seat_set_keyboard(seat, keyboard->device);
wlr_seat_set_keyboard(seat, keyboard->wlr_keyboard);
wlr_seat_keyboard_notify_key(seat, event->time_msec,
event->keycode, event->state);
}
@ -236,7 +236,7 @@ static void server_new_keyboard(struct tinywl_server *server,
struct tinywl_keyboard *keyboard =
calloc(1, sizeof(struct tinywl_keyboard));
keyboard->server = server;
keyboard->device = device;
keyboard->wlr_keyboard = device->keyboard;
/* We need to prepare an XKB keymap and assign it to the keyboard. This
* assumes the defaults (e.g. layout = "us"). */
@ -257,7 +257,7 @@ static void server_new_keyboard(struct tinywl_server *server,
keyboard->destroy.notify = keyboard_handle_destroy;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
wlr_seat_set_keyboard(server->seat, device);
wlr_seat_set_keyboard(server->seat, keyboard->wlr_keyboard);
/* And add the keyboard to our list of keyboards */
wl_list_insert(&server->keyboards, &keyboard->link);

@ -118,11 +118,10 @@ static void handle_keyboard_destroy(struct wl_listener *listener, void *data) {
}
void wlr_seat_set_keyboard(struct wlr_seat *seat,
struct wlr_input_device *device) {
struct wlr_keyboard *keyboard) {
// TODO call this on device key event before the event reaches the
// compositor and set a pending keyboard and then send the new keyboard
// state on the next keyboard notify event.
struct wlr_keyboard *keyboard = (device ? device->keyboard : NULL);
if (seat->keyboard_state.keyboard == keyboard) {
return;
}
@ -135,16 +134,15 @@ void wlr_seat_set_keyboard(struct wlr_seat *seat,
}
if (keyboard) {
assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
seat->keyboard_state.keyboard = keyboard;
wl_signal_add(&device->events.destroy,
wl_signal_add(&keyboard->base.events.destroy,
&seat->keyboard_state.keyboard_destroy);
seat->keyboard_state.keyboard_destroy.notify = handle_keyboard_destroy;
wl_signal_add(&device->keyboard->events.keymap,
wl_signal_add(&keyboard->events.keymap,
&seat->keyboard_state.keyboard_keymap);
seat->keyboard_state.keyboard_keymap.notify = handle_keyboard_keymap;
wl_signal_add(&device->keyboard->events.repeat_info,
wl_signal_add(&keyboard->events.repeat_info,
&seat->keyboard_state.keyboard_repeat_info);
seat->keyboard_state.keyboard_repeat_info.notify =
handle_keyboard_repeat_info;

Loading…
Cancel
Save