diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h index 2c61e5a7..571d9e6f 100644 --- a/include/sway/input/keyboard.h +++ b/include/sway/input/keyboard.h @@ -50,6 +50,7 @@ struct sway_shortcut_state { struct sway_keyboard { struct sway_seat_device *seat_device; + struct wlr_keyboard *wlr; struct xkb_keymap *keymap; xkb_layout_index_t effective_layout; diff --git a/include/sway/input/switch.h b/include/sway/input/switch.h index 213b471d..de6787b7 100644 --- a/include/sway/input/switch.h +++ b/include/sway/input/switch.h @@ -5,6 +5,7 @@ struct sway_switch { struct sway_seat_device *seat_device; + struct wlr_switch *wlr; enum wlr_switch_state state; enum wlr_switch_type type; diff --git a/include/sway/input/tablet.h b/include/sway/input/tablet.h index d7e4c242..c0a5aff7 100644 --- a/include/sway/input/tablet.h +++ b/include/sway/input/tablet.h @@ -32,6 +32,7 @@ struct sway_tablet_pad { struct wl_list link; struct sway_seat_device *seat_device; struct sway_tablet *tablet; + struct wlr_tablet_pad *wlr; struct wlr_tablet_v2_tablet_pad *tablet_v2_pad; struct wl_listener attach; 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) { struct xkb_switch_layout_action *action = &actions[actions_len++]; - action->keyboard = dev->wlr_device->keyboard; + action->keyboard = wlr_keyboard_from_input_device(dev->wlr_device); if (relative) { - action->layout = get_layout_relative( - dev->wlr_device->keyboard, relative); + action->layout = get_layout_relative(action->keyboard, relative); } else { action->layout = layout; } 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, double y1 = region->y1, y2 = region->y2; 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) { return; } 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, static size_t keyboard_keysyms_translated(struct sway_keyboard *keyboard, xkb_keycode_t keycode, const xkb_keysym_t **keysyms, uint32_t *modifiers) { - struct wlr_input_device *device = - keyboard->seat_device->input_device->wlr_device; - *modifiers = wlr_keyboard_get_modifiers(device->keyboard); + *modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); 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; - return xkb_state_key_get_syms(device->keyboard->xkb_state, + return xkb_state_key_get_syms(keyboard->wlr->xkb_state, 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, xkb_keycode_t keycode, const xkb_keysym_t **keysyms, uint32_t *modifiers) { - struct wlr_input_device *device = - keyboard->seat_device->input_device->wlr_device; - *modifiers = wlr_keyboard_get_modifiers(device->keyboard); + *modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); xkb_layout_index_t layout_index = xkb_state_key_get_layout( - device->keyboard->xkb_state, keycode); - return xkb_keymap_key_get_syms_by_level(device->keyboard->keymap, + keyboard->wlr->xkb_state, keycode); + return xkb_keymap_key_get_syms_by_level(keyboard->wlr->keymap, keycode, layout_index, 0, keysyms); } @@ -360,8 +356,7 @@ static void update_keyboard_state(struct sway_keyboard *keyboard, keyinfo->keycode, &keyinfo->translated_keysyms, &keyinfo->translated_modifiers); - keyinfo->code_modifiers = wlr_keyboard_get_modifiers( - keyboard->seat_device->input_device->wlr_device->keyboard); + keyinfo->code_modifiers = wlr_keyboard_get_modifiers(keyboard->wlr); // Update shortcut model keyinfo 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 = keyboard->seat_device->input_device->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); bool input_inhibited = seat->exclusive_client != NULL || 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 // binding may remove the keyboard, the timer needs to be updated first if (binding && !(binding->flags & BINDING_NOREPEAT) && - wlr_device->keyboard->repeat_info.delay > 0) { + keyboard->wlr->repeat_info.delay > 0) { keyboard->repeat_binding = binding; 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"); } } else if (keyboard->repeat_binding) { @@ -493,7 +488,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, handled = true; } - if (!handled && wlr_device->keyboard->group) { + if (!handled && keyboard->wlr->group) { // Only handle device specific bindings for keyboards in a group free(device_identifier); return; @@ -518,7 +513,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, &keyboard->state_pressed_sent, event->keycode, event->state, keyinfo.keycode, 0); 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, event->keycode, event->state); 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); if (kb_grab) { - wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, - wlr_device->keyboard); + wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, keyboard->wlr); wlr_input_method_keyboard_grab_v2_send_key(kb_grab, event->time_msec, event->keycode, event->state); handled = true; @@ -543,7 +537,7 @@ static void handle_key_event(struct sway_keyboard *keyboard, update_shortcut_state( &keyboard->state_pressed_sent, event->keycode, event->state, 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, 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) { - struct sway_keyboard *keyboard = (struct sway_keyboard *)data; - struct wlr_keyboard *wlr_device = - keyboard->seat_device->input_device->wlr_device->keyboard; + struct sway_keyboard *keyboard = data; 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 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"); } } @@ -659,31 +651,28 @@ static void determine_bar_visibility(uint32_t modifiers) { } static void handle_modifier_event(struct sway_keyboard *keyboard) { - struct wlr_input_device *wlr_device = - keyboard->seat_device->input_device->wlr_device; - if (!wlr_device->keyboard->group) { + if (!keyboard->wlr->group) { struct wlr_input_method_keyboard_grab_v2 *kb_grab = keyboard_get_im_grab(keyboard); if (kb_grab) { - wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, - wlr_device->keyboard); + wlr_input_method_keyboard_grab_v2_set_keyboard(kb_grab, keyboard->wlr); wlr_input_method_keyboard_grab_v2_send_modifiers(kb_grab, - &wlr_device->keyboard->modifiers); + &keyboard->wlr->modifiers); } else { 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_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); } - if (wlr_device->keyboard->modifiers.group != keyboard->effective_layout) { - keyboard->effective_layout = wlr_device->keyboard->modifiers.group; + if (keyboard->wlr->modifiers.group != keyboard->effective_layout) { + 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); } } @@ -712,6 +701,7 @@ struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, } keyboard->seat_device = device; + keyboard->wlr = wlr_keyboard_from_input_device(device->input_device->wlr_device); device->keyboard = keyboard; 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) { 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 = wlr_keyboard->group; + struct wlr_keyboard_group *wlr_group = keyboard->wlr->group; sway_log(SWAY_DEBUG, "Removing keyboard %s from group %p", 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)) { 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) { - struct sway_input_device *device = keyboard->seat_device->input_device; - struct wlr_keyboard *wlr_keyboard = device->wlr_device->keyboard; - if (!wlr_keyboard->group) { + if (!keyboard->wlr->group) { return; } @@ -869,7 +856,7 @@ static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) { break; case KEYBOARD_GROUP_DEFAULT: /* fallthrough */ 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) || !repeat_info_match(keyboard, &group->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) { 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 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)) { sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p", device->identifier, wlr_group); - wlr_keyboard_group_add_keyboard(wlr_group, wlr_keyboard); + wlr_keyboard_group_add_keyboard(wlr_group, keyboard->wlr); return; } 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", 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); @@ -992,10 +978,8 @@ cleanup: void sway_keyboard_configure(struct sway_keyboard *keyboard) { struct input_config *input_config = 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 " "keyboard group's keyboard")) { return; @@ -1037,11 +1021,11 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { sway_keyboard_group_remove_invalid(keyboard); - wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap); - wlr_keyboard_set_repeat_info(wlr_device->keyboard, + wlr_keyboard_set_keymap(keyboard->wlr, keyboard->keymap); + wlr_keyboard_set_repeat_info(keyboard->wlr, keyboard->repeat_rate, keyboard->repeat_delay); - if (!wlr_device->keyboard->group) { + if (!keyboard->wlr->group) { sway_keyboard_group_add(keyboard); } @@ -1061,40 +1045,38 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { } } if (locked_mods) { - wlr_keyboard_notify_modifiers(wlr_device->keyboard, 0, 0, + wlr_keyboard_notify_modifiers(keyboard->wlr, 0, 0, locked_mods, 0); uint32_t leds = 0; for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) { - if (xkb_state_led_index_is_active( - wlr_device->keyboard->xkb_state, - wlr_device->keyboard->led_indexes[i])) { + if (xkb_state_led_index_is_active(keyboard->wlr->xkb_state, + keyboard->wlr->led_indexes[i])) { leds |= (1 << i); } } - if (wlr_device->keyboard->group) { - wlr_keyboard_led_update( - &wlr_device->keyboard->group->keyboard, leds); + if (keyboard->wlr->group) { + wlr_keyboard_led_update(&keyboard->wlr->group->keyboard, leds); } else { - wlr_keyboard_led_update(wlr_device->keyboard, leds); + wlr_keyboard_led_update(keyboard->wlr, leds); } } } else { xkb_keymap_unref(keymap); sway_keyboard_group_remove_invalid(keyboard); - if (!wlr_device->keyboard->group) { + if (!keyboard->wlr->group) { sway_keyboard_group_add(keyboard); } } 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_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; 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.notify = handle_keyboard_modifiers; @@ -1111,12 +1093,11 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) { if (!keyboard) { return; } - if (keyboard->seat_device->input_device->wlr_device->keyboard->group) { + if (keyboard->wlr->group) { sway_keyboard_group_remove(keyboard); } 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) == device->wlr_device->keyboard) { + if (wlr_seat_get_keyboard(wlr_seat) == keyboard->wlr) { wlr_seat_set_keyboard(wlr_seat, NULL); } 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( if (input_device->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) { continue; } - if (input_device->wlr_device->keyboard == wlr_keyboard) { + if (input_device->wlr_device == &wlr_keyboard->base) { 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) { struct sway_input_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; } } @@ -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; switch (dev->type) { case WLR_INPUT_DEVICE_POINTER: - mapped_to_output = dev->pointer->output_name; + mapped_to_output = wlr_pointer_from_input_device(dev)->output_name; break; case WLR_INPUT_DEVICE_TOUCH: - mapped_to_output = dev->touch->output_name; + mapped_to_output = wlr_touch_from_input_device(dev)->output_name; break; default: mapped_to_output = NULL; @@ -822,7 +822,7 @@ static void seat_configure_keyboard(struct sway_seat *seat, } sway_keyboard_configure(seat_device->keyboard); 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 // 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, return NULL; } 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->state = WLR_SWITCH_STATE_OFF; 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) { - struct wlr_input_device *wlr_device = - sway_switch->seat_device->input_device->wlr_device; 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.notify = handle_switch_toggle; 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, return NULL; } + tablet_pad->wlr = wlr_tablet_pad_from_input_device(device->input_device->wlr_device); tablet_pad->seat_device = device; wl_list_init(&tablet_pad->attach.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) { - struct wlr_input_device *device = + struct wlr_input_device *wlr_device = tablet_pad->seat_device->input_device->wlr_device; struct sway_seat *seat = tablet_pad->seat_device->sway_seat; if (!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); 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); wl_list_remove(&tablet_pad->button.link); 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); 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); 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 */ - if (!wlr_input_device_is_libinput(device)) { + if (!wlr_input_device_is_libinput(wlr_device)) { /* We can only do this on libinput devices */ return; } 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; wl_list_for_each(tool, &seat->cursor->tablets, link) { 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) { input_device_get_type(device))); 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_state *state = keyboard->xkb_state; - + json_object_object_add(object, "repeat_delay", json_object_new_int(keyboard->repeat_info.delay)); json_object_object_add(object, "repeat_rate", @@ -1012,11 +1013,11 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { struct input_config *ic = input_device_get_config(device); float scroll_factor = 1.0f; - if (ic != NULL && !isnan(ic->scroll_factor) && + if (ic != NULL && !isnan(ic->scroll_factor) && ic->scroll_factor != FLT_MIN) { scroll_factor = ic->scroll_factor; } - json_object_object_add(object, "scroll_factor", + json_object_object_add(object, "scroll_factor", json_object_new_double(scroll_factor)); }