mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 11:21:28 +00:00
Remove access to wlr_input_device union
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3626 Closes: https://github.com/swaywm/sway/issues/7077
This commit is contained in:
parent
49cef51e6e
commit
122d8ce954
|
@ -50,6 +50,7 @@ struct sway_shortcut_state {
|
||||||
|
|
||||||
struct sway_keyboard {
|
struct sway_keyboard {
|
||||||
struct sway_seat_device *seat_device;
|
struct sway_seat_device *seat_device;
|
||||||
|
struct wlr_keyboard *wlr;
|
||||||
|
|
||||||
struct xkb_keymap *keymap;
|
struct xkb_keymap *keymap;
|
||||||
xkb_layout_index_t effective_layout;
|
xkb_layout_index_t effective_layout;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
struct sway_switch {
|
struct sway_switch {
|
||||||
struct sway_seat_device *seat_device;
|
struct sway_seat_device *seat_device;
|
||||||
|
struct wlr_switch *wlr;
|
||||||
enum wlr_switch_state state;
|
enum wlr_switch_state state;
|
||||||
enum wlr_switch_type type;
|
enum wlr_switch_type type;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ struct sway_tablet_pad {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct sway_seat_device *seat_device;
|
struct sway_seat_device *seat_device;
|
||||||
struct sway_tablet *tablet;
|
struct sway_tablet *tablet;
|
||||||
|
struct wlr_tablet_pad *wlr;
|
||||||
struct wlr_tablet_v2_tablet_pad *tablet_v2_pad;
|
struct wlr_tablet_v2_tablet_pad *tablet_v2_pad;
|
||||||
|
|
||||||
struct wl_listener attach;
|
struct wl_listener attach;
|
||||||
|
|
|
@ -98,10 +98,9 @@ struct cmd_results *input_cmd_xkb_switch_layout(int argc, char **argv) {
|
||||||
struct xkb_switch_layout_action *action =
|
struct xkb_switch_layout_action *action =
|
||||||
&actions[actions_len++];
|
&actions[actions_len++];
|
||||||
|
|
||||||
action->keyboard = dev->wlr_device->keyboard;
|
action->keyboard = wlr_keyboard_from_input_device(dev->wlr_device);
|
||||||
if (relative) {
|
if (relative) {
|
||||||
action->layout = get_layout_relative(
|
action->layout = get_layout_relative(action->keyboard, relative);
|
||||||
dev->wlr_device->keyboard, relative);
|
|
||||||
} else {
|
} else {
|
||||||
action->layout = layout;
|
action->layout = layout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,7 +595,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
|
||||||
double y1 = region->y1, y2 = region->y2;
|
double y1 = region->y1, y2 = region->y2;
|
||||||
|
|
||||||
if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
|
if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
|
||||||
struct wlr_tablet *tablet = device->tablet;
|
struct wlr_tablet *tablet = wlr_tablet_from_input_device(device);
|
||||||
if (tablet->width_mm == 0 || tablet->height_mm == 0) {
|
if (tablet->width_mm == 0 || tablet->height_mm == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,14 +291,12 @@ static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard,
|
||||||
static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard,
|
static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard,
|
||||||
xkb_keycode_t keycode, const xkb_keysym_t **keysyms,
|
xkb_keycode_t keycode, const xkb_keysym_t **keysyms,
|
||||||
uint32_t *modifiers) {
|
uint32_t *modifiers) {
|
||||||
struct wlr_input_device *device =
|
*modifiers = wlr_keyboard_get_modifiers(keyboard->wlr);
|
||||||
keyboard->seat_device->input_device->wlr_device;
|
|
||||||
*modifiers = wlr_keyboard_get_modifiers(device->keyboard);
|
|
||||||
xkb_mod_mask_t consumed = xkb_state_key_get_consumed_mods2(
|
xkb_mod_mask_t consumed = xkb_state_key_get_consumed_mods2(
|
||||||
device->keyboard->xkb_state, keycode, XKB_CONSUMED_MODE_XKB);
|
keyboard->wlr->xkb_state, keycode, XKB_CONSUMED_MODE_XKB);
|
||||||
*modifiers = *modifiers & ~consumed;
|
*modifiers = *modifiers & ~consumed;
|
||||||
|
|
||||||
return xkb_state_key_get_syms(device->keyboard->xkb_state,
|
return xkb_state_key_get_syms(keyboard->wlr->xkb_state,
|
||||||
keycode, keysyms);
|
keycode, keysyms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,13 +312,11 @@ static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard,
|
||||||
static size_t keyboard_keysyms_raw(struct sway_keyboard *keyboard,
|
static size_t keyboard_keysyms_raw(struct sway_keyboard *keyboard,
|
||||||
xkb_keycode_t keycode, const xkb_keysym_t **keysyms,
|
xkb_keycode_t keycode, const xkb_keysym_t **keysyms,
|
||||||
uint32_t *modifiers) {
|
uint32_t *modifiers) {
|
||||||
struct wlr_input_device *device =
|
*modifiers = wlr_keyboard_get_modifiers(keyboard->wlr);
|
||||||
keyboard->seat_device->input_device->wlr_device;
|
|
||||||
*modifiers = wlr_keyboard_get_modifiers(device->keyboard);
|
|
||||||
|
|
||||||
xkb_layout_index_t layout_index = xkb_state_key_get_layout(
|
xkb_layout_index_t layout_index = xkb_state_key_get_layout(
|
||||||
device->keyboard->xkb_state, keycode);
|
keyboard->wlr->xkb_state, keycode);
|
||||||
return xkb_keymap_key_get_syms_by_level(device->keyboard->keymap,
|
return xkb_keymap_key_get_syms_by_level(keyboard->wlr->keymap,
|
||||||
keycode, layout_index, 0, keysyms);
|
keycode, layout_index, 0, keysyms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,8 +356,7 @@ static void update_keyboard_state(struct sway_keyboard *keyboard,
|
||||||
keyinfo->keycode, &keyinfo->translated_keysyms,
|
keyinfo->keycode, &keyinfo->translated_keysyms,
|
||||||
&keyinfo->translated_modifiers);
|
&keyinfo->translated_modifiers);
|
||||||
|
|
||||||
keyinfo->code_modifiers = wlr_keyboard_get_modifiers(
|
keyinfo->code_modifiers = wlr_keyboard_get_modifiers(keyboard->wlr);
|
||||||
keyboard->seat_device->input_device->wlr_device->keyboard);
|
|
||||||
|
|
||||||
// Update shortcut model keyinfo
|
// Update shortcut model keyinfo
|
||||||
update_shortcut_state(&keyboard->state_keycodes, raw_keycode, keystate,
|
update_shortcut_state(&keyboard->state_keycodes, raw_keycode, keystate,
|
||||||
|
@ -407,7 +402,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
|
||||||
struct wlr_input_device *wlr_device =
|
struct wlr_input_device *wlr_device =
|
||||||
keyboard->seat_device->input_device->wlr_device;
|
keyboard->seat_device->input_device->wlr_device;
|
||||||
char *device_identifier = input_device_get_identifier(wlr_device);
|
char *device_identifier = input_device_get_identifier(wlr_device);
|
||||||
bool exact_identifier = wlr_device->keyboard->group != NULL;
|
bool exact_identifier = keyboard->wlr->group != NULL;
|
||||||
seat_idle_notify_activity(seat, IDLE_SOURCE_KEYBOARD);
|
seat_idle_notify_activity(seat, IDLE_SOURCE_KEYBOARD);
|
||||||
bool input_inhibited = seat->exclusive_client != NULL ||
|
bool input_inhibited = seat->exclusive_client != NULL ||
|
||||||
server.session_lock.locked;
|
server.session_lock.locked;
|
||||||
|
@ -478,10 +473,10 @@ static void handle_key_event(struct sway_keyboard *keyboard,
|
||||||
// Set up (or clear) keyboard repeat for a pressed binding. Since the
|
// Set up (or clear) keyboard repeat for a pressed binding. Since the
|
||||||
// binding may remove the keyboard, the timer needs to be updated first
|
// binding may remove the keyboard, the timer needs to be updated first
|
||||||
if (binding && !(binding->flags & BINDING_NOREPEAT) &&
|
if (binding && !(binding->flags & BINDING_NOREPEAT) &&
|
||||||
wlr_device->keyboard->repeat_info.delay > 0) {
|
keyboard->wlr->repeat_info.delay > 0) {
|
||||||
keyboard->repeat_binding = binding;
|
keyboard->repeat_binding = binding;
|
||||||
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
||||||
wlr_device->keyboard->repeat_info.delay) < 0) {
|
keyboard->wlr->repeat_info.delay) < 0) {
|
||||||
sway_log(SWAY_DEBUG, "failed to set key repeat timer");
|
sway_log(SWAY_DEBUG, "failed to set key repeat timer");
|
||||||
}
|
}
|
||||||
} else if (keyboard->repeat_binding) {
|
} else if (keyboard->repeat_binding) {
|
||||||
|
@ -493,7 +488,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handled && wlr_device->keyboard->group) {
|
if (!handled && keyboard->wlr->group) {
|
||||||
// Only handle device specific bindings for keyboards in a group
|
// Only handle device specific bindings for keyboards in a group
|
||||||
free(device_identifier);
|
free(device_identifier);
|
||||||
return;
|
return;
|
||||||
|
@ -518,7 +513,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
|
||||||
&keyboard->state_pressed_sent, event->keycode,
|
&keyboard->state_pressed_sent, event->keycode,
|
||||||
event->state, keyinfo.keycode, 0);
|
event->state, keyinfo.keycode, 0);
|
||||||
if (pressed_sent) {
|
if (pressed_sent) {
|
||||||
wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
|
wlr_seat_set_keyboard(wlr_seat, keyboard->wlr);
|
||||||
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
|
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
|
||||||
event->keycode, event->state);
|
event->keycode, event->state);
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -529,8 +524,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
|
||||||
struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard);
|
struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard);
|
||||||
|
|
||||||
if (kb_grab) {
|
if (kb_grab) {
|
||||||
wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab,
|
wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, keyboard->wlr);
|
||||||
wlr_device->keyboard);
|
|
||||||
wlr_input_method_keyboard_grab_v2_send_key(kb_grab,
|
wlr_input_method_keyboard_grab_v2_send_key(kb_grab,
|
||||||
event->time_msec, event->keycode, event->state);
|
event->time_msec, event->keycode, event->state);
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -543,7 +537,7 @@ static void handle_key_event(struct sway_keyboard *keyboard,
|
||||||
update_shortcut_state(
|
update_shortcut_state(
|
||||||
&keyboard->state_pressed_sent, event->keycode, event->state,
|
&keyboard->state_pressed_sent, event->keycode, event->state,
|
||||||
keyinfo.keycode, 0);
|
keyinfo.keycode, 0);
|
||||||
wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
|
wlr_seat_set_keyboard(wlr_seat, keyboard->wlr);
|
||||||
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
|
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
|
||||||
event->keycode, event->state);
|
event->keycode, event->state);
|
||||||
}
|
}
|
||||||
|
@ -619,14 +613,12 @@ static void handle_keyboard_group_leave(struct wl_listener *listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_keyboard_repeat(void *data) {
|
static int handle_keyboard_repeat(void *data) {
|
||||||
struct sway_keyboard *keyboard = (struct sway_keyboard *)data;
|
struct sway_keyboard *keyboard = data;
|
||||||
struct wlr_keyboard *wlr_device =
|
|
||||||
keyboard->seat_device->input_device->wlr_device->keyboard;
|
|
||||||
if (keyboard->repeat_binding) {
|
if (keyboard->repeat_binding) {
|
||||||
if (wlr_device->repeat_info.rate > 0) {
|
if (keyboard->wlr->repeat_info.rate > 0) {
|
||||||
// We queue the next event first, as the command might cancel it
|
// We queue the next event first, as the command might cancel it
|
||||||
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
||||||
1000 / wlr_device->repeat_info.rate) < 0) {
|
1000 / keyboard->wlr->repeat_info.rate) < 0) {
|
||||||
sway_log(SWAY_DEBUG, "failed to update key repeat timer");
|
sway_log(SWAY_DEBUG, "failed to update key repeat timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,31 +651,28 @@ static void determine_bar_visibility(uint32_t modifiers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_modifier_event(struct sway_keyboard *keyboard) {
|
static void handle_modifier_event(struct sway_keyboard *keyboard) {
|
||||||
struct wlr_input_device *wlr_device =
|
if (!keyboard->wlr->group) {
|
||||||
keyboard->seat_device->input_device->wlr_device;
|
|
||||||
if (!wlr_device->keyboard->group) {
|
|
||||||
struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard);
|
struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard);
|
||||||
|
|
||||||
if (kb_grab) {
|
if (kb_grab) {
|
||||||
wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab,
|
wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, keyboard->wlr);
|
||||||
wlr_device->keyboard);
|
|
||||||
wlr_input_method_keyboard_grab_v2_send_modifiers(kb_grab,
|
wlr_input_method_keyboard_grab_v2_send_modifiers(kb_grab,
|
||||||
&wlr_device->keyboard->modifiers);
|
&keyboard->wlr->modifiers);
|
||||||
} else {
|
} else {
|
||||||
struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
|
struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
|
||||||
wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard);
|
wlr_seat_set_keyboard(wlr_seat, keyboard->wlr);
|
||||||
wlr_seat_keyboard_notify_modifiers(wlr_seat,
|
wlr_seat_keyboard_notify_modifiers(wlr_seat,
|
||||||
&wlr_device->keyboard->modifiers);
|
&keyboard->wlr->modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t modifiers = wlr_keyboard_get_modifiers(wlr_device->keyboard);
|
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->wlr);
|
||||||
determine_bar_visibility(modifiers);
|
determine_bar_visibility(modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlr_device->keyboard->modifiers.group != keyboard->effective_layout) {
|
if (keyboard->wlr->modifiers.group != keyboard->effective_layout) {
|
||||||
keyboard->effective_layout = wlr_device->keyboard->modifiers.group;
|
keyboard->effective_layout = keyboard->wlr->modifiers.group;
|
||||||
|
|
||||||
if (!wlr_keyboard_group_from_wlr_keyboard(wlr_device->keyboard)) {
|
if (!wlr_keyboard_group_from_wlr_keyboard(keyboard->wlr)) {
|
||||||
ipc_event_input("xkb_layout", keyboard->seat_device->input_device);
|
ipc_event_input("xkb_layout", keyboard->seat_device->input_device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -712,6 +701,7 @@ struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard->seat_device = device;
|
keyboard->seat_device = device;
|
||||||
|
keyboard->wlr = wlr_keyboard_from_input_device(device->input_device->wlr_device);
|
||||||
device->keyboard = keyboard;
|
device->keyboard = keyboard;
|
||||||
|
|
||||||
wl_list_init(&keyboard->keyboard_key.link);
|
wl_list_init(&keyboard->keyboard_key.link);
|
||||||
|
@ -820,13 +810,12 @@ static void destroy_empty_wlr_keyboard_group(void *data) {
|
||||||
|
|
||||||
static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) {
|
static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) {
|
||||||
struct sway_input_device *device = keyboard->seat_device->input_device;
|
struct sway_input_device *device = keyboard->seat_device->input_device;
|
||||||
struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard;
|
struct wlr_keyboard_group *wlr_group = keyboard->wlr->group;
|
||||||
struct wlr_keyboard_group *wlr_group = wlr_keyboard->group;
|
|
||||||
|
|
||||||
sway_log(SWAY_DEBUG, "Removing keyboard %s from group %p",
|
sway_log(SWAY_DEBUG, "Removing keyboard %s from group %p",
|
||||||
device->identifier, wlr_group);
|
device->identifier, wlr_group);
|
||||||
|
|
||||||
wlr_keyboard_group_remove_keyboard(wlr_keyboard->group, wlr_keyboard);
|
wlr_keyboard_group_remove_keyboard(keyboard->wlr->group, keyboard->wlr);
|
||||||
|
|
||||||
if (wl_list_empty(&wlr_group->devices)) {
|
if (wl_list_empty(&wlr_group->devices)) {
|
||||||
sway_log(SWAY_DEBUG, "Destroying empty keyboard group %p",
|
sway_log(SWAY_DEBUG, "Destroying empty keyboard group %p",
|
||||||
|
@ -851,9 +840,7 @@ static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) {
|
static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) {
|
||||||
struct sway_input_device *device = keyboard->seat_device->input_device;
|
if (!keyboard->wlr->group) {
|
||||||
struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard;
|
|
||||||
if (!wlr_keyboard->group) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,7 +856,7 @@ static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) {
|
||||||
break;
|
break;
|
||||||
case KEYBOARD_GROUP_DEFAULT: /* fallthrough */
|
case KEYBOARD_GROUP_DEFAULT: /* fallthrough */
|
||||||
case KEYBOARD_GROUP_SMART:;
|
case KEYBOARD_GROUP_SMART:;
|
||||||
struct wlr_keyboard_group *group = wlr_keyboard->group;
|
struct wlr_keyboard_group *group = keyboard->wlr->group;
|
||||||
if (!wlr_keyboard_keymaps_match(keyboard->keymap, group->keyboard.keymap) ||
|
if (!wlr_keyboard_keymaps_match(keyboard->keymap, group->keyboard.keymap) ||
|
||||||
!repeat_info_match(keyboard, &group->keyboard)) {
|
!repeat_info_match(keyboard, &group->keyboard)) {
|
||||||
sway_keyboard_group_remove(keyboard);
|
sway_keyboard_group_remove(keyboard);
|
||||||
|
@ -880,7 +867,6 @@ static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) {
|
||||||
|
|
||||||
static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
|
static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
|
||||||
struct sway_input_device *device = keyboard->seat_device->input_device;
|
struct sway_input_device *device = keyboard->seat_device->input_device;
|
||||||
struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard;
|
|
||||||
struct sway_seat *seat = keyboard->seat_device->sway_seat;
|
struct sway_seat *seat = keyboard->seat_device->sway_seat;
|
||||||
struct seat_config *sc = seat_get_config(seat);
|
struct seat_config *sc = seat_get_config(seat);
|
||||||
|
|
||||||
|
@ -912,7 +898,7 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
|
||||||
repeat_info_match(keyboard, &wlr_group->keyboard)) {
|
repeat_info_match(keyboard, &wlr_group->keyboard)) {
|
||||||
sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p",
|
sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p",
|
||||||
device->identifier, wlr_group);
|
device->identifier, wlr_group);
|
||||||
wlr_keyboard_group_add_keyboard(wlr_group, wlr_keyboard);
|
wlr_keyboard_group_add_keyboard(wlr_group, keyboard->wlr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -960,7 +946,7 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
|
||||||
|
|
||||||
sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p",
|
sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p",
|
||||||
device->identifier, sway_group->wlr_group);
|
device->identifier, sway_group->wlr_group);
|
||||||
wlr_keyboard_group_add_keyboard(sway_group->wlr_group, wlr_keyboard);
|
wlr_keyboard_group_add_keyboard(sway_group->wlr_group, keyboard->wlr);
|
||||||
|
|
||||||
wl_list_insert(&seat->keyboard_groups, &sway_group->link);
|
wl_list_insert(&seat->keyboard_groups, &sway_group->link);
|
||||||
|
|
||||||
|
@ -992,10 +978,8 @@ cleanup:
|
||||||
void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
||||||
struct input_config *input_config =
|
struct input_config *input_config =
|
||||||
input_device_get_config(keyboard->seat_device->input_device);
|
input_device_get_config(keyboard->seat_device->input_device);
|
||||||
struct wlr_input_device *wlr_device =
|
|
||||||
keyboard->seat_device->input_device->wlr_device;
|
|
||||||
|
|
||||||
if (!sway_assert(!wlr_keyboard_group_from_wlr_keyboard(wlr_device->keyboard),
|
if (!sway_assert(!wlr_keyboard_group_from_wlr_keyboard(keyboard->wlr),
|
||||||
"sway_keyboard_configure should not be called with a "
|
"sway_keyboard_configure should not be called with a "
|
||||||
"keyboard group's keyboard")) {
|
"keyboard group's keyboard")) {
|
||||||
return;
|
return;
|
||||||
|
@ -1037,11 +1021,11 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
||||||
|
|
||||||
sway_keyboard_group_remove_invalid(keyboard);
|
sway_keyboard_group_remove_invalid(keyboard);
|
||||||
|
|
||||||
wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap);
|
wlr_keyboard_set_keymap(keyboard->wlr, keyboard->keymap);
|
||||||
wlr_keyboard_set_repeat_info(wlr_device->keyboard,
|
wlr_keyboard_set_repeat_info(keyboard->wlr,
|
||||||
keyboard->repeat_rate, keyboard->repeat_delay);
|
keyboard->repeat_rate, keyboard->repeat_delay);
|
||||||
|
|
||||||
if (!wlr_device->keyboard->group) {
|
if (!keyboard->wlr->group) {
|
||||||
sway_keyboard_group_add(keyboard);
|
sway_keyboard_group_add(keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1061,40 +1045,38 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (locked_mods) {
|
if (locked_mods) {
|
||||||
wlr_keyboard_notify_modifiers(wlr_device->keyboard, 0, 0,
|
wlr_keyboard_notify_modifiers(keyboard->wlr, 0, 0,
|
||||||
locked_mods, 0);
|
locked_mods, 0);
|
||||||
uint32_t leds = 0;
|
uint32_t leds = 0;
|
||||||
for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
|
for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
|
||||||
if (xkb_state_led_index_is_active(
|
if (xkb_state_led_index_is_active(keyboard->wlr->xkb_state,
|
||||||
wlr_device->keyboard->xkb_state,
|
keyboard->wlr->led_indexes[i])) {
|
||||||
wlr_device->keyboard->led_indexes[i])) {
|
|
||||||
leds |= (1 << i);
|
leds |= (1 << i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wlr_device->keyboard->group) {
|
if (keyboard->wlr->group) {
|
||||||
wlr_keyboard_led_update(
|
wlr_keyboard_led_update(&keyboard->wlr->group->keyboard, leds);
|
||||||
&wlr_device->keyboard->group->keyboard, leds);
|
|
||||||
} else {
|
} else {
|
||||||
wlr_keyboard_led_update(wlr_device->keyboard, leds);
|
wlr_keyboard_led_update(keyboard->wlr, leds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xkb_keymap_unref(keymap);
|
xkb_keymap_unref(keymap);
|
||||||
sway_keyboard_group_remove_invalid(keyboard);
|
sway_keyboard_group_remove_invalid(keyboard);
|
||||||
if (!wlr_device->keyboard->group) {
|
if (!keyboard->wlr->group) {
|
||||||
sway_keyboard_group_add(keyboard);
|
sway_keyboard_group_add(keyboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
|
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
|
||||||
wlr_seat_set_keyboard(seat, wlr_device->keyboard);
|
wlr_seat_set_keyboard(seat, keyboard->wlr);
|
||||||
|
|
||||||
wl_list_remove(&keyboard->keyboard_key.link);
|
wl_list_remove(&keyboard->keyboard_key.link);
|
||||||
wl_signal_add(&wlr_device->keyboard->events.key, &keyboard->keyboard_key);
|
wl_signal_add(&keyboard->wlr->events.key, &keyboard->keyboard_key);
|
||||||
keyboard->keyboard_key.notify = handle_keyboard_key;
|
keyboard->keyboard_key.notify = handle_keyboard_key;
|
||||||
|
|
||||||
wl_list_remove(&keyboard->keyboard_modifiers.link);
|
wl_list_remove(&keyboard->keyboard_modifiers.link);
|
||||||
wl_signal_add(&wlr_device->keyboard->events.modifiers,
|
wl_signal_add(&keyboard->wlr->events.modifiers,
|
||||||
&keyboard->keyboard_modifiers);
|
&keyboard->keyboard_modifiers);
|
||||||
keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers;
|
keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers;
|
||||||
|
|
||||||
|
@ -1111,12 +1093,11 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) {
|
||||||
if (!keyboard) {
|
if (!keyboard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (keyboard->seat_device->input_device->wlr_device->keyboard->group) {
|
if (keyboard->wlr->group) {
|
||||||
sway_keyboard_group_remove(keyboard);
|
sway_keyboard_group_remove(keyboard);
|
||||||
}
|
}
|
||||||
struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
|
struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
|
||||||
struct sway_input_device *device = keyboard->seat_device->input_device;
|
if (wlr_seat_get_keyboard(wlr_seat) == keyboard->wlr) {
|
||||||
if (wlr_seat_get_keyboard(wlr_seat) == device->wlr_device->keyboard) {
|
|
||||||
wlr_seat_set_keyboard(wlr_seat, NULL);
|
wlr_seat_set_keyboard(wlr_seat, NULL);
|
||||||
}
|
}
|
||||||
if (keyboard->keymap) {
|
if (keyboard->keymap) {
|
||||||
|
|
|
@ -142,7 +142,7 @@ static struct sway_keyboard *sway_keyboard_for_wlr_keyboard(
|
||||||
if (input_device->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
if (input_device->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (input_device->wlr_device->keyboard == wlr_keyboard) {
|
if (input_device->wlr_device == &wlr_keyboard->base) {
|
||||||
return seat_device->keyboard;
|
return seat_device->keyboard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ static struct sway_keyboard *sway_keyboard_for_wlr_keyboard(
|
||||||
wl_list_for_each(group, &seat->keyboard_groups, link) {
|
wl_list_for_each(group, &seat->keyboard_groups, link) {
|
||||||
struct sway_input_device *input_device =
|
struct sway_input_device *input_device =
|
||||||
group->seat_device->input_device;
|
group->seat_device->input_device;
|
||||||
if (input_device->wlr_device->keyboard == wlr_keyboard) {
|
if (input_device->wlr_device == &wlr_keyboard->base) {
|
||||||
return group->seat_device->keyboard;
|
return group->seat_device->keyboard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -745,10 +745,10 @@ static void seat_apply_input_config(struct sway_seat *seat,
|
||||||
struct wlr_input_device *dev = sway_device->input_device->wlr_device;
|
struct wlr_input_device *dev = sway_device->input_device->wlr_device;
|
||||||
switch (dev->type) {
|
switch (dev->type) {
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
mapped_to_output = dev->pointer->output_name;
|
mapped_to_output = wlr_pointer_from_input_device(dev)->output_name;
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TOUCH:
|
case WLR_INPUT_DEVICE_TOUCH:
|
||||||
mapped_to_output = dev->touch->output_name;
|
mapped_to_output = wlr_touch_from_input_device(dev)->output_name;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mapped_to_output = NULL;
|
mapped_to_output = NULL;
|
||||||
|
@ -822,7 +822,7 @@ static void seat_configure_keyboard(struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
sway_keyboard_configure(seat_device->keyboard);
|
sway_keyboard_configure(seat_device->keyboard);
|
||||||
wlr_seat_set_keyboard(seat->wlr_seat,
|
wlr_seat_set_keyboard(seat->wlr_seat,
|
||||||
seat_device->input_device->wlr_device->keyboard);
|
wlr_keyboard_from_input_device(seat_device->input_device->wlr_device));
|
||||||
|
|
||||||
// force notify reenter to pick up the new configuration. This reuses
|
// force notify reenter to pick up the new configuration. This reuses
|
||||||
// the current focused surface to avoid breaking input grabs.
|
// the current focused surface to avoid breaking input grabs.
|
||||||
|
|
|
@ -11,6 +11,7 @@ struct sway_switch *sway_switch_create(struct sway_seat *seat,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
device->switch_device = switch_device;
|
device->switch_device = switch_device;
|
||||||
|
switch_device->wlr = wlr_switch_from_input_device(device->input_device->wlr_device);
|
||||||
switch_device->seat_device = device;
|
switch_device->seat_device = device;
|
||||||
switch_device->state = WLR_SWITCH_STATE_OFF;
|
switch_device->state = WLR_SWITCH_STATE_OFF;
|
||||||
wl_list_init(&switch_device->switch_toggle.link);
|
wl_list_init(&switch_device->switch_toggle.link);
|
||||||
|
@ -95,10 +96,8 @@ static void handle_switch_toggle(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sway_switch_configure(struct sway_switch *sway_switch) {
|
void sway_switch_configure(struct sway_switch *sway_switch) {
|
||||||
struct wlr_input_device *wlr_device =
|
|
||||||
sway_switch->seat_device->input_device->wlr_device;
|
|
||||||
wl_list_remove(&sway_switch->switch_toggle.link);
|
wl_list_remove(&sway_switch->switch_toggle.link);
|
||||||
wl_signal_add(&wlr_device->switch_device->events.toggle,
|
wl_signal_add(&sway_switch->wlr->events.toggle,
|
||||||
&sway_switch->switch_toggle);
|
&sway_switch->switch_toggle);
|
||||||
sway_switch->switch_toggle.notify = handle_switch_toggle;
|
sway_switch->switch_toggle.notify = handle_switch_toggle;
|
||||||
sway_log(SWAY_DEBUG, "Configured switch for device");
|
sway_log(SWAY_DEBUG, "Configured switch for device");
|
||||||
|
|
|
@ -246,6 +246,7 @@ struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tablet_pad->wlr = wlr_tablet_pad_from_input_device(device->input_device->wlr_device);
|
||||||
tablet_pad->seat_device = device;
|
tablet_pad->seat_device = device;
|
||||||
wl_list_init(&tablet_pad->attach.link);
|
wl_list_init(&tablet_pad->attach.link);
|
||||||
wl_list_init(&tablet_pad->button.link);
|
wl_list_init(&tablet_pad->button.link);
|
||||||
|
@ -260,40 +261,40 @@ struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
|
|
||||||
void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) {
|
void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) {
|
||||||
struct wlr_input_device *device =
|
struct wlr_input_device *wlr_device =
|
||||||
tablet_pad->seat_device->input_device->wlr_device;
|
tablet_pad->seat_device->input_device->wlr_device;
|
||||||
struct sway_seat *seat = tablet_pad->seat_device->sway_seat;
|
struct sway_seat *seat = tablet_pad->seat_device->sway_seat;
|
||||||
|
|
||||||
if (!tablet_pad->tablet_v2_pad) {
|
if (!tablet_pad->tablet_v2_pad) {
|
||||||
tablet_pad->tablet_v2_pad =
|
tablet_pad->tablet_v2_pad =
|
||||||
wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, device);
|
wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, wlr_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_remove(&tablet_pad->attach.link);
|
wl_list_remove(&tablet_pad->attach.link);
|
||||||
tablet_pad->attach.notify = handle_tablet_pad_attach;
|
tablet_pad->attach.notify = handle_tablet_pad_attach;
|
||||||
wl_signal_add(&device->tablet_pad->events.attach_tablet,
|
wl_signal_add(&tablet_pad->wlr->events.attach_tablet,
|
||||||
&tablet_pad->attach);
|
&tablet_pad->attach);
|
||||||
|
|
||||||
wl_list_remove(&tablet_pad->button.link);
|
wl_list_remove(&tablet_pad->button.link);
|
||||||
tablet_pad->button.notify = handle_tablet_pad_button;
|
tablet_pad->button.notify = handle_tablet_pad_button;
|
||||||
wl_signal_add(&device->tablet_pad->events.button, &tablet_pad->button);
|
wl_signal_add(&tablet_pad->wlr->events.button, &tablet_pad->button);
|
||||||
|
|
||||||
wl_list_remove(&tablet_pad->strip.link);
|
wl_list_remove(&tablet_pad->strip.link);
|
||||||
tablet_pad->strip.notify = handle_tablet_pad_strip;
|
tablet_pad->strip.notify = handle_tablet_pad_strip;
|
||||||
wl_signal_add(&device->tablet_pad->events.strip, &tablet_pad->strip);
|
wl_signal_add(&tablet_pad->wlr->events.strip, &tablet_pad->strip);
|
||||||
|
|
||||||
wl_list_remove(&tablet_pad->ring.link);
|
wl_list_remove(&tablet_pad->ring.link);
|
||||||
tablet_pad->ring.notify = handle_tablet_pad_ring;
|
tablet_pad->ring.notify = handle_tablet_pad_ring;
|
||||||
wl_signal_add(&device->tablet_pad->events.ring, &tablet_pad->ring);
|
wl_signal_add(&tablet_pad->wlr->events.ring, &tablet_pad->ring);
|
||||||
|
|
||||||
/* Search for a sibling tablet */
|
/* Search for a sibling tablet */
|
||||||
if (!wlr_input_device_is_libinput(device)) {
|
if (!wlr_input_device_is_libinput(wlr_device)) {
|
||||||
/* We can only do this on libinput devices */
|
/* We can only do this on libinput devices */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct libinput_device_group *group =
|
struct libinput_device_group *group =
|
||||||
libinput_device_get_device_group(wlr_libinput_get_device_handle(device));
|
libinput_device_get_device_group(wlr_libinput_get_device_handle(wlr_device));
|
||||||
struct sway_tablet *tool;
|
struct sway_tablet *tool;
|
||||||
wl_list_for_each(tool, &seat->cursor->tablets, link) {
|
wl_list_for_each(tool, &seat->cursor->tablets, link) {
|
||||||
struct wlr_input_device *tablet =
|
struct wlr_input_device *tablet =
|
||||||
|
|
|
@ -979,7 +979,8 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
|
||||||
input_device_get_type(device)));
|
input_device_get_type(device)));
|
||||||
|
|
||||||
if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) {
|
if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) {
|
||||||
struct wlr_keyboard *keyboard = device->wlr_device->keyboard;
|
struct wlr_keyboard *keyboard =
|
||||||
|
wlr_keyboard_from_input_device(device->wlr_device);
|
||||||
struct xkb_keymap *keymap = keyboard->keymap;
|
struct xkb_keymap *keymap = keyboard->keymap;
|
||||||
struct xkb_state *state = keyboard->xkb_state;
|
struct xkb_state *state = keyboard->xkb_state;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue