From 46ec003667487d244828babe43884555fbe7322b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 16 Jan 2020 22:50:18 +0100 Subject: nxagent: re-implement timeout handling Option -timeout used the screensaver facility. This patch changes that to an own timer that is independent. This effectly means we can drop most of the derived screensaving stuff in a follow-up commit. --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 85 +++-------------------------- 1 file changed, 7 insertions(+), 78 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Screen.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index bf614ffdc..da1f0d962 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -37,12 +37,6 @@ is" without express or implied warranty. */ -/* - * Used by the auto-disconnect feature. - */ - -#include - #include "scrnintstr.h" #include "dix.h" #include "dixstruct.h" @@ -517,19 +511,6 @@ void nxagentSetScreenSaverTime(void) (long unsigned int)ScreenSaverTime, (long unsigned int)ScreenSaverInterval); #endif - /* - * More than one timeout could be used here, - * to make use of screen-saver handler not - * only for the timeout feature. In a case - * like this, the lower timeout have to be - * used as ScreenSaverTime. - */ - - if (nxagentAutoDisconnectTimeout > 0) - { - ScreenSaverTime = nxagentAutoDisconnectTimeout; - } - ScreenSaverInterval = ScreenSaverTime; #ifdef TEST @@ -550,15 +531,8 @@ static Bool nxagentSaveScreen(ScreenPtr pScreen, int what) SCREEN_SAVER_CYCLE); #endif - /* - * We need only to reset the timeouts - * in this case. - */ - if (what == SCREEN_SAVER_OFF) { - nxagentAutoDisconnectTimeout = nxagentOption(Timeout) * MILLI_PER_SECOND; - return 1; } @@ -592,56 +566,6 @@ FIXME: Do we need to check the key grab if the return 1; } - /* - * Handling the auto-disconnect feature. - * If there is any client attached and the persisten- - * ce is allowed then leave the session running, else - * terminate it. It should use something less brutal, - * though raising a signal should ensure that the code - * follows the usual execution path. - */ - - if (nxagentOption(Timeout) > 0) - { - #ifdef TEST - fprintf(stderr, "nxagentSaveScreen: Auto-disconnect timeout was [%d].\n", - nxagentAutoDisconnectTimeout); - #endif - - nxagentAutoDisconnectTimeout -= ScreenSaverTime; - - #ifdef TEST - fprintf(stderr, "nxagentSaveScreen: Auto-disconnect timeout is [%d].\n", - nxagentAutoDisconnectTimeout); - #endif - - if (nxagentSessionState == SESSION_UP && - nxagentAutoDisconnectTimeout <= 0) - { - nxagentAutoDisconnectTimeout = nxagentOption(Timeout) * MILLI_PER_SECOND; - - if (nxagentClients == 0) - { - fprintf(stderr, "Info: Terminating session with no client running.\n"); - - raise(SIGTERM); - } - else if (nxagentOption(Persistent) == 0) - { - fprintf(stderr, "Info: Terminating session with persistence not allowed.\n"); - - raise(SIGTERM); - } - else - { - fprintf(stderr, "Info: Suspending session with %d clients running.\n", - nxagentClients); - - raise(SIGHUP); - } - } - } - return 1; } @@ -3490,14 +3414,19 @@ Bool nxagentReconnectScreen(void *p0) XSelectInput(nxagentDisplay, nxagentDefaultWindows[0], mask); /* - * Turn off the screen-saver and reset the - * time to the next auto-disconnection. + * Turn off the screen-saver */ SaveScreens(SCREEN_SAVER_OFF, ScreenSaverActive); + /* + * reset the time to the next auto-disconnection. + */ + lastDeviceEventTime.milliseconds = GetTimeInMillis(); + nxagentSetTimeoutTimer(0); + return True; } -- cgit v1.2.3