aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-09 00:09:20 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-09 11:24:15 -0500
commit4696f49ecc69aa86ea6bd53fc08abf6a32b4a414 (patch)
tree67c4e3d792c49ac7fbf6311c8b0d842768d29bc4 /sway/input/input-manager.c
parentReset container dimensions when moving into workspace from direction (diff)
downloadsway-4696f49ecc69aa86ea6bd53fc08abf6a32b4a414.tar.gz
sway-4696f49ecc69aa86ea6bd53fc08abf6a32b4a414.tar.zst
sway-4696f49ecc69aa86ea6bd53fc08abf6a32b4a414.zip
reload: reset input configs
This resets all input options to their defaults on reload. This also fixes some debug log typos in `input_manager_libinput_config_pointer`.
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r--sway/input/input-manager.c172
1 files changed, 169 insertions, 3 deletions
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
132static 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
132static void input_manager_libinput_config_touch( 150static 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
172static 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
154static void input_manager_libinput_config_pointer( 190static 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
293static 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
257static void handle_device_destroy(struct wl_listener *listener, void *data) { 399static 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
611void 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
627void 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
469void input_manager_apply_seat_config(struct seat_config *seat_config) { 635void 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) {