diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-26 20:18:43 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-11-28 13:28:15 -0500 |
commit | e62299daa45de139b912325eb5800796586e57c7 (patch) | |
tree | 5a1972d97bd65000f8e328667f2a772c8622e9e8 /sway/input/input-manager.c | |
parent | Make session optional (diff) | |
download | sway-e62299daa45de139b912325eb5800796586e57c7.tar.gz sway-e62299daa45de139b912325eb5800796586e57c7.tar.zst sway-e62299daa45de139b912325eb5800796586e57c7.zip |
Make libinput backend optional
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r-- | sway/input/input-manager.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 26eefc8a..634d8981 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <math.h> | 5 | #include <math.h> |
6 | #include <wlr/backend/libinput.h> | 6 | #include <wlr/config.h> |
7 | #include <wlr/types/wlr_cursor.h> | 7 | #include <wlr/types/wlr_cursor.h> |
8 | #include <wlr/types/wlr_keyboard_group.h> | 8 | #include <wlr/types/wlr_keyboard_group.h> |
9 | #include <wlr/types/wlr_input_inhibitor.h> | 9 | #include <wlr/types/wlr_input_inhibitor.h> |
@@ -22,6 +22,10 @@ | |||
22 | #include "list.h" | 22 | #include "list.h" |
23 | #include "log.h" | 23 | #include "log.h" |
24 | 24 | ||
25 | #if WLR_HAS_LIBINPUT_BACKEND | ||
26 | #include <wlr/backend/libinput.h> | ||
27 | #endif | ||
28 | |||
25 | #define DEFAULT_SEAT "seat0" | 29 | #define DEFAULT_SEAT "seat0" |
26 | 30 | ||
27 | struct input_config *current_input_config = NULL; | 31 | struct input_config *current_input_config = NULL; |
@@ -90,6 +94,7 @@ char *input_device_get_identifier(struct wlr_input_device *device) { | |||
90 | } | 94 | } |
91 | 95 | ||
92 | static bool device_is_touchpad(struct sway_input_device *device) { | 96 | static bool device_is_touchpad(struct sway_input_device *device) { |
97 | #if WLR_HAS_LIBINPUT_BACKEND | ||
93 | if (device->wlr_device->type != WLR_INPUT_DEVICE_POINTER || | 98 | if (device->wlr_device->type != WLR_INPUT_DEVICE_POINTER || |
94 | !wlr_input_device_is_libinput(device->wlr_device)) { | 99 | !wlr_input_device_is_libinput(device->wlr_device)) { |
95 | return false; | 100 | return false; |
@@ -99,6 +104,9 @@ static bool device_is_touchpad(struct sway_input_device *device) { | |||
99 | wlr_libinput_get_device_handle(device->wlr_device); | 104 | wlr_libinput_get_device_handle(device->wlr_device); |
100 | 105 | ||
101 | return libinput_device_config_tap_get_finger_count(libinput_device) > 0; | 106 | return libinput_device_config_tap_get_finger_count(libinput_device) > 0; |
107 | #else | ||
108 | return false; | ||
109 | #endif | ||
102 | } | 110 | } |
103 | 111 | ||
104 | const char *input_device_get_type(struct sway_input_device *device) { | 112 | const char *input_device_get_type(struct sway_input_device *device) { |
@@ -236,7 +244,11 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
236 | 244 | ||
237 | apply_input_type_config(input_device); | 245 | apply_input_type_config(input_device); |
238 | 246 | ||
247 | #if WLR_HAS_LIBINPUT_BACKEND | ||
239 | bool config_changed = sway_input_configure_libinput_device(input_device); | 248 | bool config_changed = sway_input_configure_libinput_device(input_device); |
249 | #else | ||
250 | bool config_changed = false; | ||
251 | #endif | ||
240 | 252 | ||
241 | wl_signal_add(&device->events.destroy, &input_device->device_destroy); | 253 | wl_signal_add(&device->events.destroy, &input_device->device_destroy); |
242 | input_device->device_destroy.notify = handle_device_destroy; | 254 | input_device->device_destroy.notify = handle_device_destroy; |
@@ -532,7 +544,11 @@ static void retranslate_keysyms(struct input_config *input_config) { | |||
532 | 544 | ||
533 | static void input_manager_configure_input( | 545 | static void input_manager_configure_input( |
534 | struct sway_input_device *input_device) { | 546 | struct sway_input_device *input_device) { |
547 | #if WLR_HAS_LIBINPUT_BACKEND | ||
535 | bool config_changed = sway_input_configure_libinput_device(input_device); | 548 | bool config_changed = sway_input_configure_libinput_device(input_device); |
549 | #else | ||
550 | bool config_changed = false; | ||
551 | #endif | ||
536 | struct sway_seat *seat = NULL; | 552 | struct sway_seat *seat = NULL; |
537 | wl_list_for_each(seat, &server.input->seats, link) { | 553 | wl_list_for_each(seat, &server.input->seats, link) { |
538 | seat_configure_device(seat, input_device); | 554 | seat_configure_device(seat, input_device); |
@@ -567,7 +583,9 @@ void input_manager_apply_input_config(struct input_config *input_config) { | |||
567 | } | 583 | } |
568 | 584 | ||
569 | void input_manager_reset_input(struct sway_input_device *input_device) { | 585 | void input_manager_reset_input(struct sway_input_device *input_device) { |
586 | #if WLR_HAS_LIBINPUT_BACKEND | ||
570 | sway_input_reset_libinput_device(input_device); | 587 | sway_input_reset_libinput_device(input_device); |
588 | #endif | ||
571 | struct sway_seat *seat = NULL; | 589 | struct sway_seat *seat = NULL; |
572 | wl_list_for_each(seat, &server.input->seats, link) { | 590 | wl_list_for_each(seat, &server.input->seats, link) { |
573 | seat_reset_device(seat, input_device); | 591 | seat_reset_device(seat, input_device); |