From 1ac940c01d79440b802cc6c60b8a4e4b066910c7 Mon Sep 17 00:00:00 2001 From: Tautvis Date: Sat, 27 Sep 2025 01:49:49 +0300 Subject: [PATCH] Patch 3/5 os-support: add xf86VTKeepTtyIsSet Add xf86VTKeepTtyIsSet function to export KeepTty state. When seatd activates, it takes control of current vt (in global sense)!, this code only activates sesion control code when XServer started using same vt (for more context see c88a325899381d1133e63e6c33c29db079e20a87 commit ). Signed-off-By: Tautvis --- hw/xfree86/os-support/bsd/bsd_init.c | 7 +++++++ hw/xfree86/os-support/hurd/hurd_init.c | 6 ++++++ hw/xfree86/os-support/linux/linux.h | 1 - hw/xfree86/os-support/linux/lnx_init.c | 4 ++-- hw/xfree86/os-support/linux/systemd-logind.c | 3 ++- hw/xfree86/os-support/solaris/sun_init.c | 8 ++++++++ hw/xfree86/os-support/stub/stub_init.c | 7 +++++++ hw/xfree86/os-support/xf86_os_support.h | 6 ++++++ 8 files changed, 38 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index 4162e2a4b..b0ad13ea7 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -134,6 +134,13 @@ static xf86ConsOpen_t xf86ConsTab[] = { (xf86ConsOpen_t) NULL }; + +Bool +xf86VTKeepTtyIsSet(void) +{ + return KeepTty; +} + void xf86OpenConsole(void) { diff --git a/hw/xfree86/os-support/hurd/hurd_init.c b/hw/xfree86/os-support/hurd/hurd_init.c index e99c3fff4..f3071437e 100644 --- a/hw/xfree86/os-support/hurd/hurd_init.c +++ b/hw/xfree86/os-support/hurd/hurd_init.c @@ -57,6 +57,12 @@ xf86UseMsg() return; } +Bool +xf86VTKeepTtyIsSet(void) +{ + return FALSE; +} + void xf86OpenConsole() { diff --git a/hw/xfree86/os-support/linux/linux.h b/hw/xfree86/os-support/linux/linux.h index 83506fd38..0fe4cf5f7 100644 --- a/hw/xfree86/os-support/linux/linux.h +++ b/hw/xfree86/os-support/linux/linux.h @@ -27,6 +27,5 @@ #define XF86_LINUX_H int linux_parse_vt_settings(int may_fail); -int linux_get_keeptty(void); #endif diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index d14ed20d7..181232c06 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -167,8 +167,8 @@ linux_parse_vt_settings(int may_fail) return 1; } -int -linux_get_keeptty(void) +Bool +xf86VTKeepTtyIsSet(void) { return KeepTty; } diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index 152649583..e0343bac0 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -37,6 +37,7 @@ #include "os.h" #include "linux.h" +#include "xf86_os_support.h" #include "xf86_priv.h" #include "xf86platformBus_priv.h" #include "xf86Xinput_priv.h" @@ -659,7 +660,7 @@ static struct dbus_core_hook core_hook = { int systemd_logind_init(void) { - if (!ServerIsNotSeat0() && xf86HasTTYs() && linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { + if (!ServerIsNotSeat0() && xf86HasTTYs() && linux_parse_vt_settings(TRUE) && !xf86VTKeepTtyIsSet()) { LogMessage(X_INFO, "systemd-logind: logind integration requires -keeptty and " "-keeptty was not provided, disabling logind integration\n"); diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c index d623c375f..b1bd2b276 100644 --- a/hw/xfree86/os-support/solaris/sun_init.c +++ b/hw/xfree86/os-support/solaris/sun_init.c @@ -74,6 +74,14 @@ static char consoleDev[PATH_MAX] = "/dev/fb"; Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */ char xf86SolarisFbDev[PATH_MAX] = "/dev/fb"; + +Bool +xf86VTKeepTtyIsSet(void) +{ + return KeepTty; +} + + #ifdef HAS_USL_VTS static void switch_to(int vt, const char *from) diff --git a/hw/xfree86/os-support/stub/stub_init.c b/hw/xfree86/os-support/stub/stub_init.c index 677401bfa..8f82269eb 100644 --- a/hw/xfree86/os-support/stub/stub_init.c +++ b/hw/xfree86/os-support/stub/stub_init.c @@ -15,6 +15,13 @@ xf86CloseConsole(void) { } +Bool +xf86VTKeepTtyIsSet(void) +{ + return FALSE; +} + + int xf86ProcessArgument(int argc, char *argv[], int i) { diff --git a/hw/xfree86/os-support/xf86_os_support.h b/hw/xfree86/os-support/xf86_os_support.h index 9076eba0d..e6c573d0e 100644 --- a/hw/xfree86/os-support/xf86_os_support.h +++ b/hw/xfree86/os-support/xf86_os_support.h @@ -30,6 +30,12 @@ typedef void (*PMClose) (void); void xf86OpenConsole(void); void xf86CloseConsole(void); + +/** + * @brief get keeptty switch state + **/ +Bool xf86VTKeepTtyIsSet(void); + Bool xf86VTActivate(int vtno); Bool xf86VTSwitchPending(void); Bool xf86VTSwitchAway(void);