2003-11-14 16:54:54 +01:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* OS Dependent input routines:
|
|
|
|
*
|
|
|
|
* WaitForSomething
|
|
|
|
* TimerForce, TimerSet, TimerCheck, TimerFree
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <X11/Xwinsock.h>
|
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <X11/Xos.h> /* for strings, fcntl, time */
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#include "osdep.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include <X11/Xpoll.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "opaque.h"
|
|
|
|
#ifdef DPMSExtension
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dpmsproc.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2013-11-03 22:12:40 +01:00
|
|
|
#include "busfault.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2004-12-02 22:49:54 +01:00
|
|
|
#ifdef WIN32
|
|
|
|
/* Error codes from windows sockets differ from fileio error codes */
|
|
|
|
#undef EINTR
|
|
|
|
#define EINTR WSAEINTR
|
|
|
|
#undef EINVAL
|
|
|
|
#define EINVAL WSAEINVAL
|
|
|
|
#undef EBADF
|
|
|
|
#define EBADF WSAENOTSOCK
|
|
|
|
/* Windows select does not set errno. Use GetErrno as wrapper for
|
|
|
|
WSAGetLastError */
|
|
|
|
#define GetErrno WSAGetLastError
|
|
|
|
#else
|
|
|
|
/* This is just a fallback to errno to hide the differences between unix and
|
|
|
|
Windows in the code */
|
|
|
|
#define GetErrno() errno
|
|
|
|
#endif
|
|
|
|
|
2009-06-18 18:49:12 +02:00
|
|
|
/* like ffs, but uses fd_mask instead of int as argument, so it works
|
|
|
|
when fd_mask is longer than an int, such as common 64-bit platforms */
|
2003-11-14 17:49:22 +01:00
|
|
|
/* modifications by raphael */
|
|
|
|
int
|
|
|
|
mffs(fd_mask mask)
|
|
|
|
{
|
|
|
|
int i;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!mask)
|
|
|
|
return 0;
|
2003-11-14 17:49:22 +01:00
|
|
|
i = 1;
|
2012-03-21 20:55:09 +01:00
|
|
|
while (!(mask & 1)) {
|
|
|
|
i++;
|
|
|
|
mask >>= 1;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef DPMSExtension
|
2009-07-15 08:51:05 +02:00
|
|
|
#include <X11/extensions/dpmsconst.h>
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
struct _OsTimerRec {
|
2012-03-21 20:55:09 +01:00
|
|
|
OsTimerPtr next;
|
|
|
|
CARD32 expires;
|
|
|
|
CARD32 delta;
|
|
|
|
OsTimerCallback callback;
|
2013-12-15 10:05:51 +01:00
|
|
|
void *arg;
|
2003-11-14 16:54:54 +01:00
|
|
|
};
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
|
2007-03-28 20:46:30 +02:00
|
|
|
static void CheckAllTimers(void);
|
2003-11-25 20:29:01 +01:00
|
|
|
static OsTimerPtr timers = NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/*****************
|
|
|
|
* WaitForSomething:
|
|
|
|
* Make the server suspend until there is
|
|
|
|
* 1. data from clients or
|
|
|
|
* 2. input events available or
|
|
|
|
* 3. ddx notices something of interest (graphics
|
|
|
|
* queue ready, etc.) or
|
|
|
|
* 4. clients that have buffered replies/events are ready
|
|
|
|
*
|
|
|
|
* If the time between INPUT events is
|
|
|
|
* greater than ScreenSaverTime, the display is turned off (or
|
|
|
|
* saved, depending on the hardware). So, WaitForSomething()
|
|
|
|
* has to handle this also (that's why the select() has a timeout.
|
|
|
|
* For more info on ClientsWithInput, see ReadRequestFromClient().
|
|
|
|
* pClientsReady is an array to store ready client->index values into.
|
|
|
|
*****************/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2003-11-25 20:29:01 +01:00
|
|
|
WaitForSomething(int *pClientsReady)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct timeval waittime, *wt;
|
2003-11-14 17:49:22 +01:00
|
|
|
INT32 timeout = 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
fd_set clientsReadable;
|
|
|
|
fd_set clientsWritable;
|
|
|
|
int curclient;
|
|
|
|
int selecterr;
|
2009-12-14 20:38:10 +01:00
|
|
|
static int nready;
|
2003-11-14 16:54:54 +01:00
|
|
|
fd_set devicesReadable;
|
2003-11-14 17:49:22 +01:00
|
|
|
CARD32 now = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool someReady = FALSE;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
FD_ZERO(&clientsReadable);
|
|
|
|
|
2009-12-14 20:38:10 +01:00
|
|
|
if (nready)
|
|
|
|
SmartScheduleStopTimer();
|
|
|
|
nready = 0;
|
|
|
|
|
2013-11-03 22:12:40 +01:00
|
|
|
#ifdef BUSFAULT
|
|
|
|
busfault_check();
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* We need a while loop here to handle
|
|
|
|
crashed connections and the screen saver timeout */
|
2012-03-21 20:55:09 +01:00
|
|
|
while (1) {
|
|
|
|
/* deal with any blocked jobs */
|
|
|
|
if (workQueue)
|
|
|
|
ProcessWorkQueue();
|
|
|
|
if (XFD_ANYSET(&ClientsWithInput)) {
|
|
|
|
if (!SmartScheduleDisable) {
|
|
|
|
someReady = TRUE;
|
|
|
|
waittime.tv_sec = 0;
|
|
|
|
waittime.tv_usec = 0;
|
|
|
|
wt = &waittime;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
XFD_COPYSET(&ClientsWithInput, &clientsReadable);
|
|
|
|
break;
|
2006-10-25 22:55:43 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
if (someReady) {
|
|
|
|
XFD_COPYSET(&AllSockets, &LastSelectMask);
|
|
|
|
XFD_UNSET(&LastSelectMask, &ClientsWithInput);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wt = NULL;
|
|
|
|
if (timers) {
|
|
|
|
now = GetTimeInMillis();
|
|
|
|
timeout = timers->expires - now;
|
|
|
|
if (timeout > 0 && timeout > timers->delta + 250) {
|
|
|
|
/* time has rewound. reset the timers. */
|
|
|
|
CheckAllTimers();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timers) {
|
|
|
|
timeout = timers->expires - now;
|
|
|
|
if (timeout < 0)
|
|
|
|
timeout = 0;
|
|
|
|
waittime.tv_sec = timeout / MILLI_PER_SECOND;
|
|
|
|
waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
|
|
|
|
(1000000 / MILLI_PER_SECOND);
|
|
|
|
wt = &waittime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XFD_COPYSET(&AllSockets, &LastSelectMask);
|
|
|
|
}
|
2006-10-29 02:40:57 +02:00
|
|
|
|
2013-12-15 10:05:51 +01:00
|
|
|
BlockHandler((void *) &wt, (void *) &LastSelectMask);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (NewOutputPending)
|
|
|
|
FlushAllOutput();
|
|
|
|
/* keep this check close to select() call to minimize race */
|
|
|
|
if (dispatchException)
|
|
|
|
i = -1;
|
|
|
|
else if (AnyClientsWriteBlocked) {
|
|
|
|
XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
|
|
|
|
i = Select(MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
|
|
|
|
}
|
|
|
|
selecterr = GetErrno();
|
2013-12-15 10:05:51 +01:00
|
|
|
WakeupHandler(i, (void *) &LastSelectMask);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (i <= 0) { /* An error or timeout occurred */
|
|
|
|
if (dispatchException)
|
|
|
|
return 0;
|
|
|
|
if (i < 0) {
|
|
|
|
if (selecterr == EBADF) { /* Some client disconnected */
|
|
|
|
CheckConnections();
|
|
|
|
if (!XFD_ANYSET(&AllClients))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (selecterr == EINVAL) {
|
|
|
|
FatalError("WaitForSomething(): select: %s\n",
|
|
|
|
strerror(selecterr));
|
|
|
|
}
|
|
|
|
else if (selecterr != EINTR && selecterr != EAGAIN) {
|
|
|
|
ErrorF("WaitForSomething(): select: %s\n",
|
|
|
|
strerror(selecterr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (someReady) {
|
|
|
|
/*
|
|
|
|
* If no-one else is home, bail quickly
|
|
|
|
*/
|
|
|
|
XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
|
|
|
|
XFD_COPYSET(&ClientsWithInput, &clientsReadable);
|
|
|
|
break;
|
2004-11-15 16:06:51 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (*checkForInput[0] != *checkForInput[1])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (timers) {
|
2003-11-25 20:29:01 +01:00
|
|
|
int expired = 0;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
now = GetTimeInMillis();
|
|
|
|
if ((int) (timers->expires - now) <= 0)
|
|
|
|
expired = 1;
|
|
|
|
|
|
|
|
while (timers && (int) (timers->expires - now) <= 0)
|
|
|
|
DoTimer(timers, now, &timers);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
if (expired)
|
|
|
|
return 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fd_set tmp_set;
|
|
|
|
|
|
|
|
if (*checkForInput[0] == *checkForInput[1]) {
|
|
|
|
if (timers) {
|
2003-11-25 20:29:01 +01:00
|
|
|
int expired = 0;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
now = GetTimeInMillis();
|
|
|
|
if ((int) (timers->expires - now) <= 0)
|
|
|
|
expired = 1;
|
|
|
|
|
|
|
|
while (timers && (int) (timers->expires - now) <= 0)
|
|
|
|
DoTimer(timers, now, &timers);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
if (expired)
|
|
|
|
return 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (someReady)
|
|
|
|
XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
|
|
|
|
if (AnyClientsWriteBlocked && XFD_ANYSET(&clientsWritable)) {
|
|
|
|
NewOutputPending = TRUE;
|
|
|
|
XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
|
|
|
|
XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
|
|
|
|
if (!XFD_ANYSET(&ClientsWriteBlocked))
|
|
|
|
AnyClientsWriteBlocked = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
|
|
|
|
XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
|
|
|
|
XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
|
|
|
|
if (XFD_ANYSET(&tmp_set))
|
|
|
|
QueueWorkProc(EstablishNewConnections, NULL,
|
2013-12-15 10:05:51 +01:00
|
|
|
(void *) &LastSelectMask);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (XFD_ANYSET(&devicesReadable) || XFD_ANYSET(&clientsReadable))
|
|
|
|
break;
|
|
|
|
/* check here for DDXes that queue events during Block/Wakeup */
|
|
|
|
if (*checkForInput[0] != *checkForInput[1])
|
|
|
|
return 0;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nready = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XFD_ANYSET(&clientsReadable)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifndef WIN32
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) {
|
|
|
|
int highest_priority = 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
while (clientsReadable.fds_bits[i]) {
|
|
|
|
int client_priority, client_index;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
curclient = mffs(clientsReadable.fds_bits[i]) - 1;
|
|
|
|
client_index = /* raphael: modified */
|
|
|
|
ConnectionTranslation[curclient +
|
|
|
|
(i * (sizeof(fd_mask) * 8))];
|
2003-11-14 16:54:54 +01:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
int highest_priority = 0;
|
|
|
|
fd_set savedClientsReadable;
|
|
|
|
|
|
|
|
XFD_COPYSET(&clientsReadable, &savedClientsReadable);
|
|
|
|
for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++) {
|
|
|
|
int client_priority, client_index;
|
|
|
|
|
|
|
|
curclient = XFD_FD(&savedClientsReadable, i);
|
|
|
|
client_index = GetConnectionTranslation(curclient);
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
/* We implement "strict" priorities.
|
|
|
|
* Only the highest priority client is returned to
|
|
|
|
* dix. If multiple clients at the same priority are
|
|
|
|
* ready, they are all returned. This means that an
|
|
|
|
* aggressive client could take over the server.
|
|
|
|
* This was not considered a big problem because
|
|
|
|
* aggressive clients can hose the server in so many
|
|
|
|
* other ways :)
|
|
|
|
*/
|
|
|
|
client_priority = clients[client_index]->priority;
|
|
|
|
if (nready == 0 || client_priority > highest_priority) {
|
|
|
|
/* Either we found the first client, or we found
|
|
|
|
* a client whose priority is greater than all others
|
|
|
|
* that have been found so far. Either way, we want
|
|
|
|
* to initialize the list of clients to contain just
|
|
|
|
* this client.
|
|
|
|
*/
|
|
|
|
pClientsReady[0] = client_index;
|
|
|
|
highest_priority = client_priority;
|
|
|
|
nready = 1;
|
|
|
|
}
|
|
|
|
/* the following if makes sure that multiple same-priority
|
|
|
|
* clients get batched together
|
|
|
|
*/
|
|
|
|
else if (client_priority == highest_priority) {
|
|
|
|
pClientsReady[nready++] = client_index;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifndef WIN32
|
2012-03-21 20:55:09 +01:00
|
|
|
clientsReadable.fds_bits[i] &= ~(((fd_mask) 1L) << curclient);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
FD_CLR(curclient, &clientsReadable);
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2009-12-14 20:38:10 +01:00
|
|
|
|
|
|
|
if (nready)
|
|
|
|
SmartScheduleStartTimer();
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return nready;
|
|
|
|
}
|
|
|
|
|
2006-10-25 22:55:43 +02:00
|
|
|
/* If time has rewound, re-run every affected timer.
|
2006-10-29 02:40:57 +02:00
|
|
|
* Timers might drop out of the list, so we have to restart every time. */
|
2006-10-25 22:55:43 +02:00
|
|
|
static void
|
2007-03-28 20:46:30 +02:00
|
|
|
CheckAllTimers(void)
|
2006-10-25 22:55:43 +02:00
|
|
|
{
|
|
|
|
OsTimerPtr timer;
|
2007-03-28 20:46:30 +02:00
|
|
|
CARD32 now;
|
2006-10-25 22:55:43 +02:00
|
|
|
|
2012-04-27 02:52:39 +02:00
|
|
|
OsBlockSignals();
|
2012-03-21 20:55:09 +01:00
|
|
|
start:
|
2007-03-28 20:46:30 +02:00
|
|
|
now = GetTimeInMillis();
|
|
|
|
|
2006-10-25 22:55:43 +02:00
|
|
|
for (timer = timers; timer; timer = timer->next) {
|
2006-10-29 02:40:57 +02:00
|
|
|
if (timer->expires - now > timer->delta + 250) {
|
2006-10-25 22:55:43 +02:00
|
|
|
TimerForce(timer);
|
2006-10-29 02:40:57 +02:00
|
|
|
goto start;
|
|
|
|
}
|
2006-10-25 22:55:43 +02:00
|
|
|
}
|
2012-04-27 02:52:39 +02:00
|
|
|
OsReleaseSignals();
|
2006-10-25 22:55:43 +02:00
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
static void
|
2003-11-14 17:49:22 +01:00
|
|
|
DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
CARD32 newTime;
|
|
|
|
|
2012-04-27 02:52:39 +02:00
|
|
|
OsBlockSignals();
|
2003-11-14 16:54:54 +01:00
|
|
|
*prev = timer->next;
|
|
|
|
timer->next = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
newTime = (*timer->callback) (timer, now, timer->arg);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (newTime)
|
2012-03-21 20:55:09 +01:00
|
|
|
TimerSet(timer, 0, newTime, timer->callback, timer->arg);
|
2012-04-27 02:52:39 +02:00
|
|
|
OsReleaseSignals();
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
OsTimerPtr
|
2012-03-21 20:55:09 +01:00
|
|
|
TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
|
2013-12-15 10:05:51 +01:00
|
|
|
OsTimerCallback func, void *arg)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
register OsTimerPtr *prev;
|
|
|
|
CARD32 now = GetTimeInMillis();
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!timer) {
|
|
|
|
timer = malloc(sizeof(struct _OsTimerRec));
|
|
|
|
if (!timer)
|
|
|
|
return NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
2012-04-27 02:52:39 +02:00
|
|
|
OsBlockSignals();
|
2012-03-21 20:55:09 +01:00
|
|
|
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
|
|
|
if (*prev == timer) {
|
|
|
|
*prev = timer->next;
|
|
|
|
if (flags & TimerForceOld)
|
|
|
|
(void) (*timer->callback) (timer, now, timer->arg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-04-27 02:52:39 +02:00
|
|
|
OsReleaseSignals();
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
if (!millis)
|
2012-03-21 20:55:09 +01:00
|
|
|
return timer;
|
2006-10-25 22:55:43 +02:00
|
|
|
if (flags & TimerAbsolute) {
|
|
|
|
timer->delta = millis - now;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
timer->delta = millis;
|
2012-03-21 20:55:09 +01:00
|
|
|
millis += now;
|
2006-10-25 22:55:43 +02:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
timer->expires = millis;
|
|
|
|
timer->callback = func;
|
|
|
|
timer->arg = arg;
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((int) (millis - now) <= 0) {
|
|
|
|
timer->next = NULL;
|
|
|
|
millis = (*timer->callback) (timer, now, timer->arg);
|
|
|
|
if (!millis)
|
|
|
|
return timer;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-04-27 02:52:39 +02:00
|
|
|
OsBlockSignals();
|
2003-11-14 16:54:54 +01:00
|
|
|
for (prev = &timers;
|
2012-03-21 20:55:09 +01:00
|
|
|
*prev && (int) ((*prev)->expires - millis) <= 0;
|
|
|
|
prev = &(*prev)->next);
|
2003-11-14 16:54:54 +01:00
|
|
|
timer->next = *prev;
|
|
|
|
*prev = timer;
|
2012-04-27 02:52:39 +02:00
|
|
|
OsReleaseSignals();
|
2003-11-14 16:54:54 +01:00
|
|
|
return timer;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-25 20:29:01 +01:00
|
|
|
TimerForce(OsTimerPtr timer)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-04-27 02:52:39 +02:00
|
|
|
int rc = FALSE;
|
2003-11-25 20:29:01 +01:00
|
|
|
OsTimerPtr *prev;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-04-27 02:52:39 +02:00
|
|
|
OsBlockSignals();
|
2012-03-21 20:55:09 +01:00
|
|
|
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
|
|
|
if (*prev == timer) {
|
|
|
|
DoTimer(timer, GetTimeInMillis(), prev);
|
2012-04-27 02:52:39 +02:00
|
|
|
rc = TRUE;
|
|
|
|
break;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-04-27 02:52:39 +02:00
|
|
|
OsReleaseSignals();
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
TimerCancel(OsTimerPtr timer)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2003-11-25 20:29:01 +01:00
|
|
|
OsTimerPtr *prev;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
if (!timer)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2012-04-27 02:52:39 +02:00
|
|
|
OsBlockSignals();
|
2012-03-21 20:55:09 +01:00
|
|
|
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
|
|
|
if (*prev == timer) {
|
|
|
|
*prev = timer->next;
|
|
|
|
break;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-04-27 02:52:39 +02:00
|
|
|
OsReleaseSignals();
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
TimerFree(OsTimerPtr timer)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (!timer)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2003-11-14 16:54:54 +01:00
|
|
|
TimerCancel(timer);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(timer);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
TimerCheck(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2003-11-25 20:29:01 +01:00
|
|
|
CARD32 now = GetTimeInMillis();
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
while (timers && (int) (timers->expires - now) <= 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
DoTimer(timers, now, &timers);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
TimerInit(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
OsTimerPtr timer;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
while ((timer = timers)) {
|
|
|
|
timers = timer->next;
|
|
|
|
free(timer);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2006-03-24 21:50:13 +01:00
|
|
|
#ifdef DPMSExtension
|
|
|
|
|
|
|
|
#define DPMS_CHECK_MODE(mode,time)\
|
|
|
|
if (time > 0 && DPMSPowerLevel < mode && timeout >= time)\
|
2007-08-16 16:36:05 +02:00
|
|
|
DPMSSet(serverClient, mode);
|
2006-03-24 21:50:13 +01:00
|
|
|
|
|
|
|
#define DPMS_CHECK_TIMEOUT(time)\
|
|
|
|
if (time > 0 && (time - timeout) > 0)\
|
|
|
|
return time - timeout;
|
|
|
|
|
|
|
|
static CARD32
|
|
|
|
NextDPMSTimeout(INT32 timeout)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Return the amount of time remaining until we should set
|
|
|
|
* the next power level. Fallthroughs are intentional.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
switch (DPMSPowerLevel) {
|
|
|
|
case DPMSModeOn:
|
|
|
|
DPMS_CHECK_TIMEOUT(DPMSStandbyTime)
|
2006-03-24 21:50:13 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case DPMSModeStandby:
|
|
|
|
DPMS_CHECK_TIMEOUT(DPMSSuspendTime)
|
2006-03-24 21:50:13 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case DPMSModeSuspend:
|
|
|
|
DPMS_CHECK_TIMEOUT(DPMSOffTime)
|
2006-03-24 21:50:13 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
default: /* DPMSModeOff */
|
|
|
|
return 0;
|
2006-03-24 21:50:13 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* DPMSExtension */
|
2006-03-24 21:50:13 +01:00
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
static CARD32
|
2013-12-15 10:05:51 +01:00
|
|
|
ScreenSaverTimeoutExpire(OsTimerPtr timer, CARD32 now, void *arg)
|
2003-11-25 20:29:01 +01:00
|
|
|
{
|
2013-10-16 01:36:01 +02:00
|
|
|
INT32 timeout = now - LastEventTime(XIAllDevices).milliseconds;
|
2006-03-24 21:50:13 +01:00
|
|
|
CARD32 nextTimeout = 0;
|
|
|
|
|
|
|
|
#ifdef DPMSExtension
|
|
|
|
/*
|
|
|
|
* Check each mode lowest to highest, since a lower mode can
|
|
|
|
* have the same timeout as a higher one.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (DPMSEnabled) {
|
|
|
|
DPMS_CHECK_MODE(DPMSModeOff, DPMSOffTime)
|
|
|
|
DPMS_CHECK_MODE(DPMSModeSuspend, DPMSSuspendTime)
|
|
|
|
DPMS_CHECK_MODE(DPMSModeStandby, DPMSStandbyTime)
|
2006-03-24 21:50:13 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
nextTimeout = NextDPMSTimeout(timeout);
|
2006-03-24 21:50:13 +01:00
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2006-03-24 21:50:13 +01:00
|
|
|
/*
|
|
|
|
* Only do the screensaver checks if we're not in a DPMS
|
|
|
|
* power saving mode
|
|
|
|
*/
|
|
|
|
if (DPMSPowerLevel != DPMSModeOn)
|
2012-03-21 20:55:09 +01:00
|
|
|
return nextTimeout;
|
|
|
|
#endif /* DPMSExtension */
|
2006-03-24 21:50:13 +01:00
|
|
|
|
|
|
|
if (!ScreenSaverTime)
|
2012-03-21 20:55:09 +01:00
|
|
|
return nextTimeout;
|
2006-03-24 21:50:13 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (timeout < ScreenSaverTime) {
|
|
|
|
return nextTimeout > 0 ?
|
|
|
|
min(ScreenSaverTime - timeout, nextTimeout) :
|
|
|
|
ScreenSaverTime - timeout;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ResetOsBuffers(); /* not ideal, but better than nothing */
|
2007-11-19 22:55:09 +01:00
|
|
|
dixSaveScreens(serverClient, SCREEN_SAVER_ON, ScreenSaverActive);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (ScreenSaverInterval > 0) {
|
|
|
|
nextTimeout = nextTimeout > 0 ?
|
|
|
|
min(ScreenSaverInterval, nextTimeout) : ScreenSaverInterval;
|
2006-03-24 21:50:13 +01:00
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2006-03-24 21:50:13 +01:00
|
|
|
return nextTimeout;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static OsTimerPtr ScreenSaverTimer = NULL;
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
FreeScreenSaverTimer(void)
|
|
|
|
{
|
|
|
|
if (ScreenSaverTimer) {
|
2012-03-21 20:55:09 +01:00
|
|
|
TimerFree(ScreenSaverTimer);
|
|
|
|
ScreenSaverTimer = NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
SetScreenSaverTimer(void)
|
|
|
|
{
|
2006-03-24 21:50:13 +01:00
|
|
|
CARD32 timeout = 0;
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
#ifdef DPMSExtension
|
2012-03-21 20:55:09 +01:00
|
|
|
if (DPMSEnabled) {
|
|
|
|
/*
|
|
|
|
* A higher DPMS level has a timeout that's either less
|
|
|
|
* than or equal to that of a lower DPMS level.
|
|
|
|
*/
|
|
|
|
if (DPMSStandbyTime > 0)
|
|
|
|
timeout = DPMSStandbyTime;
|
|
|
|
|
|
|
|
else if (DPMSSuspendTime > 0)
|
|
|
|
timeout = DPMSSuspendTime;
|
|
|
|
|
|
|
|
else if (DPMSOffTime > 0)
|
|
|
|
timeout = DPMSOffTime;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
2006-03-24 21:50:13 +01:00
|
|
|
#endif
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (ScreenSaverTime > 0) {
|
|
|
|
timeout = timeout > 0 ? min(ScreenSaverTime, timeout) : ScreenSaverTime;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
2006-03-31 20:49:38 +02:00
|
|
|
#ifdef SCREENSAVER
|
|
|
|
if (timeout && !screenSaverSuspended) {
|
|
|
|
#else
|
2006-03-24 21:50:13 +01:00
|
|
|
if (timeout) {
|
2006-03-31 20:49:38 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, timeout,
|
|
|
|
ScreenSaverTimeoutExpire, NULL);
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
2006-03-24 21:50:13 +01:00
|
|
|
else if (ScreenSaverTimer) {
|
2012-03-21 20:55:09 +01:00
|
|
|
FreeScreenSaverTimer();
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
}
|