aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-11-26 20:18:43 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-28 13:28:15 -0500
commite62299daa45de139b912325eb5800796586e57c7 (patch)
tree5a1972d97bd65000f8e328667f2a772c8622e9e8
parent46170580b2ca7c2d484f9095f1ecd92c0a4ac04f (diff)
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'))
pixman = dependency('pixman-1')
glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep
libevdev = dependency('libevdev')
-libinput = dependency('libinput', version: '>=1.21.0')
+libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
xcb = dependency('xcb', required: get_option('xwayland'))
drm_full = dependency('libdrm') # only needed for drm_fourcc.h
drm = drm_full.partial_dependency(compile_args: true, includes: true)
-libudev = dependency('libudev')
+libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep
bash_comp = dependency('bash-completion', required: false)
fish_comp = dependency('fish', required: false)
math = 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 @@
#include <limits.h>
#include <string.h>
#include <strings.h>
-#include <wlr/backend/libinput.h>
+#include <wlr/config.h>
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
#include "log.h"
+#if WLR_HAS_LIBINPUT_BACKEND
+#include <wlr/backend/libinput.h>
+#endif
+
static void toggle_supported_send_events_for_device(struct input_config *ic,
struct sway_input_device *input_device) {
+#if WLR_HAS_LIBINPUT_BACKEND
struct wlr_input_device *wlr_device = input_device->wlr_device;
if (!wlr_input_device_is_libinput(wlr_device)) {
return;
@@ -41,6 +46,7 @@ static void toggle_supported_send_events_for_device(struct input_config *ic,
}
ic->send_events = mode;
+#endif
}
static int mode_for_name(const char *name) {
@@ -56,6 +62,7 @@ static int mode_for_name(const char *name) {
static void toggle_select_send_events_for_device(struct input_config *ic,
struct sway_input_device *input_device, int argc, char **argv) {
+#if WLR_HAS_LIBINPUT_BACKEND
if (!wlr_input_device_is_libinput(input_device->wlr_device)) {
return;
}
@@ -72,6 +79,7 @@ static void toggle_select_send_events_for_device(struct input_config *ic,
}
}
ic->send_events = mode_for_name(argv[index % argc]);
+#endif
}
static 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 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
-#include <wlr/backend/libinput.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_keyboard_group.h>
#include <wlr/types/wlr_input_inhibitor.h>
@@ -22,6 +22,10 @@
#include "list.h"
#include "log.h"
+#if WLR_HAS_LIBINPUT_BACKEND
+#include <wlr/backend/libinput.h>
+#endif
+
#define DEFAULT_SEAT "seat0"
struct input_config *current_input_config = NULL;
@@ -90,6 +94,7 @@ char *input_device_get_identifier(struct wlr_input_device *device) {
}
static bool device_is_touchpad(struct sway_input_device *device) {
+#if WLR_HAS_LIBINPUT_BACKEND
if (device->wlr_device->type != WLR_INPUT_DEVICE_POINTER ||
!wlr_input_device_is_libinput(device->wlr_device)) {
return false;
@@ -99,6 +104,9 @@ static bool device_is_touchpad(struct sway_input_device *device) {
wlr_libinput_get_device_handle(device->wlr_device);
return libinput_device_config_tap_get_finger_count(libinput_device) > 0;
+#else
+ return false;
+#endif
}
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) {
apply_input_type_config(input_device);
+#if WLR_HAS_LIBINPUT_BACKEND
bool config_changed = sway_input_configure_libinput_device(input_device);
+#else
+ bool config_changed = false;
+#endif
wl_signal_add(&device->events.destroy, &input_device->device_destroy);
input_device->device_destroy.notify = handle_device_destroy;
@@ -532,7 +544,11 @@ static void retranslate_keysyms(struct input_config *input_config) {
static void input_manager_configure_input(
struct sway_input_device *input_device) {
+#if WLR_HAS_LIBINPUT_BACKEND
bool config_changed = sway_input_configure_libinput_device(input_device);
+#else
+ bool config_changed = false;
+#endif
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &server.input->seats, link) {
seat_configure_device(seat, input_device);
@@ -567,7 +583,9 @@ void input_manager_apply_input_config(struct input_config *input_config) {
}
void input_manager_reset_input(struct sway_input_device *input_device) {
+#if WLR_HAS_LIBINPUT_BACKEND
sway_input_reset_libinput_device(input_device);
+#endif
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &server.input->seats, link) {
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 @@
#include <string.h>
#include <strings.h>
#include <time.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_idle.h>
@@ -750,6 +751,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
mapped_to_output = NULL;
break;
}
+#if WLR_HAS_LIBINPUT_BACKEND
if (mapped_to_output == NULL && is_touch_or_tablet_tool(sway_device) &&
sway_libinput_device_is_builtin(sway_device->input_device)) {
mapped_to_output = get_builtin_output_name();
@@ -758,6 +760,10 @@ static void seat_apply_input_config(struct sway_seat *seat,
mapped_to_output, sway_device->input_device->identifier);
}
}
+#else
+ (void)is_touch_or_tablet_tool;
+ (void)get_builtin_output_name;
+#endif
if (mapped_to_output == NULL) {
return;
}
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 @@
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
-#include <wlr/backend/libinput.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_pad.h>
@@ -9,6 +9,10 @@
#include "sway/input/seat.h"
#include "sway/input/tablet.h"
+#if WLR_HAS_LIBINPUT_BACKEND
+#include <wlr/backend/libinput.h>
+#endif
+
static void handle_pad_tablet_destroy(struct wl_listener *listener, void *data) {
struct sway_tablet_pad *pad =
wl_container_of(listener, pad, tablet_destroy);
@@ -63,6 +67,7 @@ void sway_configure_tablet(struct sway_tablet *tablet) {
wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device);
}
+#if WLR_HAS_LIBINPUT_BACKEND
/* Search for a sibling tablet pad */
if (!wlr_input_device_is_libinput(device)) {
/* We can only do this on libinput devices */
@@ -87,6 +92,7 @@ void sway_configure_tablet(struct sway_tablet *tablet) {
break;
}
}
+#endif
}
void sway_tablet_destroy(struct sway_tablet *tablet) {
@@ -287,6 +293,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) {
tablet_pad->ring.notify = handle_tablet_pad_ring;
wl_signal_add(&tablet_pad->wlr->events.ring, &tablet_pad->ring);
+#if WLR_HAS_LIBINPUT_BACKEND
/* Search for a sibling tablet */
if (!wlr_input_device_is_libinput(wlr_device)) {
/* We can only do this on libinput devices */
@@ -311,6 +318,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) {
break;
}
}
+#endif
}
void 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 @@
#include <json.h>
#include <libevdev/libevdev.h>
#include <stdio.h>
-#include <wlr/backend/libinput.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_content_type_v1.h>
#include <wlr/types/wlr_output.h>
#include <xkbcommon/xkbcommon.h>
@@ -21,6 +21,10 @@
#include "wlr-layer-shell-unstable-v1-protocol.h"
#include "sway/desktop/idle_inhibit_v1.h"
+#if WLR_HAS_LIBINPUT_BACKEND
+#include <wlr/backend/libinput.h>
+#endif
+
static const int i3_output_id = INT32_MAX;
static const int i3_scratch_id = INT32_MAX - 1;
@@ -847,6 +851,7 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) {
return object;
}
+#if WLR_HAS_LIBINPUT_BACKEND
static json_object *describe_libinput_device(struct libinput_device *device) {
json_object *object = json_object_new_object();
@@ -1052,6 +1057,7 @@ static json_object *describe_libinput_device(struct libinput_device *device) {
return object;
}
+#endif
json_object *ipc_json_describe_input(struct sway_input_device *device) {
if (!(sway_assert(device, "Device must not be null"))) {
@@ -1115,12 +1121,14 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
json_object_new_double(scroll_factor));
}
+#if WLR_HAS_LIBINPUT_BACKEND
if (wlr_input_device_is_libinput(device->wlr_device)) {
struct libinput_device *libinput_dev;
libinput_dev = wlr_libinput_get_device_handle(device->wlr_device);
json_object_object_add(object, "libinput",
describe_libinput_device(libinput_dev));
}
+#endif
return object;
}
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(
'input/input-manager.c',
'input/cursor.c',
'input/keyboard.c',
- 'input/libinput.c',
'input/seat.c',
'input/seatop_default.c',
'input/seatop_down.c',
@@ -227,12 +226,16 @@ sway_deps = [
wayland_server,
wlroots,
xkbcommon,
+ xcb,
xcb_icccm,
]
if have_xwayland
sway_sources += 'desktop/xwayland.c'
- sway_deps += xcb
+endif
+
+if wlroots_features['libinput_backend']
+ sway_sources += 'input/libinput.c'
endif
executable(