aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-03-21 17:37:17 -0600
committerKirill Primak <vyivel@eclair.cafe>2022-03-23 13:08:41 +0000
commit4519117a6885736b26f2d8ff1af97886d184c155 (patch)
treebed18c61f44f77412585c5be6410a21fc6c7acd3
parent4cc2a03620b55113622379772c0b8890010fe7fa (diff)
seat: take wlr_keyboard in wlr_seat_set_keyboard()
Signed-off-by: Leonardo Hernández Hernández <leohdz172@protonmail.com>
-rw-r--r--include/wlr/types/wlr_seat.h2
-rw-r--r--tinywl/tinywl.c16
-rw-r--r--types/seat/wlr_seat_keyboard.c10
3 files changed, 13 insertions, 15 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 41f3918b..ebbcfd47 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -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.
diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c
index da965c4c..290dd094 100644
--- a/tinywl/tinywl.c
+++ b/tinywl/tinywl.c
@@ -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);
diff --git a/types/seat/wlr_seat_keyboard.c b/types/seat/wlr_seat_keyboard.c
index 1bad8ff6..e1f13783 100644
--- a/types/seat/wlr_seat_keyboard.c
+++ b/types/seat/wlr_seat_keyboard.c
@@ -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;