From 8c6faa010f639bc4cd6715ad314c68340c3be802 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sun, 29 Mar 2026 20:31:33 +0200 Subject: [PATCH] make wlroots libinput backend optional --- src/input/cursor.c | 9 +++++++-- src/input/tablet-pad.c | 11 +++++++++-- src/input/tablet.c | 8 +++++++- src/seat.c | 13 +++++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/input/cursor.c b/src/input/cursor.c index 3985e9d6..e8ac7d96 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -3,7 +3,7 @@ #include "input/cursor.h" #include #include -#include +#include #include #include #include @@ -38,6 +38,10 @@ #include "view.h" #include "xwayland.h" +#if WLR_HAS_LIBINPUT_BACKEND + #include +#endif + #define LAB_CURSOR_SHAPE_V1_VERSION 1 struct constraint { @@ -898,6 +902,7 @@ preprocess_cursor_motion(struct seat *seat, struct wlr_pointer *pointer, static double get_natural_scroll_factor(struct wlr_input_device *wlr_input_device) { +#if WLR_HAS_LIBINPUT_BACKEND if (wlr_input_device_is_libinput(wlr_input_device)) { struct libinput_device *libinput_device = wlr_libinput_get_device_handle(wlr_input_device); @@ -905,7 +910,7 @@ static double get_natural_scroll_factor(struct wlr_input_device *wlr_input_devic return -1.0; } } - +#endif return 1.0; } diff --git a/src/input/tablet-pad.c b/src/input/tablet-pad.c index 44b71847..7c52278c 100644 --- a/src/input/tablet-pad.c +++ b/src/input/tablet-pad.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include "input/tablet-pad.h" #include -#include +#include #include #include #include @@ -14,6 +14,12 @@ #include "input/tablet.h" #include "labwc.h" +#if WLR_HAS_LIBINPUT_BACKEND + #include +#else + #define wlr_input_device_is_libinput(device) (false) +#endif + void tablet_pad_attach_tablet(struct seat *seat) { @@ -34,7 +40,7 @@ tablet_pad_attach_tablet(struct seat *seat) */ continue; } - +#if WLR_HAS_LIBINPUT_BACKEND struct libinput_device *tablet_device = wlr_libinput_get_device_handle(tablet->wlr_input_device); struct libinput_device_group *tablet_group = @@ -55,6 +61,7 @@ tablet_pad_attach_tablet(struct seat *seat) pad->tablet = tablet; } } +#endif } } diff --git a/src/input/tablet.c b/src/input/tablet.c index a4ca0fab..58587490 100644 --- a/src/input/tablet.c +++ b/src/input/tablet.c @@ -2,7 +2,7 @@ #include "input/tablet.h" #include #include -#include "wlr/backend/libinput.h" +#include #include #include #include @@ -22,6 +22,10 @@ #include "action.h" #include "view.h" +#if WLR_HAS_LIBINPUT_BACKEND + #include +#endif + bool tablet_tool_has_focused_surface(struct seat *seat) { @@ -338,6 +342,7 @@ handle_tablet_tool_proximity(struct wl_listener *listener, void *data) tool = tablet_tool_create(tablet->seat, ev->tool); } +#if WLR_HAS_LIBINPUT_BACKEND struct libinput_tablet_tool *libinput_tool = wlr_libinput_get_tablet_tool_handle(tool->tool_v2->wlr_tool); @@ -358,6 +363,7 @@ handle_tablet_tool_proximity(struct wl_listener *listener, void *data) rc.tablet_tool.min_pressure, rc.tablet_tool.max_pressure); } } +#endif /* * Enforce mouse emulation when the current tool is a tablet mouse. diff --git a/src/seat.c b/src/seat.c index aea16c7a..93d108be 100644 --- a/src/seat.c +++ b/src/seat.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,6 +31,12 @@ #include "session-lock.h" #include "view.h" +#if WLR_HAS_LIBINPUT_BACKEND + #include +#else + #define wlr_input_device_is_libinput(device) (false) +#endif + static void input_device_destroy(struct wl_listener *listener, void *data) { @@ -48,6 +54,7 @@ input_device_destroy(struct wl_listener *listener, void *data) free(input); } +#if WLR_HAS_LIBINPUT_BACKEND static enum lab_libinput_device_type device_type_from_wlr_device(struct wlr_input_device *wlr_input_device) { @@ -101,6 +108,7 @@ get_category(struct wlr_input_device *device) /* Use default profile as a fallback */ return libinput_category_get_default(); } +#endif static void configure_libinput(struct wlr_input_device *wlr_input_device) @@ -135,7 +143,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device) input->scroll_factor = 1.0; return; } - +#if WLR_HAS_LIBINPUT_BACKEND struct libinput_device *libinput_dev = wlr_libinput_get_device_handle(wlr_input_device); if (!libinput_dev) { @@ -347,6 +355,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device) wlr_log(WLR_INFO, "scroll factor configured (%g)", dc->scroll_factor); input->scroll_factor = dc->scroll_factor; +#endif } static struct wlr_output *