Submitted by:            DJ Lucas (dj_AT_linuxfromscratch_DOT_org)
Date:                    2018-12-18
Initial Package Version: 1.20.3
Upstream Status:         Submitted
Origin:                  Self
Description:             Allows detection and use of elogind


diff -Naurp xorg-server-1.20.3-orig/configure.ac xorg-server-1.20.3/configure.ac
--- xorg-server-1.20.3-orig/configure.ac	2018-10-25 09:13:21.000000000 -0500
+++ xorg-server-1.20.3/configure.ac	2018-12-17 22:55:52.939502789 -0600
@@ -580,6 +580,7 @@ AC_ARG_ENABLE(clientids,      AS_HELP_ST
 AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], [Build Xorg with pciaccess library (default: enabled)]), [PCI=$enableval], [PCI=yes])
 AC_ARG_ENABLE(linux_acpi, AS_HELP_STRING([--disable-linux-acpi], [Disable building ACPI support on Linux (if available).]), [enable_linux_acpi=$enableval], [enable_linux_acpi=yes])
 AC_ARG_ENABLE(linux_apm, AS_HELP_STRING([--disable-linux-apm], [Disable building APM support on Linux (if available).]), [enable_linux_apm=$enableval], [enable_linux_apm=yes])
+AC_ARG_ENABLE(elogind, AS_HELP_STRING([--enable-elogind], [Build elogind support (default: auto)]), [ELOGIND_LOGIND=$enableval], [ELOGIND_LOGIND=auto])
 AC_ARG_ENABLE(systemd-logind, AS_HELP_STRING([--enable-systemd-logind], [Build systemd-logind support (default: auto)]), [SYSTEMD_LOGIND=$enableval], [SYSTEMD_LOGIND=auto])
 AC_ARG_ENABLE(suid-wrapper, AS_HELP_STRING([--enable-suid-wrapper], [Build suid-root wrapper for legacy driver support on rootless xserver systems (default: no)]), [SUID_WRAPPER=$enableval], [SUID_WRAPPER=no])
 
@@ -885,6 +886,7 @@ if test "x$CONFIG_UDEV" = xyes; then
 fi
 AM_CONDITIONAL(CONFIG_UDEV_KMS, [test "x$CONFIG_UDEV_KMS" = xyes])
 
+
 PKG_CHECK_MODULES(DBUS, $LIBDBUS, [HAVE_DBUS=yes], [HAVE_DBUS=no])
 if test "x$HAVE_DBUS" = xyes; then
 	AC_DEFINE(HAVE_DBUS, 1, [Have D-Bus support])
@@ -905,6 +907,28 @@ if test "x$CONFIG_HAL" = xyes; then
 fi
 AM_CONDITIONAL(CONFIG_HAL, [test "x$CONFIG_HAL" = xyes])
 
+dnl elogind detection
+PKG_CHECK_MODULES(ELOGIND, [libelogind >= 209], [HAVE_ELOGIND=yes], [HAVE_ELOGIND=no])
+if test "x$ELOGIND_LOGIND" = xauto; then
+        if test "x$HAVE_DBUS" = xyes -a "x$CONFIG_UDEV" = xyes -a "x$HAVE_ELOGIND" = xyes; then
+                ELOGIND_LOGIND=yes
+        else
+                ELOGIND_LOGIND=no
+        fi
+fi
+if test "x$ELOGIND_LOGIND" = xyes; then
+        if ! test "x$HAVE_DBUS" = xyes; then
+                AC_MSG_ERROR([elogind requested, but D-Bus is not installed.])
+        fi
+        if ! test "x$CONFIG_UDEV" = xyes ; then
+                AC_MSG_ERROR([elogind is only supported in combination with udev configuration.])
+        fi
+
+        AC_DEFINE(ELOGIND_LOGIND, 1, [Enable elogind integration])
+        NEED_DBUS="yes"
+fi
+AM_CONDITIONAL(ELOGIND_LOGIND, [test "x$ELOGIND_LOGIND" = xyes])
+
 if test "x$SYSTEMD_LOGIND" = xauto; then
         if test "x$HAVE_DBUS" = xyes -a "x$CONFIG_UDEV" = xyes ; then
                 SYSTEMD_LOGIND=yes
diff -Naurp xorg-server-1.20.3-orig/hw/kdrive/src/kdrive.c xorg-server-1.20.3/hw/kdrive/src/kdrive.c
--- xorg-server-1.20.3-orig/hw/kdrive/src/kdrive.c	2018-10-25 09:13:21.000000000 -0500
+++ xorg-server-1.20.3/hw/kdrive/src/kdrive.c	2018-12-17 22:55:10.029500113 -0600
@@ -1007,7 +1007,7 @@ xf86_find_platform_device_by_devnum(int
     return NULL;
 }
 
-#ifdef SYSTEMD_LOGIND
+#if defined (SYSTEMD_LOGIND) || defined(ELOGIND_LOGIND)
 void
 systemd_logind_vtenter(void)
 {
diff -Naurp xorg-server-1.20.3-orig/hw/xfree86/os-support/linux/Makefile.am xorg-server-1.20.3/hw/xfree86/os-support/linux/Makefile.am
--- xorg-server-1.20.3-orig/hw/xfree86/os-support/linux/Makefile.am	2018-10-25 09:13:21.000000000 -0500
+++ xorg-server-1.20.3/hw/xfree86/os-support/linux/Makefile.am	2018-12-17 22:55:10.029500113 -0600
@@ -18,6 +18,11 @@ LOGIND_SRCS = systemd-logind.c
 XORG_CFLAGS += $(DBUS_CFLAGS)
 endif
 
+if ELOGIND_LOGIND
+LOGIND_SRCS = systemd-logind.c
+XORG_CFLAGS += $(DBUS_CFLAGS)
+endif
+
 liblinux_la_SOURCES = linux.h lnx_init.c lnx_video.c \
                      lnx_agp.c lnx_kmod.c lnx_bell.c lnx_platform.c \
 		     $(srcdir)/../shared/VTsw_usl.c \
diff -Naurp xorg-server-1.20.3-orig/include/dix-config.h.in xorg-server-1.20.3/include/dix-config.h.in
--- xorg-server-1.20.3-orig/include/dix-config.h.in	2018-10-25 09:13:21.000000000 -0500
+++ xorg-server-1.20.3/include/dix-config.h.in	2018-12-17 22:55:10.029500113 -0600
@@ -424,6 +424,9 @@
 /* Enable systemd-logind integration */
 #undef SYSTEMD_LOGIND 1
 
+/* Enable elogind integration */
+#undef ELOGIND_LOGIND 1
+
 /* Have a monotonic clock from clock_gettime() */
 #undef MONOTONIC_CLOCK
 
diff -Naurp xorg-server-1.20.3-orig/include/do-not-use-config.h.in xorg-server-1.20.3/include/do-not-use-config.h.in
--- xorg-server-1.20.3-orig/include/do-not-use-config.h.in	2018-10-25 09:13:28.000000000 -0500
+++ xorg-server-1.20.3/include/do-not-use-config.h.in	2018-12-17 22:55:10.029500113 -0600
@@ -105,6 +105,9 @@
 /* Default DRI driver path */
 #undef DRI_DRIVER_PATH
 
+/* Enable elogind integration */
+#undef ELOGIND_LOGIND
+
 /* Fallback input driver */
 #undef FALLBACK_INPUT_DRIVER
 
diff -Naurp xorg-server-1.20.3-orig/include/meson.build xorg-server-1.20.3/include/meson.build
--- xorg-server-1.20.3-orig/include/meson.build	2018-10-25 09:13:21.000000000 -0500
+++ xorg-server-1.20.3/include/meson.build	2018-12-17 22:55:10.029500113 -0600
@@ -67,6 +67,7 @@ conf_data.set('CONFIG_UDEV_KMS', build_u
 conf_data.set('HAVE_DBUS', build_dbus)
 conf_data.set('CONFIG_HAL', build_hal)
 conf_data.set('SYSTEMD_LOGIND', build_systemd_logind)
+conf_data.set('ELOGIND_LOGIND', build_systemd_logind)
 conf_data.set('NEED_DBUS', build_systemd_logind or build_hal)
 conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd')
 
diff -Naurp xorg-server-1.20.3-orig/include/systemd-logind.h xorg-server-1.20.3/include/systemd-logind.h
--- xorg-server-1.20.3-orig/include/systemd-logind.h	2018-10-25 09:13:21.000000000 -0500
+++ xorg-server-1.20.3/include/systemd-logind.h	2018-12-17 22:55:10.030500113 -0600
@@ -26,7 +26,7 @@
 #ifndef SYSTEMD_LOGIND_H
 #define SYSTEMD_LOGIND_H
 
-#ifdef SYSTEMD_LOGIND
+#if defined(SYSTEMD_LOGIND) || defined(ELOGIND_LOGIND)
 int systemd_logind_init(void);
 void systemd_logind_fini(void);
 int systemd_logind_take_fd(int major, int minor, const char *path, Bool *paus);
