diff --git a/hw/xfree86/common/seatd-libseat.h b/hw/xfree86/common/seatd-libseat.h index cbc0d2a9e1..ad9b15be27 100644 --- a/hw/xfree86/common/seatd-libseat.h +++ b/hw/xfree86/common/seatd-libseat.h @@ -29,7 +29,7 @@ #ifdef SEATD_LIBSEAT #include -extern int seatd_libseat_init(void); +extern int seatd_libseat_init(Bool KeepTty_state); extern void seatd_libseat_fini(void); extern int seatd_libseat_open_graphics(const char *path); extern void seatd_libseat_open_device(InputInfoPtr p,int *fd,Bool *paus); @@ -37,13 +37,15 @@ extern void seatd_libseat_close_device(InputInfoPtr p); extern int seatd_libseat_switch_session(int session); extern Bool seatd_libseat_controls_session(void); #else -#define seatd_libseat_init() -#define seatd_libseat_fini() -#define seatd_libseat_open_graphics(path) -1 -#define seatd_libseat_open_device(p,x,y) -#define seatd_libseat_close_device(p) -#define seatd_libseat_switch_session(int) -1 -#define seatd_libseat_controls_session() FALSE + +static inline int seatd_libseat_init(bool KeepTty_state) {(void)KeepTty_state; return -1; }; +static inline void seatd_libseat_fini(void) {}; +static inline int seatd_libseat_open_graphics(const char *path) {(void)path; return -1; } +static inline void seatd_libseat_open_device(void *p,int *fd, Bool *paus) { (void)p;(void)fd;(void)paus; }; +static inline void seatd_libseat_close_device(void *p) { (void)p;}; +static inline int seatd_libseat_switch_session(int session) { return -1; }; +static inline Bool seatd_libseat_controls_session(void) { return FALSE; }; + #endif #endif diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index d18f40a928..f40782a52a 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -363,7 +363,7 @@ void xf86DisableGeneralHandler(void *handler) { _xf86DisableGeneralHandler(handler); } -static void +void xf86VTLeave(void) { int i; diff --git a/hw/xfree86/common/xf86_priv.h b/hw/xfree86/common/xf86_priv.h index c51407d5a3..c661771fc0 100644 --- a/hw/xfree86/common/xf86_priv.h +++ b/hw/xfree86/common/xf86_priv.h @@ -65,6 +65,7 @@ InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, void *data); void xf86ProcessActionEvent(ActionEvent action, void *arg); Bool xf86VTOwner(void); void xf86VTEnter(void); +void xf86VTLeave(void); void xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo); void xf86Wakeup(void *blockData, int err); void xf86HandlePMEvents(int fd, void *data); diff --git a/hw/xfree86/os-support/meson.build b/hw/xfree86/os-support/meson.build index 160f7516b9..18bcc8df6b 100644 --- a/hw/xfree86/os-support/meson.build +++ b/hw/xfree86/os-support/meson.build @@ -51,6 +51,7 @@ if host_machine.system() == 'linux' srcs_xorg_os_support += 'linux/systemd-logind.c' endif + # this is ugly because the code is also if build_apm or build_acpi srcs_xorg_os_support += 'linux/lnx_apm.c' @@ -157,6 +158,15 @@ else ] endif +if host_machine.system() == 'linux' or host_machine.system() == 'dragonfly' or host_machine.system().endswith('bsd') + + if build_seatd_libseat + srcs_xorg_os_support += 'shared/seatd-libseat.c' + os_dep += seat_libseat_dep + endif + +endif + xorg_os_support = static_library('xorg_os_support', srcs_xorg_os_support, include_directories: [inc, xorg_inc], diff --git a/hw/xfree86/os-support/shared/seatd-libseat.c b/hw/xfree86/os-support/shared/seatd-libseat.c index 4a48c7d4b4..4eddc05e22 100644 --- a/hw/xfree86/os-support/shared/seatd-libseat.c +++ b/hw/xfree86/os-support/shared/seatd-libseat.c @@ -36,12 +36,17 @@ #include #include "os.h" -#include "linux.h" #include "xf86.h" +#include "xf86_priv.h" #include "xf86platformBus.h" #include "xf86Xinput.h" +#include "xf86Xinput_priv.h" #include "xf86Priv.h" #include "globals.h" + +#include "config/hotplug_priv.h" +#include "xf86platformBus_priv.h" + #include "seatd-libseat.h" /* ============ libseat client adapter ====================== */ @@ -160,7 +165,7 @@ event_handler(int fd, int ready, void *data) /* * Handle libseat logging. */ -static void +static _X_ATTRIBUTE_PRINTF(2, 0) void log_libseat(enum libseat_log_level level, const char *fmt, va_list args) { MessageType xmt; @@ -192,6 +197,8 @@ log_libseat(enum libseat_log_level level, const char *fmt, va_list args) /* * Initialise the libseat client. * + * @param KeepTty_state - the KeepTty parameter value + * * Returns: * 0 if all ok * 1 if not possible @@ -199,17 +206,17 @@ log_libseat(enum libseat_log_level level, const char *fmt, va_list args) * -EPIPE (-32) if the seat opening failed. */ int -seatd_libseat_init(void) +seatd_libseat_init(Bool KeepTty_state) { - if (!ServerIsNotSeat0() && xf86HasTTYs() && linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { - LogMessage(X_INFO, + if (!ServerIsNotSeat0() && xf86HasTTYs() && !KeepTty_state) { + LogMessage(X_WARNING, "seat-libseat: libseat integration requires -keeptty which " "was not provided, disabling\n"); return 1; } libseat_set_log_level(LIBSEAT_LOG_LEVEL_DEBUG); - libseat_set_log_handler(log_libseat); + libseat_set_log_handler((libseat_log_func)log_libseat); LogMessage(X_INFO, "seatd_libseat init\n"); if (libseat_active()) { LogMessage(X_ERROR, "seatd_libseat already initialised\n"); @@ -304,7 +311,7 @@ check_duplicate_device(int maj, int min) { void seatd_libseat_open_device(InputInfoPtr p, int *pfd, Bool *paused) { - int id, fd; + int id = -1, fd = -1; char *path = xf86CheckStrOption(p->options, "Device", NULL); if (!libseat_active()) { diff --git a/include/meson.build b/include/meson.build index 297835ce6c..f8f7a9be0e 100644 --- a/include/meson.build +++ b/include/meson.build @@ -92,6 +92,7 @@ conf_data.set('CONFIG_UDEV', build_udev ? '1' : false) conf_data.set('CONFIG_UDEV_KMS', build_udev_kms ? '1' : false) conf_data.set('HAVE_DBUS', build_dbus ? '1' : false) conf_data.set('CONFIG_HAL', build_hal ? '1' : false) +conf_data.set('SEATD_LIBSEAT', build_seatd_libseat ? '1' : false) conf_data.set('SYSTEMD_LOGIND', build_systemd_logind ? '1' : false) conf_data.set('NEED_DBUS', build_systemd_logind or build_hal ? '1' : false) conf_data.set('CONFIG_WSCONS', host_machine.system() in ['openbsd', 'netbsd'] ? '1' : false) diff --git a/meson.build b/meson.build index c34bb003c5..dba3c286b0 100644 --- a/meson.build +++ b/meson.build @@ -115,6 +115,9 @@ xfont2_dep = dependency('xfont2', version: '>= 2.0') dbus_required = get_option('systemd_logind') == 'true' dbus_dep = dependency('dbus-1', version: '>= 1.0', required: dbus_required) +seat_libseat_required = get_option('seatd_libseat') == 'true' +seat_libseat_dep = dependency('libseat', version: '>= 0.9.1', required: seat_libseat_required) + build_systemd = get_option('systemd_notify') == 'true' # libsystemd-daemon was moved into libsystemd in version 209 libsystemd_daemon_dep = dependency('libsystemd', version: '>= 209', required: false) @@ -197,12 +200,23 @@ endif build_udev = (udev_option != 'false') build_udev_kms = (udev_kms_option != 'false') +if get_option('seatd_libseat') == 'auto' + build_seatd_libseat = build_udev_kms and seat_libseat_dep.found() +else + build_seatd_libseat = get_option('seatd_libseat') == 'true' +endif + + if get_option('systemd_logind') == 'auto' - build_systemd_logind = build_udev_kms and dbus_dep.found() + build_systemd_logind = build_udev_kms and dbus_dep.found() and not build_seatd_libseat else build_systemd_logind = get_option('systemd_logind') == 'true' endif +if build_systemd_logind and build_seatd_libseat + error('Support for systemd-logind and seatd-libseat are mutually exclusive: choose either.') +endif + with_dtrace = get_option('dtrace') if with_dtrace dtrace = find_program('dtrace', required: true) diff --git a/meson_options.txt b/meson_options.txt index 7b3c42318a..99e65e7139 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -85,6 +85,10 @@ option('systemd_notify', type: 'combo', choices: ['true', 'false', 'auto'], valu description: 'Enable systemd-notify support') option('systemd_logind', type: 'combo', choices: ['true', 'false', 'auto'], value: 'false', description: 'Enable systemd-logind integration') + +option('seatd_libseat', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Enable seatd-libseat integration') + option('vgahw', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Xorg VGA access module') option('dpms', type: 'boolean', value: true,