Make libinput optional

Only really useful for wlroots compiled without the libinput backend.
This commit is contained in:
Keith Bowes 2024-07-16 03:14:50 -04:00
parent 0f9461c4c0
commit 4cf3ee8a05
2 changed files with 15 additions and 1 deletions

View file

@ -33,13 +33,17 @@ else
endif
libevdev = dependency('libevdev')
libinput = dependency('libinput', version: '>=1.21.0')
libinput = dependency('libinput', version: '>=1.21.0', required: false)
libxml2 = dependency('libxml-2.0')
wayland_protos = dependency('wayland-protocols', version: '>=1.27')
wayland_server = dependency('wayland-server', version: '>=1.15')
wlroots = dependency(wlroots_version, version: '>=0.17.0')
xkbcommon = dependency('xkbcommon')
if libinput.found()
add_project_arguments('-DHAS_LIBINPUT', language: 'c')
endif
msgfmt = find_program('msgfmt', required: false)
if msgfmt.found()
source_root = meson.current_source_dir()

View file

@ -1,7 +1,13 @@
#include <libevdev/libevdev.h>
#include <unistd.h>
#include <wlr/config.h>
#if WLR_HAS_LIBINPUT_BACKEND && defined(HAS_LIBINPUT)
#include <wlr/backend/libinput.h>
#else
#undef HAS_LIBINPUT
#endif
#include <wlr/backend/session.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_primary_selection_v1.h>
@ -263,11 +269,14 @@ static void handle_new_keyboard(struct wb_server *server,
wl_list_insert(&server->seat->keyboards, &keyboard->link);
}
#ifdef HAS_LIBINPUT
static bool libinput_config_get_enabled(char *config) {
return strcmp(config, "disabled") != 0;
}
#endif
static void handle_new_pointer(struct wb_server *server, struct wlr_input_device *device) {
#ifdef HAS_LIBINPUT
struct wb_config *config = server->config;
if (wlr_input_device_is_libinput(device) && config->libinput_config.use_config) {
struct libinput_device *libinput_handle =
@ -362,6 +371,7 @@ static void handle_new_pointer(struct wb_server *server, struct wlr_input_device
libinput_config_get_enabled(config->libinput_config.tap_drag_lock));
};
}
#endif
wlr_cursor_attach_input_device(server->cursor->cursor, device);
}