input/libinput: make udev optional

This commit is contained in:
illiliti 2022-02-09 15:17:22 +03:00
parent 6c4c0387a2
commit 8600e88728
3 changed files with 11 additions and 2 deletions

View file

@ -64,7 +64,7 @@ libinput = dependency('libinput', version: '>=1.6.0')
xcb = dependency('xcb', required: get_option('xwayland')) xcb = dependency('xcb', required: get_option('xwayland'))
drm_full = dependency('libdrm') # only needed for drm_fourcc.h drm_full = dependency('libdrm') # only needed for drm_fourcc.h
drm = drm_full.partial_dependency(compile_args: true, includes: true) drm = drm_full.partial_dependency(compile_args: true, includes: true)
libudev = dependency('libudev') libudev = dependency('libudev', required: get_option('udev'))
bash_comp = dependency('bash-completion', required: false) bash_comp = dependency('bash-completion', required: false)
fish_comp = dependency('fish', required: false) fish_comp = dependency('fish', required: false)
math = cc.find_library('m') math = cc.find_library('m')
@ -113,6 +113,7 @@ conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd
conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind') conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind')
conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu') conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu')
conf_data.set10('HAVE_TRAY', have_tray) conf_data.set10('HAVE_TRAY', have_tray)
conf_data.set10('HAVE_UDEV', libudev.found())
scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages')) scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
if scdoc.found() if scdoc.found()

View file

@ -9,3 +9,4 @@ option('tray', type: 'feature', value: 'auto', description: 'Enable support for
option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybg') option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybg')
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library') option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library')
option('udev', type: 'feature', value: 'auto', description: 'Enable support for udev')

View file

@ -1,6 +1,5 @@
#include <float.h> #include <float.h>
#include <libinput.h> #include <libinput.h>
#include <libudev.h>
#include <limits.h> #include <limits.h>
#include <wlr/backend/libinput.h> #include <wlr/backend/libinput.h>
#include "log.h" #include "log.h"
@ -9,6 +8,10 @@
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/ipc-server.h" #include "sway/ipc-server.h"
#if HAVE_UDEV
#include <libudev.h>
#endif
static void log_status(enum libinput_config_status status) { static void log_status(enum libinput_config_status status) {
if (status != LIBINPUT_CONFIG_STATUS_SUCCESS) { if (status != LIBINPUT_CONFIG_STATUS_SUCCESS) {
sway_log(SWAY_ERROR, "Failed to apply libinput config: %s", sway_log(SWAY_ERROR, "Failed to apply libinput config: %s",
@ -315,6 +318,7 @@ void sway_input_reset_libinput_device(struct sway_input_device *input_device) {
} }
bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) { bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) {
#if HAVE_UDEV
if (!wlr_input_device_is_libinput(sway_device->wlr_device)) { if (!wlr_input_device_is_libinput(sway_device->wlr_device)) {
return false; return false;
} }
@ -341,4 +345,7 @@ bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) {
const char infix_platform[] = "-platform-"; const char infix_platform[] = "-platform-";
return (strncmp(id_path, prefix_pci, strlen(prefix_pci)) == 0) && return (strncmp(id_path, prefix_pci, strlen(prefix_pci)) == 0) &&
strstr(id_path, infix_platform); strstr(id_path, infix_platform);
#else
return false;
#endif
} }