aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2022-11-26 20:18:43 +0100
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2022-11-28 13:28:15 -0500
commite62299daa45de139b912325eb5800796586e57c7 (patch)
tree5a1972d97bd65000f8e328667f2a772c8622e9e8
parentMake session optional (diff)
downloadsway-e62299daa45de139b912325eb5800796586e57c7.tar.gz
sway-e62299daa45de139b912325eb5800796586e57c7.tar.zst
sway-e62299daa45de139b912325eb5800796586e57c7.zip
Make libinput backend optional
-rw-r--r--meson.build4
-rw-r--r--sway/commands/input/events.c10
-rw-r--r--sway/input/input-manager.c20
-rw-r--r--sway/input/seat.c6
-rw-r--r--sway/input/tablet.c10
-rw-r--r--sway/ipc-json.c10
-rw-r--r--sway/meson.build7
7 files changed, 59 insertions, 8 deletions
diff --git a/meson.build b/meson.build
index 5468064f..20ed8424 100644
--- a/meson.build
+++ b/meson.build
@@ -76,11 +76,11 @@ gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
76pixman = dependency('pixman-1') 76pixman = dependency('pixman-1')
77glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep 77glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep
78libevdev = dependency('libevdev') 78libevdev = dependency('libevdev')
79libinput = dependency('libinput', version: '>=1.21.0') 79libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
80xcb = dependency('xcb', required: get_option('xwayland')) 80xcb = dependency('xcb', required: get_option('xwayland'))
81drm_full = dependency('libdrm') # only needed for drm_fourcc.h 81drm_full = dependency('libdrm') # only needed for drm_fourcc.h
82drm = drm_full.partial_dependency(compile_args: true, includes: true) 82drm = drm_full.partial_dependency(compile_args: true, includes: true)
83libudev = dependency('libudev') 83libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep
84bash_comp = dependency('bash-completion', required: false) 84bash_comp = dependency('bash-completion', required: false)
85fish_comp = dependency('fish', required: false) 85fish_comp = dependency('fish', required: false)
86math = cc.find_library('m') 86math = cc.find_library('m')
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index 9405181a..08d99bf0 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -1,14 +1,19 @@
1#include <limits.h> 1#include <limits.h>
2#include <string.h> 2#include <string.h>
3#include <strings.h> 3#include <strings.h>
4#include <wlr/backend/libinput.h> 4#include <wlr/config.h>
5#include "sway/config.h" 5#include "sway/config.h"
6#include "sway/commands.h" 6#include "sway/commands.h"
7#include "sway/input/input-manager.h" 7#include "sway/input/input-manager.h"
8#include "log.h" 8#include "log.h"
9 9
10#if WLR_HAS_LIBINPUT_BACKEND
11#include <wlr/backend/libinput.h>
12#endif
13
10static void toggle_supported_send_events_for_device(struct input_config *ic, 14static void toggle_supported_send_events_for_device(struct input_config *ic,
11 struct sway_input_device *input_device) { 15 struct sway_input_device *input_device) {
16#if WLR_HAS_LIBINPUT_BACKEND
12 struct wlr_input_device *wlr_device = input_device->wlr_device; 17 struct wlr_input_device *wlr_device = input_device->wlr_device;
13 if (!wlr_input_device_is_libinput(wlr_device)) { 18 if (!wlr_input_device_is_libinput(wlr_device)) {
14 return; 19 return;
@@ -41,6 +46,7 @@ static void toggle_supported_send_events_for_device(struct input_config *ic,
41 } 46 }
42 47
43 ic->send_events = mode; 48 ic->send_events = mode;
49#endif
44} 50}
45 51
46static int mode_for_name(const char *name) { 52static int mode_for_name(const char *name) {
@@ -56,6 +62,7 @@ static int mode_for_name(const char *name) {
56 62
57static void toggle_select_send_events_for_device(struct input_config *ic, 63static void toggle_select_send_events_for_device(struct input_config *ic,
58 struct sway_input_device *input_device, int argc, char **argv) { 64 struct sway_input_device *input_device, int argc, char **argv) {
65#if WLR_HAS_LIBINPUT_BACKEND
59 if (!wlr_input_device_is_libinput(input_device->wlr_device)) { 66 if (!wlr_input_device_is_libinput(input_device->wlr_device)) {
60 return; 67 return;
61 } 68 }
@@ -72,6 +79,7 @@ static void toggle_select_send_events_for_device(struct input_config *ic,
72 } 79 }
73 } 80 }
74 ic->send_events = mode_for_name(argv[index % argc]); 81 ic->send_events = mode_for_name(argv[index % argc]);
82#endif
75} 83}
76 84
77static void toggle_send_events(int argc, char **argv) { 85static void toggle_send_events(int argc, char **argv) {
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
27struct input_config *current_input_config = NULL; 31struct input_config *current_input_config = NULL;
@@ -90,6 +94,7 @@ char *input_device_get_identifier(struct wlr_input_device *device) {
90} 94}
91 95
92static bool device_is_touchpad(struct sway_input_device *device) { 96static 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
104const char *input_device_get_type(struct sway_input_device *device) { 112const 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
533static void input_manager_configure_input( 545static 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
569void input_manager_reset_input(struct sway_input_device *input_device) { 585void 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);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index c263eb82..4919bed0 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -4,6 +4,7 @@
4#include <string.h> 4#include <string.h>
5#include <strings.h> 5#include <strings.h>
6#include <time.h> 6#include <time.h>
7#include <wlr/config.h>
7#include <wlr/types/wlr_cursor.h> 8#include <wlr/types/wlr_cursor.h>
8#include <wlr/types/wlr_data_device.h> 9#include <wlr/types/wlr_data_device.h>
9#include <wlr/types/wlr_idle.h> 10#include <wlr/types/wlr_idle.h>
@@ -750,6 +751,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
750 mapped_to_output = NULL; 751 mapped_to_output = NULL;
751 break; 752 break;
752 } 753 }
754#if WLR_HAS_LIBINPUT_BACKEND
753 if (mapped_to_output == NULL && is_touch_or_tablet_tool(sway_device) && 755 if (mapped_to_output == NULL && is_touch_or_tablet_tool(sway_device) &&
754 sway_libinput_device_is_builtin(sway_device->input_device)) { 756 sway_libinput_device_is_builtin(sway_device->input_device)) {
755 mapped_to_output = get_builtin_output_name(); 757 mapped_to_output = get_builtin_output_name();
@@ -758,6 +760,10 @@ static void seat_apply_input_config(struct sway_seat *seat,
758 mapped_to_output, sway_device->input_device->identifier); 760 mapped_to_output, sway_device->input_device->identifier);
759 } 761 }
760 } 762 }
763#else
764 (void)is_touch_or_tablet_tool;
765 (void)get_builtin_output_name;
766#endif
761 if (mapped_to_output == NULL) { 767 if (mapped_to_output == NULL) {
762 return; 768 return;
763 } 769 }
diff --git a/sway/input/tablet.c b/sway/input/tablet.c
index 92ede3fa..a62e77ec 100644
--- a/sway/input/tablet.c
+++ b/sway/input/tablet.c
@@ -1,6 +1,6 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <stdlib.h> 2#include <stdlib.h>
3#include <wlr/backend/libinput.h> 3#include <wlr/config.h>
4#include <wlr/types/wlr_tablet_v2.h> 4#include <wlr/types/wlr_tablet_v2.h>
5#include <wlr/types/wlr_tablet_tool.h> 5#include <wlr/types/wlr_tablet_tool.h>
6#include <wlr/types/wlr_tablet_pad.h> 6#include <wlr/types/wlr_tablet_pad.h>
@@ -9,6 +9,10 @@
9#include "sway/input/seat.h" 9#include "sway/input/seat.h"
10#include "sway/input/tablet.h" 10#include "sway/input/tablet.h"
11 11
12#if WLR_HAS_LIBINPUT_BACKEND
13#include <wlr/backend/libinput.h>
14#endif
15
12static void handle_pad_tablet_destroy(struct wl_listener *listener, void *data) { 16static void handle_pad_tablet_destroy(struct wl_listener *listener, void *data) {
13 struct sway_tablet_pad *pad = 17 struct sway_tablet_pad *pad =
14 wl_container_of(listener, pad, tablet_destroy); 18 wl_container_of(listener, pad, tablet_destroy);
@@ -63,6 +67,7 @@ void sway_configure_tablet(struct sway_tablet *tablet) {
63 wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device); 67 wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device);
64 } 68 }
65 69
70#if WLR_HAS_LIBINPUT_BACKEND
66 /* Search for a sibling tablet pad */ 71 /* Search for a sibling tablet pad */
67 if (!wlr_input_device_is_libinput(device)) { 72 if (!wlr_input_device_is_libinput(device)) {
68 /* We can only do this on libinput devices */ 73 /* We can only do this on libinput devices */
@@ -87,6 +92,7 @@ void sway_configure_tablet(struct sway_tablet *tablet) {
87 break; 92 break;
88 } 93 }
89 } 94 }
95#endif
90} 96}
91 97
92void sway_tablet_destroy(struct sway_tablet *tablet) { 98void sway_tablet_destroy(struct sway_tablet *tablet) {
@@ -287,6 +293,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) {
287 tablet_pad->ring.notify = handle_tablet_pad_ring; 293 tablet_pad->ring.notify = handle_tablet_pad_ring;
288 wl_signal_add(&tablet_pad->wlr->events.ring, &tablet_pad->ring); 294 wl_signal_add(&tablet_pad->wlr->events.ring, &tablet_pad->ring);
289 295
296#if WLR_HAS_LIBINPUT_BACKEND
290 /* Search for a sibling tablet */ 297 /* Search for a sibling tablet */
291 if (!wlr_input_device_is_libinput(wlr_device)) { 298 if (!wlr_input_device_is_libinput(wlr_device)) {
292 /* We can only do this on libinput devices */ 299 /* We can only do this on libinput devices */
@@ -311,6 +318,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) {
311 break; 318 break;
312 } 319 }
313 } 320 }
321#endif
314} 322}
315 323
316void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad) { 324void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad) {
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 73a3d376..8aa9557e 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -3,7 +3,7 @@
3#include <json.h> 3#include <json.h>
4#include <libevdev/libevdev.h> 4#include <libevdev/libevdev.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <wlr/backend/libinput.h> 6#include <wlr/config.h>
7#include <wlr/types/wlr_content_type_v1.h> 7#include <wlr/types/wlr_content_type_v1.h>
8#include <wlr/types/wlr_output.h> 8#include <wlr/types/wlr_output.h>
9#include <xkbcommon/xkbcommon.h> 9#include <xkbcommon/xkbcommon.h>
@@ -21,6 +21,10 @@
21#include "wlr-layer-shell-unstable-v1-protocol.h" 21#include "wlr-layer-shell-unstable-v1-protocol.h"
22#include "sway/desktop/idle_inhibit_v1.h" 22#include "sway/desktop/idle_inhibit_v1.h"
23 23
24#if WLR_HAS_LIBINPUT_BACKEND
25#include <wlr/backend/libinput.h>
26#endif
27
24static const int i3_output_id = INT32_MAX; 28static const int i3_output_id = INT32_MAX;
25static const int i3_scratch_id = INT32_MAX - 1; 29static const int i3_scratch_id = INT32_MAX - 1;
26 30
@@ -847,6 +851,7 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) {
847 return object; 851 return object;
848} 852}
849 853
854#if WLR_HAS_LIBINPUT_BACKEND
850static json_object *describe_libinput_device(struct libinput_device *device) { 855static json_object *describe_libinput_device(struct libinput_device *device) {
851 json_object *object = json_object_new_object(); 856 json_object *object = json_object_new_object();
852 857
@@ -1052,6 +1057,7 @@ static json_object *describe_libinput_device(struct libinput_device *device) {
1052 1057
1053 return object; 1058 return object;
1054} 1059}
1060#endif
1055 1061
1056json_object *ipc_json_describe_input(struct sway_input_device *device) { 1062json_object *ipc_json_describe_input(struct sway_input_device *device) {
1057 if (!(sway_assert(device, "Device must not be null"))) { 1063 if (!(sway_assert(device, "Device must not be null"))) {
@@ -1115,12 +1121,14 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
1115 json_object_new_double(scroll_factor)); 1121 json_object_new_double(scroll_factor));
1116 } 1122 }
1117 1123
1124#if WLR_HAS_LIBINPUT_BACKEND
1118 if (wlr_input_device_is_libinput(device->wlr_device)) { 1125 if (wlr_input_device_is_libinput(device->wlr_device)) {
1119 struct libinput_device *libinput_dev; 1126 struct libinput_device *libinput_dev;
1120 libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); 1127 libinput_dev = wlr_libinput_get_device_handle(device->wlr_device);
1121 json_object_object_add(object, "libinput", 1128 json_object_object_add(object, "libinput",
1122 describe_libinput_device(libinput_dev)); 1129 describe_libinput_device(libinput_dev));
1123 } 1130 }
1131#endif
1124 1132
1125 return object; 1133 return object;
1126} 1134}
diff --git a/sway/meson.build b/sway/meson.build
index 8a73cc86..de10e14f 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -26,7 +26,6 @@ sway_sources = files(
26 'input/input-manager.c', 26 'input/input-manager.c',
27 'input/cursor.c', 27 'input/cursor.c',
28 'input/keyboard.c', 28 'input/keyboard.c',
29 'input/libinput.c',
30 'input/seat.c', 29 'input/seat.c',
31 'input/seatop_default.c', 30 'input/seatop_default.c',
32 'input/seatop_down.c', 31 'input/seatop_down.c',
@@ -227,12 +226,16 @@ sway_deps = [
227 wayland_server, 226 wayland_server,
228 wlroots, 227 wlroots,
229 xkbcommon, 228 xkbcommon,
229 xcb,
230 xcb_icccm, 230 xcb_icccm,
231] 231]
232 232
233if have_xwayland 233if have_xwayland
234 sway_sources += 'desktop/xwayland.c' 234 sway_sources += 'desktop/xwayland.c'
235 sway_deps += xcb 235endif
236
237if wlroots_features['libinput_backend']
238 sway_sources += 'input/libinput.c'
236endif 239endif
237 240
238executable( 241executable(