diff options
author | 2022-06-21 23:10:38 +0200 | |
---|---|---|
committer | 2022-06-22 12:44:15 -0400 | |
commit | 122d8ce95484bd097bf3a15b8191213bd6969b41 (patch) | |
tree | b97bb88c4bf7b566747bed4cce84f51842cd21a5 /sway | |
parent | Allocate enough space for `cmd_results->error` (diff) | |
download | sway-122d8ce95484bd097bf3a15b8191213bd6969b41.tar.gz sway-122d8ce95484bd097bf3a15b8191213bd6969b41.tar.zst sway-122d8ce95484bd097bf3a15b8191213bd6969b41.zip |
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
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/input/xkb_switch_layout.c | 5 | ||||
-rw-r--r-- | sway/input/cursor.c | 2 | ||||
-rw-r--r-- | sway/input/keyboard.c | 117 | ||||
-rw-r--r-- | sway/input/seat.c | 10 | ||||
-rw-r--r-- | sway/input/switch.c | 5 | ||||
-rw-r--r-- | sway/input/tablet.c | 17 | ||||
-rw-r--r-- | sway/ipc-json.c | 9 |
7 files changed, 73 insertions, 92 deletions
diff --git a/sway/commands/input/xkb_switch_layout.c b/sway/commands/input/xkb_switch_layout.c index dabc6697..3cce4ec8 100644 --- a/sway/commands/input/xkb_switch_layout.c +++ b/sway/commands/input/xkb_switch_layout.c | |||
@@ -98,10 +98,9 @@ struct cmd_results *input_cmd_xkb_switch_layout(int argc, char **argv) { | |||
98 | struct xkb_switch_layout_action *action = | 98 | struct xkb_switch_layout_action *action = |
99 | &actions[actions_len++]; | 99 | &actions[actions_len++]; |
100 | 100 | ||
101 | action->keyboard = dev->wlr_device->keyboard; | 101 | action->keyboard = wlr_keyboard_from_input_device(dev->wlr_device); |
102 | if (relative) { | 102 | if (relative) { |
103 | action->layout = get_layout_relative( | 103 | action->layout = get_layout_relative(action->keyboard, relative); |
104 | dev->wlr_device->keyboard, relative); | ||
105 | } else { | 104 | } else { |
106 | action->layout = layout; | 105 | action->layout = layout; |
107 | } | 106 | } |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index e87594ee..2ee63124 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -595,7 +595,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device, | |||
595 | double y1 = region->y1, y2 = region->y2; | 595 | double y1 = region->y1, y2 = region->y2; |
596 | 596 | ||
597 | if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { | 597 | if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { |
598 | struct wlr_tablet *tablet = device->tablet; | 598 | struct wlr_tablet *tablet = wlr_tablet_from_input_device(device); |
599 | if (tablet->width_mm == 0 || tablet->height_mm == 0) { | 599 | if (tablet->width_mm == 0 || tablet->height_mm == 0) { |
600 | return; | 600 | return; |
601 | } | 601 | } |
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 8f18b8ba..5e5692f1 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c | |||
@@ -291,14 +291,12 @@ static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard, | |||
291 | static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard, | 291 | static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard, |
292 | xkb_keycode_t keycode, const xkb_keysym_t **keysyms, | 292 | xkb_keycode_t keycode, const xkb_keysym_t **keysyms, |
293 | uint32_t *modifiers) { | 293 | uint32_t *modifiers) { |
294 | struct wlr_input_device *device = | 294 | *modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); |
295 | keyboard->seat_device->input_device->wlr_device; | ||
296 | *modifiers = wlr_keyboard_get_modifiers(device->keyboard); | ||
297 | xkb_mod_mask_t consumed = xkb_state_key_get_consumed_mods2( | 295 | xkb_mod_mask_t consumed = xkb_state_key_get_consumed_mods2( |
298 | device->keyboard->xkb_state, keycode, XKB_CONSUMED_MODE_XKB); | 296 | keyboard->wlr->xkb_state, keycode, XKB_CONSUMED_MODE_XKB); |
299 | *modifiers = *modifiers & ~consumed; | 297 | *modifiers = *modifiers & ~consumed; |
300 | 298 | ||
301 | return xkb_state_key_get_syms(device->keyboard->xkb_state, | 299 | return xkb_state_key_get_syms(keyboard->wlr->xkb_state, |
302 | keycode, keysyms); | 300 | keycode, keysyms); |
303 | } | 301 | } |
304 | 302 | ||
@@ -314,13 +312,11 @@ static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard, | |||
314 | static size_t keyboard_keysyms_raw(struct sway_keyboard *keyboard, | 312 | static size_t keyboard_keysyms_raw(struct sway_keyboard *keyboard, |
315 | xkb_keycode_t keycode, const xkb_keysym_t **keysyms, | 313 | xkb_keycode_t keycode, const xkb_keysym_t **keysyms, |
316 | uint32_t *modifiers) { | 314 | uint32_t *modifiers) { |
317 | struct wlr_input_device *device = | 315 | *modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); |
318 | keyboard->seat_device->input_device->wlr_device; | ||
319 | *modifiers = wlr_keyboard_get_modifiers(device->keyboard); | ||
320 | 316 | ||
321 | xkb_layout_index_t layout_index = xkb_state_key_get_layout( | 317 | xkb_layout_index_t layout_index = xkb_state_key_get_layout( |
322 | device->keyboard->xkb_state, keycode); | 318 | keyboard->wlr->xkb_state, keycode); |
323 | return xkb_keymap_key_get_syms_by_level(device->keyboard->keymap, | 319 | return xkb_keymap_key_get_syms_by_level(keyboard->wlr->keymap, |
324 | keycode, layout_index, 0, keysyms); | 320 | keycode, layout_index, 0, keysyms); |
325 | } | 321 | } |
326 | 322 | ||
@@ -360,8 +356,7 @@ static void update_keyboard_state(struct sway_keyboard *keyboard, | |||
360 | keyinfo->keycode, &keyinfo->translated_keysyms, | 356 | keyinfo->keycode, &keyinfo->translated_keysyms, |
361 | &keyinfo->translated_modifiers); | 357 | &keyinfo->translated_modifiers); |
362 | 358 | ||
363 | keyinfo->code_modifiers = wlr_keyboard_get_modifiers( | 359 | keyinfo->code_modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); |
364 | keyboard->seat_device->input_device->wlr_device->keyboard); | ||
365 | 360 | ||
366 | // Update shortcut model keyinfo | 361 | // Update shortcut model keyinfo |
367 | update_shortcut_state(&keyboard->state_keycodes, raw_keycode, keystate, | 362 | update_shortcut_state(&keyboard->state_keycodes, raw_keycode, keystate, |
@@ -407,7 +402,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, | |||
407 | struct wlr_input_device *wlr_device = | 402 | struct wlr_input_device *wlr_device = |
408 | keyboard->seat_device->input_device->wlr_device; | 403 | keyboard->seat_device->input_device->wlr_device; |
409 | char *device_identifier = input_device_get_identifier(wlr_device); | 404 | char *device_identifier = input_device_get_identifier(wlr_device); |
410 | bool exact_identifier = wlr_device->keyboard->group != NULL; | 405 | bool exact_identifier = keyboard->wlr->group != NULL; |
411 | seat_idle_notify_activity(seat, IDLE_SOURCE_KEYBOARD); | 406 | seat_idle_notify_activity(seat, IDLE_SOURCE_KEYBOARD); |
412 | bool input_inhibited = seat->exclusive_client != NULL || | 407 | bool input_inhibited = seat->exclusive_client != NULL || |
413 | server.session_lock.locked; | 408 | server.session_lock.locked; |
@@ -478,10 +473,10 @@ static void handle_key_event(struct sway_keyboard *keyboard, | |||
478 | // Set up (or clear) keyboard repeat for a pressed binding. Since the | 473 | // Set up (or clear) keyboard repeat for a pressed binding. Since the |
479 | // binding may remove the keyboard, the timer needs to be updated first | 474 | // binding may remove the keyboard, the timer needs to be updated first |
480 | if (binding && !(binding->flags & BINDING_NOREPEAT) && | 475 | if (binding && !(binding->flags & BINDING_NOREPEAT) && |
481 | wlr_device->keyboard->repeat_info.delay > 0) { | 476 | keyboard->wlr->repeat_info.delay > 0) { |
482 | keyboard->repeat_binding = binding; | 477 | keyboard->repeat_binding = binding; |
483 | if (wl_event_source_timer_update(keyboard->key_repeat_source, | 478 | if (wl_event_source_timer_update(keyboard->key_repeat_source, |
484 | wlr_device->keyboard->repeat_info.delay) < 0) { | 479 | keyboard->wlr->repeat_info.delay) < 0) { |
485 | sway_log(SWAY_DEBUG, "failed to set key repeat timer"); | 480 | sway_log(SWAY_DEBUG, "failed to set key repeat timer"); |
486 | } | 481 | } |
487 | } else if (keyboard->repeat_binding) { | 482 | } else if (keyboard->repeat_binding) { |
@@ -493,7 +488,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, | |||
493 | handled = true; | 488 | handled = true; |
494 | } | 489 | } |
495 | 490 | ||
496 | if (!handled && wlr_device->keyboard->group) { | 491 | if (!handled && keyboard->wlr->group) { |
497 | // Only handle device specific bindings for keyboards in a group | 492 | // Only handle device specific bindings for keyboards in a group |
498 | free(device_identifier); | 493 | free(device_identifier); |
499 | return; | 494 | return; |
@@ -518,7 +513,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, | |||
518 | &keyboard->state_pressed_sent, event->keycode, | 513 | &keyboard->state_pressed_sent, event->keycode, |
519 | event->state, keyinfo.keycode, 0); | 514 | event->state, keyinfo.keycode, 0); |
520 | if (pressed_sent) { | 515 | if (pressed_sent) { |
521 | wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard); | 516 | wlr_seat_set_keyboard(wlr_seat, keyboard->wlr); |
522 | wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, | 517 | wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, |
523 | event->keycode, event->state); | 518 | event->keycode, event->state); |
524 | handled = true; | 519 | handled = true; |
@@ -529,8 +524,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, | |||
529 | struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard); | 524 | struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard); |
530 | 525 | ||
531 | if (kb_grab) { | 526 | if (kb_grab) { |
532 | wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, | 527 | wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, keyboard->wlr); |
533 | wlr_device->keyboard); | ||
534 | wlr_input_method_keyboard_grab_v2_send_key(kb_grab, | 528 | wlr_input_method_keyboard_grab_v2_send_key(kb_grab, |
535 | event->time_msec, event->keycode, event->state); | 529 | event->time_msec, event->keycode, event->state); |
536 | handled = true; | 530 | handled = true; |
@@ -543,7 +537,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, | |||
543 | update_shortcut_state( | 537 | update_shortcut_state( |
544 | &keyboard->state_pressed_sent, event->keycode, event->state, | 538 | &keyboard->state_pressed_sent, event->keycode, event->state, |
545 | keyinfo.keycode, 0); | 539 | keyinfo.keycode, 0); |
546 | wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard); | 540 | wlr_seat_set_keyboard(wlr_seat, keyboard->wlr); |
547 | wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, | 541 | wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, |
548 | event->keycode, event->state); | 542 | event->keycode, event->state); |
549 | } | 543 | } |
@@ -619,14 +613,12 @@ static void handle_keyboard_group_leave(struct wl_listener *listener, | |||
619 | } | 613 | } |
620 | 614 | ||
621 | static int handle_keyboard_repeat(void *data) { | 615 | static int handle_keyboard_repeat(void *data) { |
622 | struct sway_keyboard *keyboard = (struct sway_keyboard *)data; | 616 | struct sway_keyboard *keyboard = data; |
623 | struct wlr_keyboard *wlr_device = | ||
624 | keyboard->seat_device->input_device->wlr_device->keyboard; | ||
625 | if (keyboard->repeat_binding) { | 617 | if (keyboard->repeat_binding) { |
626 | if (wlr_device->repeat_info.rate > 0) { | 618 | if (keyboard->wlr->repeat_info.rate > 0) { |
627 | // We queue the next event first, as the command might cancel it | 619 | // We queue the next event first, as the command might cancel it |
628 | if (wl_event_source_timer_update(keyboard->key_repeat_source, | 620 | if (wl_event_source_timer_update(keyboard->key_repeat_source, |
629 | 1000 / wlr_device->repeat_info.rate) < 0) { | 621 | 1000 / keyboard->wlr->repeat_info.rate) < 0) { |
630 | sway_log(SWAY_DEBUG, "failed to update key repeat timer"); | 622 | sway_log(SWAY_DEBUG, "failed to update key repeat timer"); |
631 | } | 623 | } |
632 | } | 624 | } |
@@ -659,31 +651,28 @@ static void determine_bar_visibility(uint32_t modifiers) { | |||
659 | } | 651 | } |
660 | 652 | ||
661 | static void handle_modifier_event(struct sway_keyboard *keyboard) { | 653 | static void handle_modifier_event(struct sway_keyboard *keyboard) { |
662 | struct wlr_input_device *wlr_device = | 654 | if (!keyboard->wlr->group) { |
663 | keyboard->seat_device->input_device->wlr_device; | ||
664 | if (!wlr_device->keyboard->group) { | ||
665 | struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard); | 655 | struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard); |
666 | 656 | ||
667 | if (kb_grab) { | 657 | if (kb_grab) { |
668 | wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, | 658 | wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, keyboard->wlr); |
669 | wlr_device->keyboard); | ||
670 | wlr_input_method_keyboard_grab_v2_send_modifiers(kb_grab, | 659 | wlr_input_method_keyboard_grab_v2_send_modifiers(kb_grab, |
671 | &wlr_device->keyboard->modifiers); | 660 | &keyboard->wlr->modifiers); |
672 | } else { | 661 | } else { |
673 | struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat; | 662 | struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat; |
674 | wlr_seat_set_keyboard(wlr_seat, wlr_device->keyboard); | 663 | wlr_seat_set_keyboard(wlr_seat, keyboard->wlr); |
675 | wlr_seat_keyboard_notify_modifiers(wlr_seat, | 664 | wlr_seat_keyboard_notify_modifiers(wlr_seat, |
676 | &wlr_device->keyboard->modifiers); | 665 | &keyboard->wlr->modifiers); |
677 | } | 666 | } |
678 | 667 | ||
679 | uint32_t modifiers = wlr_keyboard_get_modifiers(wlr_device->keyboard); | 668 | uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); |
680 | determine_bar_visibility(modifiers); | 669 | determine_bar_visibility(modifiers); |
681 | } | 670 | } |
682 | 671 | ||
683 | if (wlr_device->keyboard->modifiers.group != keyboard->effective_layout) { | 672 | if (keyboard->wlr->modifiers.group != keyboard->effective_layout) { |
684 | keyboard->effective_layout = wlr_device->keyboard->modifiers.group; | 673 | keyboard->effective_layout = keyboard->wlr->modifiers.group; |
685 | 674 | ||
686 | if (!wlr_keyboard_group_from_wlr_keyboard(wlr_device->keyboard)) { | 675 | if (!wlr_keyboard_group_from_wlr_keyboard(keyboard->wlr)) { |
687 | ipc_event_input("xkb_layout", keyboard->seat_device->input_device); | 676 | ipc_event_input("xkb_layout", keyboard->seat_device->input_device); |
688 | } | 677 | } |
689 | } | 678 | } |
@@ -712,6 +701,7 @@ struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, | |||
712 | } | 701 | } |
713 | 702 | ||
714 | keyboard->seat_device = device; | 703 | keyboard->seat_device = device; |
704 | keyboard->wlr = wlr_keyboard_from_input_device(device->input_device->wlr_device); | ||
715 | device->keyboard = keyboard; | 705 | device->keyboard = keyboard; |
716 | 706 | ||
717 | wl_list_init(&keyboard->keyboard_key.link); | 707 | wl_list_init(&keyboard->keyboard_key.link); |
@@ -820,13 +810,12 @@ static void destroy_empty_wlr_keyboard_group(void *data) { | |||
820 | 810 | ||
821 | static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) { | 811 | static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) { |
822 | struct sway_input_device *device = keyboard->seat_device->input_device; | 812 | struct sway_input_device *device = keyboard->seat_device->input_device; |
823 | struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard; | 813 | struct wlr_keyboard_group *wlr_group = keyboard->wlr->group; |
824 | struct wlr_keyboard_group *wlr_group = wlr_keyboard->group; | ||
825 | 814 | ||
826 | sway_log(SWAY_DEBUG, "Removing keyboard %s from group %p", | 815 | sway_log(SWAY_DEBUG, "Removing keyboard %s from group %p", |
827 | device->identifier, wlr_group); | 816 | device->identifier, wlr_group); |
828 | 817 | ||
829 | wlr_keyboard_group_remove_keyboard(wlr_keyboard->group, wlr_keyboard); | 818 | wlr_keyboard_group_remove_keyboard(keyboard->wlr->group, keyboard->wlr); |
830 | 819 | ||
831 | if (wl_list_empty(&wlr_group->devices)) { | 820 | if (wl_list_empty(&wlr_group->devices)) { |
832 | sway_log(SWAY_DEBUG, "Destroying empty keyboard group %p", | 821 | sway_log(SWAY_DEBUG, "Destroying empty keyboard group %p", |
@@ -851,9 +840,7 @@ static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) { | |||
851 | } | 840 | } |
852 | 841 | ||
853 | static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) { | 842 | static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) { |
854 | struct sway_input_device *device = keyboard->seat_device->input_device; | 843 | if (!keyboard->wlr->group) { |
855 | struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard; | ||
856 | if (!wlr_keyboard->group) { | ||
857 | return; | 844 | return; |
858 | } | 845 | } |
859 | 846 | ||
@@ -869,7 +856,7 @@ static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) { | |||
869 | break; | 856 | break; |
870 | case KEYBOARD_GROUP_DEFAULT: /* fallthrough */ | 857 | case KEYBOARD_GROUP_DEFAULT: /* fallthrough */ |
871 | case KEYBOARD_GROUP_SMART:; | 858 | case KEYBOARD_GROUP_SMART:; |
872 | struct wlr_keyboard_group *group = wlr_keyboard->group; | 859 | struct wlr_keyboard_group *group = keyboard->wlr->group; |
873 | if (!wlr_keyboard_keymaps_match(keyboard->keymap, group->keyboard.keymap) || | 860 | if (!wlr_keyboard_keymaps_match(keyboard->keymap, group->keyboard.keymap) || |
874 | !repeat_info_match(keyboard, &group->keyboard)) { | 861 | !repeat_info_match(keyboard, &group->keyboard)) { |
875 | sway_keyboard_group_remove(keyboard); | 862 | sway_keyboard_group_remove(keyboard); |
@@ -880,7 +867,6 @@ static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) { | |||
880 | 867 | ||
881 | static void sway_keyboard_group_add(struct sway_keyboard *keyboard) { | 868 | static void sway_keyboard_group_add(struct sway_keyboard *keyboard) { |
882 | struct sway_input_device *device = keyboard->seat_device->input_device; | 869 | struct sway_input_device *device = keyboard->seat_device->input_device; |
883 | struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard; | ||
884 | struct sway_seat *seat = keyboard->seat_device->sway_seat; | 870 | struct sway_seat *seat = keyboard->seat_device->sway_seat; |
885 | struct seat_config *sc = seat_get_config(seat); | 871 | struct seat_config *sc = seat_get_config(seat); |
886 | 872 | ||
@@ -912,7 +898,7 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) { | |||
912 | repeat_info_match(keyboard, &wlr_group->keyboard)) { | 898 | repeat_info_match(keyboard, &wlr_group->keyboard)) { |
913 | sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p", | 899 | sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p", |
914 | device->identifier, wlr_group); | 900 | device->identifier, wlr_group); |
915 | wlr_keyboard_group_add_keyboard(wlr_group, wlr_keyboard); | 901 | wlr_keyboard_group_add_keyboard(wlr_group, keyboard->wlr); |
916 | return; | 902 | return; |
917 | } | 903 | } |
918 | break; | 904 | break; |
@@ -960,7 +946,7 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) { | |||
960 | 946 | ||
961 | sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p", | 947 | sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p", |
962 | device->identifier, sway_group->wlr_group); | 948 | device->identifier, sway_group->wlr_group); |
963 | wlr_keyboard_group_add_keyboard(sway_group->wlr_group, wlr_keyboard); | 949 | wlr_keyboard_group_add_keyboard(sway_group->wlr_group, keyboard->wlr); |
964 | 950 | ||
965 | wl_list_insert(&seat->keyboard_groups, &sway_group->link); | 951 | wl_list_insert(&seat->keyboard_groups, &sway_group->link); |
966 | 952 | ||
@@ -992,10 +978,8 @@ cleanup: | |||
992 | void sway_keyboard_configure(struct sway_keyboard *keyboard) { | 978 | void sway_keyboard_configure(struct sway_keyboard *keyboard) { |
993 | struct input_config *input_config = | 979 | struct input_config *input_config = |
994 | input_device_get_config(keyboard->seat_device->input_device); | 980 | input_device_get_config(keyboard->seat_device->input_device); |
995 | struct wlr_input_device *wlr_device = | ||
996 | keyboard->seat_device->input_device->wlr_device; | ||
997 | 981 | ||
998 | if (!sway_assert(!wlr_keyboard_group_from_wlr_keyboard(wlr_device->keyboard), | 982 | if (!sway_assert(!wlr_keyboard_group_from_wlr_keyboard(keyboard->wlr), |
999 | "sway_keyboard_configure should not be called with a " | 983 | "sway_keyboard_configure should not be called with a " |
1000 | "keyboard group's keyboard")) { | 984 | "keyboard group's keyboard")) { |
1001 | return; | 985 | return; |
@@ -1037,11 +1021,11 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { | |||
1037 | 1021 | ||
1038 | sway_keyboard_group_remove_invalid(keyboard); | 1022 | sway_keyboard_group_remove_invalid(keyboard); |
1039 | 1023 | ||
1040 | wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap); | 1024 | wlr_keyboard_set_keymap(keyboard->wlr, keyboard->keymap); |
1041 | wlr_keyboard_set_repeat_info(wlr_device->keyboard, | 1025 | wlr_keyboard_set_repeat_info(keyboard->wlr, |
1042 | keyboard->repeat_rate, keyboard->repeat_delay); | 1026 | keyboard->repeat_rate, keyboard->repeat_delay); |
1043 | 1027 | ||
1044 | if (!wlr_device->keyboard->group) { | 1028 | if (!keyboard->wlr->group) { |
1045 | sway_keyboard_group_add(keyboard); | 1029 | sway_keyboard_group_add(keyboard); |
1046 | } | 1030 | } |
1047 | 1031 | ||
@@ -1061,40 +1045,38 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { | |||
1061 | } | 1045 | } |
1062 | } | 1046 | } |
1063 | if (locked_mods) { | 1047 | if (locked_mods) { |
1064 | wlr_keyboard_notify_modifiers(wlr_device->keyboard, 0, 0, | 1048 | wlr_keyboard_notify_modifiers(keyboard->wlr, 0, 0, |
1065 | locked_mods, 0); | 1049 | locked_mods, 0); |
1066 | uint32_t leds = 0; | 1050 | uint32_t leds = 0; |
1067 | for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) { | 1051 | for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) { |
1068 | if (xkb_state_led_index_is_active( | 1052 | if (xkb_state_led_index_is_active(keyboard->wlr->xkb_state, |
1069 | wlr_device->keyboard->xkb_state, | 1053 | keyboard->wlr->led_indexes[i])) { |
1070 | wlr_device->keyboard->led_indexes[i])) { | ||
1071 | leds |= (1 << i); | 1054 | leds |= (1 << i); |
1072 | } | 1055 | } |
1073 | } | 1056 | } |
1074 | if (wlr_device->keyboard->group) { | 1057 | if (keyboard->wlr->group) { |
1075 | wlr_keyboard_led_update( | 1058 | wlr_keyboard_led_update(&keyboard->wlr->group->keyboard, leds); |
1076 | &wlr_device->keyboard->group->keyboard, leds); | ||
1077 | } else { | 1059 | } else { |
1078 | wlr_keyboard_led_update(wlr_device->keyboard, leds); | 1060 | wlr_keyboard_led_update(keyboard->wlr, leds); |
1079 | } | 1061 | } |
1080 | } | 1062 | } |
1081 | } else { | 1063 | } else { |
1082 | xkb_keymap_unref(keymap); | 1064 | xkb_keymap_unref(keymap); |
1083 | sway_keyboard_group_remove_invalid(keyboard); | 1065 | sway_keyboard_group_remove_invalid(keyboard); |
1084 | if (!wlr_device->keyboard->group) { | 1066 | if (!keyboard->wlr->group) { |
1085 | sway_keyboard_group_add(keyboard); | 1067 | sway_keyboard_group_add(keyboard); |
1086 | } | 1068 | } |
1087 | } | 1069 | } |
1088 | 1070 | ||
1089 | struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat; | 1071 | struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat; |
1090 | wlr_seat_set_keyboard(seat, wlr_device->keyboard); | 1072 | wlr_seat_set_keyboard(seat, keyboard->wlr); |
1091 | 1073 | ||
1092 | wl_list_remove(&keyboard->keyboard_key.link); | 1074 | wl_list_remove(&keyboard->keyboard_key.link); |
1093 | wl_signal_add(&wlr_device->keyboard->events.key, &keyboard->keyboard_key); | 1075 | wl_signal_add(&keyboard->wlr->events.key, &keyboard->keyboard_key); |
1094 | keyboard->keyboard_key.notify = handle_keyboard_key; | 1076 | keyboard->keyboard_key.notify = handle_keyboard_key; |
1095 | 1077 | ||
1096 | wl_list_remove(&keyboard->keyboard_modifiers.link); | 1078 | wl_list_remove(&keyboard->keyboard_modifiers.link); |
1097 | wl_signal_add(&wlr_device->keyboard->events.modifiers, | 1079 | wl_signal_add(&keyboard->wlr->events.modifiers, |
1098 | &keyboard->keyboard_modifiers); | 1080 | &keyboard->keyboard_modifiers); |
1099 | keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers; | 1081 | keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers; |
1100 | 1082 | ||
@@ -1111,12 +1093,11 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) { | |||
1111 | if (!keyboard) { | 1093 | if (!keyboard) { |
1112 | return; | 1094 | return; |
1113 | } | 1095 | } |
1114 | if (keyboard->seat_device->input_device->wlr_device->keyboard->group) { | 1096 | if (keyboard->wlr->group) { |
1115 | sway_keyboard_group_remove(keyboard); | 1097 | sway_keyboard_group_remove(keyboard); |
1116 | } | 1098 | } |
1117 | struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat; | 1099 | struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat; |
1118 | struct sway_input_device *device = keyboard->seat_device->input_device; | 1100 | if (wlr_seat_get_keyboard(wlr_seat) == keyboard->wlr) { |
1119 | if (wlr_seat_get_keyboard(wlr_seat) == device->wlr_device->keyboard) { | ||
1120 | wlr_seat_set_keyboard(wlr_seat, NULL); | 1101 | wlr_seat_set_keyboard(wlr_seat, NULL); |
1121 | } | 1102 | } |
1122 | if (keyboard->keymap) { | 1103 | if (keyboard->keymap) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index fe61e0fe..b21e1b86 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -142,7 +142,7 @@ static struct sway_keyboard *sway_keyboard_for_wlr_keyboard( | |||
142 | if (input_device->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) { | 142 | if (input_device->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) { |
143 | continue; | 143 | continue; |
144 | } | 144 | } |
145 | if (input_device->wlr_device->keyboard == wlr_keyboard) { | 145 | if (input_device->wlr_device == &wlr_keyboard->base) { |
146 | return seat_device->keyboard; | 146 | return seat_device->keyboard; |
147 | } | 147 | } |
148 | } | 148 | } |
@@ -150,7 +150,7 @@ static struct sway_keyboard *sway_keyboard_for_wlr_keyboard( | |||
150 | wl_list_for_each(group, &seat->keyboard_groups, link) { | 150 | wl_list_for_each(group, &seat->keyboard_groups, link) { |
151 | struct sway_input_device *input_device = | 151 | struct sway_input_device *input_device = |
152 | group->seat_device->input_device; | 152 | group->seat_device->input_device; |
153 | if (input_device->wlr_device->keyboard == wlr_keyboard) { | 153 | if (input_device->wlr_device == &wlr_keyboard->base) { |
154 | return group->seat_device->keyboard; | 154 | return group->seat_device->keyboard; |
155 | } | 155 | } |
156 | } | 156 | } |
@@ -745,10 +745,10 @@ static void seat_apply_input_config(struct sway_seat *seat, | |||
745 | struct wlr_input_device *dev = sway_device->input_device->wlr_device; | 745 | struct wlr_input_device *dev = sway_device->input_device->wlr_device; |
746 | switch (dev->type) { | 746 | switch (dev->type) { |
747 | case WLR_INPUT_DEVICE_POINTER: | 747 | case WLR_INPUT_DEVICE_POINTER: |
748 | mapped_to_output = dev->pointer->output_name; | 748 | mapped_to_output = wlr_pointer_from_input_device(dev)->output_name; |
749 | break; | 749 | break; |
750 | case WLR_INPUT_DEVICE_TOUCH: | 750 | case WLR_INPUT_DEVICE_TOUCH: |
751 | mapped_to_output = dev->touch->output_name; | 751 | mapped_to_output = wlr_touch_from_input_device(dev)->output_name; |
752 | break; | 752 | break; |
753 | default: | 753 | default: |
754 | mapped_to_output = NULL; | 754 | mapped_to_output = NULL; |
@@ -822,7 +822,7 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
822 | } | 822 | } |
823 | sway_keyboard_configure(seat_device->keyboard); | 823 | sway_keyboard_configure(seat_device->keyboard); |
824 | wlr_seat_set_keyboard(seat->wlr_seat, | 824 | wlr_seat_set_keyboard(seat->wlr_seat, |
825 | seat_device->input_device->wlr_device->keyboard); | 825 | wlr_keyboard_from_input_device(seat_device->input_device->wlr_device)); |
826 | 826 | ||
827 | // force notify reenter to pick up the new configuration. This reuses | 827 | // force notify reenter to pick up the new configuration. This reuses |
828 | // the current focused surface to avoid breaking input grabs. | 828 | // the current focused surface to avoid breaking input grabs. |
diff --git a/sway/input/switch.c b/sway/input/switch.c index ac4baece..fc7dfaff 100644 --- a/sway/input/switch.c +++ b/sway/input/switch.c | |||
@@ -11,6 +11,7 @@ struct sway_switch *sway_switch_create(struct sway_seat *seat, | |||
11 | return NULL; | 11 | return NULL; |
12 | } | 12 | } |
13 | device->switch_device = switch_device; | 13 | device->switch_device = switch_device; |
14 | switch_device->wlr = wlr_switch_from_input_device(device->input_device->wlr_device); | ||
14 | switch_device->seat_device = device; | 15 | switch_device->seat_device = device; |
15 | switch_device->state = WLR_SWITCH_STATE_OFF; | 16 | switch_device->state = WLR_SWITCH_STATE_OFF; |
16 | wl_list_init(&switch_device->switch_toggle.link); | 17 | wl_list_init(&switch_device->switch_toggle.link); |
@@ -95,10 +96,8 @@ static void handle_switch_toggle(struct wl_listener *listener, void *data) { | |||
95 | } | 96 | } |
96 | 97 | ||
97 | void sway_switch_configure(struct sway_switch *sway_switch) { | 98 | void sway_switch_configure(struct sway_switch *sway_switch) { |
98 | struct wlr_input_device *wlr_device = | ||
99 | sway_switch->seat_device->input_device->wlr_device; | ||
100 | wl_list_remove(&sway_switch->switch_toggle.link); | 99 | wl_list_remove(&sway_switch->switch_toggle.link); |
101 | wl_signal_add(&wlr_device->switch_device->events.toggle, | 100 | wl_signal_add(&sway_switch->wlr->events.toggle, |
102 | &sway_switch->switch_toggle); | 101 | &sway_switch->switch_toggle); |
103 | sway_switch->switch_toggle.notify = handle_switch_toggle; | 102 | sway_switch->switch_toggle.notify = handle_switch_toggle; |
104 | sway_log(SWAY_DEBUG, "Configured switch for device"); | 103 | sway_log(SWAY_DEBUG, "Configured switch for device"); |
diff --git a/sway/input/tablet.c b/sway/input/tablet.c index db2f93ec..92ede3fa 100644 --- a/sway/input/tablet.c +++ b/sway/input/tablet.c | |||
@@ -246,6 +246,7 @@ struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat, | |||
246 | return NULL; | 246 | return NULL; |
247 | } | 247 | } |
248 | 248 | ||
249 | tablet_pad->wlr = wlr_tablet_pad_from_input_device(device->input_device->wlr_device); | ||
249 | tablet_pad->seat_device = device; | 250 | tablet_pad->seat_device = device; |
250 | wl_list_init(&tablet_pad->attach.link); | 251 | wl_list_init(&tablet_pad->attach.link); |
251 | wl_list_init(&tablet_pad->button.link); | 252 | wl_list_init(&tablet_pad->button.link); |
@@ -260,40 +261,40 @@ struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat, | |||
260 | } | 261 | } |
261 | 262 | ||
262 | void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) { | 263 | void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) { |
263 | struct wlr_input_device *device = | 264 | struct wlr_input_device *wlr_device = |
264 | tablet_pad->seat_device->input_device->wlr_device; | 265 | tablet_pad->seat_device->input_device->wlr_device; |
265 | struct sway_seat *seat = tablet_pad->seat_device->sway_seat; | 266 | struct sway_seat *seat = tablet_pad->seat_device->sway_seat; |
266 | 267 | ||
267 | if (!tablet_pad->tablet_v2_pad) { | 268 | if (!tablet_pad->tablet_v2_pad) { |
268 | tablet_pad->tablet_v2_pad = | 269 | tablet_pad->tablet_v2_pad = |
269 | wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, device); | 270 | wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, wlr_device); |
270 | } | 271 | } |
271 | 272 | ||
272 | wl_list_remove(&tablet_pad->attach.link); | 273 | wl_list_remove(&tablet_pad->attach.link); |
273 | tablet_pad->attach.notify = handle_tablet_pad_attach; | 274 | tablet_pad->attach.notify = handle_tablet_pad_attach; |
274 | wl_signal_add(&device->tablet_pad->events.attach_tablet, | 275 | wl_signal_add(&tablet_pad->wlr->events.attach_tablet, |
275 | &tablet_pad->attach); | 276 | &tablet_pad->attach); |
276 | 277 | ||
277 | wl_list_remove(&tablet_pad->button.link); | 278 | wl_list_remove(&tablet_pad->button.link); |
278 | tablet_pad->button.notify = handle_tablet_pad_button; | 279 | tablet_pad->button.notify = handle_tablet_pad_button; |
279 | wl_signal_add(&device->tablet_pad->events.button, &tablet_pad->button); | 280 | wl_signal_add(&tablet_pad->wlr->events.button, &tablet_pad->button); |
280 | 281 | ||
281 | wl_list_remove(&tablet_pad->strip.link); | 282 | wl_list_remove(&tablet_pad->strip.link); |
282 | tablet_pad->strip.notify = handle_tablet_pad_strip; | 283 | tablet_pad->strip.notify = handle_tablet_pad_strip; |
283 | wl_signal_add(&device->tablet_pad->events.strip, &tablet_pad->strip); | 284 | wl_signal_add(&tablet_pad->wlr->events.strip, &tablet_pad->strip); |
284 | 285 | ||
285 | wl_list_remove(&tablet_pad->ring.link); | 286 | wl_list_remove(&tablet_pad->ring.link); |
286 | tablet_pad->ring.notify = handle_tablet_pad_ring; | 287 | tablet_pad->ring.notify = handle_tablet_pad_ring; |
287 | wl_signal_add(&device->tablet_pad->events.ring, &tablet_pad->ring); | 288 | wl_signal_add(&tablet_pad->wlr->events.ring, &tablet_pad->ring); |
288 | 289 | ||
289 | /* Search for a sibling tablet */ | 290 | /* Search for a sibling tablet */ |
290 | if (!wlr_input_device_is_libinput(device)) { | 291 | if (!wlr_input_device_is_libinput(wlr_device)) { |
291 | /* We can only do this on libinput devices */ | 292 | /* We can only do this on libinput devices */ |
292 | return; | 293 | return; |
293 | } | 294 | } |
294 | 295 | ||
295 | struct libinput_device_group *group = | 296 | struct libinput_device_group *group = |
296 | libinput_device_get_device_group(wlr_libinput_get_device_handle(device)); | 297 | libinput_device_get_device_group(wlr_libinput_get_device_handle(wlr_device)); |
297 | struct sway_tablet *tool; | 298 | struct sway_tablet *tool; |
298 | wl_list_for_each(tool, &seat->cursor->tablets, link) { | 299 | wl_list_for_each(tool, &seat->cursor->tablets, link) { |
299 | struct wlr_input_device *tablet = | 300 | struct wlr_input_device *tablet = |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index e682bc36..f52a5ecd 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -979,10 +979,11 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
979 | input_device_get_type(device))); | 979 | input_device_get_type(device))); |
980 | 980 | ||
981 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { | 981 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { |
982 | struct wlr_keyboard *keyboard = device->wlr_device->keyboard; | 982 | struct wlr_keyboard *keyboard = |
983 | wlr_keyboard_from_input_device(device->wlr_device); | ||
983 | struct xkb_keymap *keymap = keyboard->keymap; | 984 | struct xkb_keymap *keymap = keyboard->keymap; |
984 | struct xkb_state *state = keyboard->xkb_state; | 985 | struct xkb_state *state = keyboard->xkb_state; |
985 | 986 | ||
986 | json_object_object_add(object, "repeat_delay", | 987 | json_object_object_add(object, "repeat_delay", |
987 | json_object_new_int(keyboard->repeat_info.delay)); | 988 | json_object_new_int(keyboard->repeat_info.delay)); |
988 | json_object_object_add(object, "repeat_rate", | 989 | json_object_object_add(object, "repeat_rate", |
@@ -1012,11 +1013,11 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
1012 | if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { | 1013 | if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { |
1013 | struct input_config *ic = input_device_get_config(device); | 1014 | struct input_config *ic = input_device_get_config(device); |
1014 | float scroll_factor = 1.0f; | 1015 | float scroll_factor = 1.0f; |
1015 | if (ic != NULL && !isnan(ic->scroll_factor) && | 1016 | if (ic != NULL && !isnan(ic->scroll_factor) && |
1016 | ic->scroll_factor != FLT_MIN) { | 1017 | ic->scroll_factor != FLT_MIN) { |
1017 | scroll_factor = ic->scroll_factor; | 1018 | scroll_factor = ic->scroll_factor; |
1018 | } | 1019 | } |
1019 | json_object_object_add(object, "scroll_factor", | 1020 | json_object_object_add(object, "scroll_factor", |
1020 | json_object_new_double(scroll_factor)); | 1021 | json_object_new_double(scroll_factor)); |
1021 | } | 1022 | } |
1022 | 1023 | ||