diff options
-rw-r--r-- | include/sway/input/input-manager.h | 4 | ||||
-rw-r--r-- | include/sway/input/seat.h | 3 | ||||
-rw-r--r-- | sway/config.c | 2 | ||||
-rw-r--r-- | sway/input/input-manager.c | 172 | ||||
-rw-r--r-- | sway/input/seat.c | 37 |
5 files changed, 215 insertions, 3 deletions
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 08e749dc..8e8bf1f2 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h | |||
@@ -37,6 +37,10 @@ void input_manager_configure_xcursor(void); | |||
37 | 37 | ||
38 | void input_manager_apply_input_config(struct input_config *input_config); | 38 | void input_manager_apply_input_config(struct input_config *input_config); |
39 | 39 | ||
40 | void input_manager_reset_input(struct sway_input_device *input_device); | ||
41 | |||
42 | void input_manager_reset_all_inputs(); | ||
43 | |||
40 | void input_manager_apply_seat_config(struct seat_config *seat_config); | 44 | void input_manager_apply_seat_config(struct seat_config *seat_config); |
41 | 45 | ||
42 | struct sway_seat *input_manager_get_default_seat(void); | 46 | struct sway_seat *input_manager_get_default_seat(void); |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index a3c20346..c10b48b1 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -100,6 +100,9 @@ void seat_add_device(struct sway_seat *seat, | |||
100 | void seat_configure_device(struct sway_seat *seat, | 100 | void seat_configure_device(struct sway_seat *seat, |
101 | struct sway_input_device *device); | 101 | struct sway_input_device *device); |
102 | 102 | ||
103 | void seat_reset_device(struct sway_seat *seat, | ||
104 | struct sway_input_device *input_device); | ||
105 | |||
103 | void seat_remove_device(struct sway_seat *seat, | 106 | void seat_remove_device(struct sway_seat *seat, |
104 | struct sway_input_device *device); | 107 | struct sway_input_device *device); |
105 | 108 | ||
diff --git a/sway/config.c b/sway/config.c index f99f043c..cd0857f4 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -387,6 +387,8 @@ bool load_main_config(const char *file, bool is_active, bool validating) { | |||
387 | memcpy(&config->swaynag_config_errors, | 387 | memcpy(&config->swaynag_config_errors, |
388 | &old_config->swaynag_config_errors, | 388 | &old_config->swaynag_config_errors, |
389 | sizeof(struct swaynag_instance)); | 389 | sizeof(struct swaynag_instance)); |
390 | |||
391 | input_manager_reset_all_inputs(); | ||
390 | } | 392 | } |
391 | 393 | ||
392 | config->current_config_path = path; | 394 | config->current_config_path = path; |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 04e14355..d90803f6 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -129,6 +129,24 @@ static void input_manager_libinput_config_keyboard( | |||
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | static void input_manager_libinput_reset_keyboard( | ||
133 | struct sway_input_device *input_device) { | ||
134 | struct wlr_input_device *wlr_device = input_device->wlr_device; | ||
135 | struct libinput_device *libinput_device; | ||
136 | |||
137 | if (!wlr_input_device_is_libinput(wlr_device)) { | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | libinput_device = wlr_libinput_get_device_handle(wlr_device); | ||
142 | |||
143 | uint32_t send_events = | ||
144 | libinput_device_config_send_events_get_default_mode(libinput_device); | ||
145 | wlr_log(WLR_DEBUG, "libinput_reset_keyboard(%s) send_events_set_mode(%d)", | ||
146 | input_device->identifier, send_events); | ||
147 | libinput_device_config_send_events_set_mode(libinput_device, send_events); | ||
148 | } | ||
149 | |||
132 | static void input_manager_libinput_config_touch( | 150 | static void input_manager_libinput_config_touch( |
133 | struct sway_input_device *input_device) { | 151 | struct sway_input_device *input_device) { |
134 | struct wlr_input_device *wlr_device = input_device->wlr_device; | 152 | struct wlr_input_device *wlr_device = input_device->wlr_device; |
@@ -151,6 +169,24 @@ static void input_manager_libinput_config_touch( | |||
151 | } | 169 | } |
152 | } | 170 | } |
153 | 171 | ||
172 | static void input_manager_libinput_reset_touch( | ||
173 | struct sway_input_device *input_device) { | ||
174 | struct wlr_input_device *wlr_device = input_device->wlr_device; | ||
175 | struct libinput_device *libinput_device; | ||
176 | |||
177 | if (!wlr_input_device_is_libinput(wlr_device)) { | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | libinput_device = wlr_libinput_get_device_handle(wlr_device); | ||
182 | |||
183 | uint32_t send_events = | ||
184 | libinput_device_config_send_events_get_default_mode(libinput_device); | ||
185 | wlr_log(WLR_DEBUG, "libinput_reset_touch(%s) send_events_set_mode(%d)", | ||
186 | input_device->identifier, send_events); | ||
187 | libinput_device_config_send_events_set_mode(libinput_device, send_events); | ||
188 | } | ||
189 | |||
154 | static void input_manager_libinput_config_pointer( | 190 | static void input_manager_libinput_config_pointer( |
155 | struct sway_input_device *input_device) { | 191 | struct sway_input_device *input_device) { |
156 | struct wlr_input_device *wlr_device = input_device->wlr_device; | 192 | struct wlr_input_device *wlr_device = input_device->wlr_device; |
@@ -180,14 +216,14 @@ static void input_manager_libinput_config_pointer( | |||
180 | if (ic->drag != INT_MIN) { | 216 | if (ic->drag != INT_MIN) { |
181 | wlr_log(WLR_DEBUG, | 217 | wlr_log(WLR_DEBUG, |
182 | "libinput_config_pointer(%s) tap_set_drag_enabled(%d)", | 218 | "libinput_config_pointer(%s) tap_set_drag_enabled(%d)", |
183 | ic->identifier, ic->click_method); | 219 | ic->identifier, ic->drag); |
184 | libinput_device_config_tap_set_drag_enabled(libinput_device, | 220 | libinput_device_config_tap_set_drag_enabled(libinput_device, |
185 | ic->drag); | 221 | ic->drag); |
186 | } | 222 | } |
187 | if (ic->drag_lock != INT_MIN) { | 223 | if (ic->drag_lock != INT_MIN) { |
188 | wlr_log(WLR_DEBUG, | 224 | wlr_log(WLR_DEBUG, |
189 | "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", | 225 | "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", |
190 | ic->identifier, ic->click_method); | 226 | ic->identifier, ic->drag_lock); |
191 | libinput_device_config_tap_set_drag_lock_enabled(libinput_device, | 227 | libinput_device_config_tap_set_drag_lock_enabled(libinput_device, |
192 | ic->drag_lock); | 228 | ic->drag_lock); |
193 | } | 229 | } |
@@ -248,12 +284,118 @@ static void input_manager_libinput_config_pointer( | |||
248 | } | 284 | } |
249 | if (ic->tap_button_map != INT_MIN) { | 285 | if (ic->tap_button_map != INT_MIN) { |
250 | wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_button_map(%d)", | 286 | wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_button_map(%d)", |
251 | ic->identifier, ic->tap); | 287 | ic->identifier, ic->tap_button_map); |
252 | libinput_device_config_tap_set_button_map(libinput_device, | 288 | libinput_device_config_tap_set_button_map(libinput_device, |
253 | ic->tap_button_map); | 289 | ic->tap_button_map); |
254 | } | 290 | } |
255 | } | 291 | } |
256 | 292 | ||
293 | static void input_manager_libinput_reset_pointer( | ||
294 | struct sway_input_device *input_device) { | ||
295 | struct wlr_input_device *wlr_device = input_device->wlr_device; | ||
296 | |||
297 | if (!wlr_input_device_is_libinput(wlr_device)) { | ||
298 | return; | ||
299 | } | ||
300 | |||
301 | struct libinput_device *libinput_device = | ||
302 | wlr_libinput_get_device_handle(wlr_device); | ||
303 | |||
304 | enum libinput_config_accel_profile accel_profile = | ||
305 | libinput_device_config_accel_get_default_profile(libinput_device); | ||
306 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) accel_set_profile(%d)", | ||
307 | input_device->identifier, accel_profile); | ||
308 | libinput_device_config_accel_set_profile(libinput_device, accel_profile); | ||
309 | |||
310 | enum libinput_config_click_method click_method = | ||
311 | libinput_device_config_click_get_default_method(libinput_device); | ||
312 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) click_set_method(%d)", | ||
313 | input_device->identifier, click_method); | ||
314 | libinput_device_config_click_set_method(libinput_device, click_method); | ||
315 | |||
316 | enum libinput_config_drag_state drag = | ||
317 | libinput_device_config_tap_get_default_drag_enabled(libinput_device); | ||
318 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) tap_set_drag_enabled(%d)", | ||
319 | input_device->identifier, drag); | ||
320 | libinput_device_config_tap_set_drag_enabled(libinput_device, drag); | ||
321 | |||
322 | enum libinput_config_drag_lock_state drag_lock = | ||
323 | libinput_device_config_tap_get_default_drag_lock_enabled( | ||
324 | libinput_device); | ||
325 | wlr_log(WLR_DEBUG, | ||
326 | "libinput_reset_pointer(%s) tap_set_drag_lock_enabled(%d)", | ||
327 | input_device->identifier, drag_lock); | ||
328 | libinput_device_config_tap_set_drag_lock_enabled(libinput_device, | ||
329 | drag_lock); | ||
330 | |||
331 | enum libinput_config_dwt_state dwt = | ||
332 | libinput_device_config_dwt_get_default_enabled(libinput_device); | ||
333 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) dwt_set_enabled(%d)", | ||
334 | input_device->identifier, dwt); | ||
335 | libinput_device_config_dwt_set_enabled(libinput_device, dwt); | ||
336 | |||
337 | int left_handed = | ||
338 | libinput_device_config_left_handed_get_default(libinput_device); | ||
339 | wlr_log(WLR_DEBUG, | ||
340 | "libinput_reset_pointer(%s) left_handed_set_enabled(%d)", | ||
341 | input_device->identifier, left_handed); | ||
342 | libinput_device_config_left_handed_set(libinput_device, left_handed); | ||
343 | |||
344 | enum libinput_config_middle_emulation_state middle_emulation = | ||
345 | libinput_device_config_middle_emulation_get_default_enabled( | ||
346 | libinput_device); | ||
347 | wlr_log(WLR_DEBUG, | ||
348 | "libinput_reset_pointer(%s) middle_emulation_set_enabled(%d)", | ||
349 | input_device->identifier, middle_emulation); | ||
350 | libinput_device_config_middle_emulation_set_enabled(libinput_device, | ||
351 | middle_emulation); | ||
352 | |||
353 | int natural_scroll = | ||
354 | libinput_device_config_scroll_get_default_natural_scroll_enabled( | ||
355 | libinput_device); | ||
356 | wlr_log(WLR_DEBUG, | ||
357 | "libinput_reset_pointer(%s) natural_scroll_set_enabled(%d)", | ||
358 | input_device->identifier, natural_scroll); | ||
359 | libinput_device_config_scroll_set_natural_scroll_enabled( | ||
360 | libinput_device, natural_scroll); | ||
361 | |||
362 | double pointer_accel = | ||
363 | libinput_device_config_accel_get_default_speed(libinput_device); | ||
364 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) accel_set_speed(%f)", | ||
365 | input_device->identifier, pointer_accel); | ||
366 | libinput_device_config_accel_set_speed(libinput_device, pointer_accel); | ||
367 | |||
368 | uint32_t scroll_button = | ||
369 | libinput_device_config_scroll_get_default_button(libinput_device); | ||
370 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) scroll_set_button(%d)", | ||
371 | input_device->identifier, scroll_button); | ||
372 | libinput_device_config_scroll_set_button(libinput_device, scroll_button); | ||
373 | |||
374 | enum libinput_config_scroll_method scroll_method = | ||
375 | libinput_device_config_scroll_get_default_method(libinput_device); | ||
376 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) scroll_set_method(%d)", | ||
377 | input_device->identifier, scroll_method); | ||
378 | libinput_device_config_scroll_set_method(libinput_device, scroll_method); | ||
379 | |||
380 | uint32_t send_events = | ||
381 | libinput_device_config_send_events_get_default_mode(libinput_device); | ||
382 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) send_events_set_mode(%d)", | ||
383 | input_device->identifier, send_events); | ||
384 | libinput_device_config_send_events_set_mode(libinput_device, send_events); | ||
385 | |||
386 | enum libinput_config_tap_state tap = | ||
387 | libinput_device_config_tap_get_default_enabled(libinput_device); | ||
388 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) tap_set_enabled(%d)", | ||
389 | input_device->identifier, tap); | ||
390 | libinput_device_config_tap_set_enabled(libinput_device, tap); | ||
391 | |||
392 | enum libinput_config_tap_button_map tap_button_map = | ||
393 | libinput_device_config_tap_get_button_map(libinput_device); | ||
394 | wlr_log(WLR_DEBUG, "libinput_reset_pointer(%s) tap_set_button_map(%d)", | ||
395 | input_device->identifier, tap_button_map); | ||
396 | libinput_device_config_tap_set_button_map(libinput_device, tap_button_map); | ||
397 | } | ||
398 | |||
257 | static void handle_device_destroy(struct wl_listener *listener, void *data) { | 399 | static void handle_device_destroy(struct wl_listener *listener, void *data) { |
258 | struct wlr_input_device *device = data; | 400 | struct wlr_input_device *device = data; |
259 | 401 | ||
@@ -466,6 +608,30 @@ void input_manager_apply_input_config(struct input_config *input_config) { | |||
466 | } | 608 | } |
467 | } | 609 | } |
468 | 610 | ||
611 | void input_manager_reset_input(struct sway_input_device *input_device) { | ||
612 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER || | ||
613 | input_device->wlr_device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { | ||
614 | input_manager_libinput_reset_pointer(input_device); | ||
615 | } else if (input_device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { | ||
616 | input_manager_libinput_reset_keyboard(input_device); | ||
617 | } else if (input_device->wlr_device->type == WLR_INPUT_DEVICE_TOUCH) { | ||
618 | input_manager_libinput_reset_touch(input_device); | ||
619 | } | ||
620 | |||
621 | struct sway_seat *seat = NULL; | ||
622 | wl_list_for_each(seat, &server.input->seats, link) { | ||
623 | seat_reset_device(seat, input_device); | ||
624 | } | ||
625 | } | ||
626 | |||
627 | void input_manager_reset_all_inputs() { | ||
628 | struct sway_input_device *input_device = NULL; | ||
629 | wl_list_for_each(input_device, &server.input->devices, link) { | ||
630 | input_manager_reset_input(input_device); | ||
631 | } | ||
632 | } | ||
633 | |||
634 | |||
469 | void input_manager_apply_seat_config(struct seat_config *seat_config) { | 635 | void input_manager_apply_seat_config(struct seat_config *seat_config) { |
470 | wlr_log(WLR_DEBUG, "applying seat config for seat %s", seat_config->name); | 636 | wlr_log(WLR_DEBUG, "applying seat config for seat %s", seat_config->name); |
471 | if (strcmp(seat_config->name, "*") == 0) { | 637 | if (strcmp(seat_config->name, "*") == 0) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index a8df5b99..09acab0d 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -405,6 +405,14 @@ static void seat_update_capabilities(struct sway_seat *seat) { | |||
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | static void seat_reset_input_config(struct sway_seat *seat, | ||
409 | struct sway_seat_device *sway_device) { | ||
410 | wlr_log(WLR_DEBUG, "Resetting output mapping for input device %s", | ||
411 | sway_device->input_device->identifier); | ||
412 | wlr_cursor_map_input_to_output(seat->cursor->cursor, | ||
413 | sway_device->input_device->wlr_device, NULL); | ||
414 | } | ||
415 | |||
408 | static void seat_apply_input_config(struct sway_seat *seat, | 416 | static void seat_apply_input_config(struct sway_seat *seat, |
409 | struct sway_seat_device *sway_device) { | 417 | struct sway_seat_device *sway_device) { |
410 | const char *mapped_to_output = NULL; | 418 | const char *mapped_to_output = NULL; |
@@ -522,6 +530,35 @@ void seat_configure_device(struct sway_seat *seat, | |||
522 | } | 530 | } |
523 | } | 531 | } |
524 | 532 | ||
533 | void seat_reset_device(struct sway_seat *seat, | ||
534 | struct sway_input_device *input_device) { | ||
535 | struct sway_seat_device *seat_device = seat_get_device(seat, input_device); | ||
536 | if (!seat_device) { | ||
537 | return; | ||
538 | } | ||
539 | |||
540 | switch (input_device->wlr_device->type) { | ||
541 | case WLR_INPUT_DEVICE_POINTER: | ||
542 | seat_reset_input_config(seat, seat_device); | ||
543 | break; | ||
544 | case WLR_INPUT_DEVICE_KEYBOARD: | ||
545 | sway_keyboard_configure(seat_device->keyboard); | ||
546 | break; | ||
547 | case WLR_INPUT_DEVICE_TOUCH: | ||
548 | seat_reset_input_config(seat, seat_device); | ||
549 | break; | ||
550 | case WLR_INPUT_DEVICE_TABLET_TOOL: | ||
551 | seat_reset_input_config(seat, seat_device); | ||
552 | break; | ||
553 | case WLR_INPUT_DEVICE_TABLET_PAD: | ||
554 | wlr_log(WLR_DEBUG, "TODO: reset tablet pad"); | ||
555 | break; | ||
556 | case WLR_INPUT_DEVICE_SWITCH: | ||
557 | wlr_log(WLR_DEBUG, "TODO: reset switch device"); | ||
558 | break; | ||
559 | } | ||
560 | } | ||
561 | |||
525 | void seat_add_device(struct sway_seat *seat, | 562 | void seat_add_device(struct sway_seat *seat, |
526 | struct sway_input_device *input_device) { | 563 | struct sway_input_device *input_device) { |
527 | if (seat_get_device(seat, input_device)) { | 564 | if (seat_get_device(seat, input_device)) { |