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
|
|
|
|
|
2014-10-31 00:45:12 +01:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2003-11-14 16:54:54 +01:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2014-10-31 00:45:12 +01:00
|
|
|
both that copyright notice and this permission notice appear in
|
2003-11-14 16:54:54 +01:00
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2014-10-31 00:45:12 +01:00
|
|
|
software without specific, written prior permission.
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
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"
|
|
|
|
#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
|
2014-10-31 00:45:12 +01:00
|
|
|
/* Windows select does not set errno. Use GetErrno as wrapper for
|
2004-12-02 22:49:54 +01:00
|
|
|
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
|
|
|
|
|
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 {
|
2016-05-30 04:48:25 +02:00
|
|
|
struct xorg_list list;
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD32 expires;
|
|
|
|
CARD32 delta;
|
|
|
|
OsTimerCallback callback;
|
2013-12-15 10:05:51 +01:00
|
|
|
void *arg;
|
2003-11-14 16:54:54 +01:00
|
|
|
};
|
|
|
|
|
2016-05-30 04:48:25 +02:00
|
|
|
static void DoTimer(OsTimerPtr timer, CARD32 now);
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
static void DoTimers(CARD32 now);
|
2007-03-28 20:46:30 +02:00
|
|
|
static void CheckAllTimers(void);
|
2016-05-30 04:48:25 +02:00
|
|
|
static volatile struct xorg_list timers;
|
|
|
|
|
|
|
|
static inline OsTimerPtr
|
|
|
|
first_timer(void)
|
|
|
|
{
|
|
|
|
/* inline xorg_list_is_empty which can't handle volatile */
|
|
|
|
if (timers.next == &timers)
|
|
|
|
return NULL;
|
|
|
|
return xorg_list_first_entry(&timers, struct _OsTimerRec, list);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
/*
|
|
|
|
* Compute timeout until next timer, running
|
|
|
|
* any expired timers
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
check_timers(void)
|
|
|
|
{
|
|
|
|
OsTimerPtr timer;
|
|
|
|
|
2016-12-08 05:32:06 +01:00
|
|
|
if ((timer = first_timer()) != NULL) {
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
CARD32 now = GetTimeInMillis();
|
|
|
|
int timeout = timer->expires - now;
|
|
|
|
|
|
|
|
if (timeout <= 0) {
|
|
|
|
DoTimers(now);
|
|
|
|
} else {
|
|
|
|
/* Make sure the timeout is sane */
|
|
|
|
if (timeout < timer->delta + 250)
|
|
|
|
return timeout;
|
|
|
|
|
|
|
|
/* time has rewound. reset the timers. */
|
|
|
|
CheckAllTimers();
|
|
|
|
}
|
2016-12-08 05:32:06 +01:00
|
|
|
|
|
|
|
return 0;
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*****************/
|
|
|
|
|
2016-05-19 22:59:54 +02:00
|
|
|
Bool
|
|
|
|
WaitForSomething(Bool are_ready)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
2016-05-26 19:30:56 +02:00
|
|
|
int timeout;
|
2016-05-26 19:40:44 +02:00
|
|
|
int pollerr;
|
|
|
|
static Bool were_ready;
|
|
|
|
Bool timer_is_running;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2016-05-26 19:40:44 +02:00
|
|
|
timer_is_running = were_ready;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2016-05-26 19:40:44 +02:00
|
|
|
if (were_ready && !are_ready) {
|
|
|
|
timer_is_running = FALSE;
|
2009-12-14 20:38:10 +01:00
|
|
|
SmartScheduleStopTimer();
|
2016-05-26 19:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
were_ready = FALSE;
|
2009-12-14 20:38:10 +01:00
|
|
|
|
2013-11-03 22:12:40 +01:00
|
|
|
#ifdef BUSFAULT
|
|
|
|
busfault_check();
|
|
|
|
#endif
|
|
|
|
|
2014-10-31 00:45:12 +01:00
|
|
|
/* We need a while loop here to handle
|
2003-11-14 16:54:54 +01:00
|
|
|
crashed connections and the screen saver timeout */
|
2012-03-21 20:55:09 +01:00
|
|
|
while (1) {
|
|
|
|
/* deal with any blocked jobs */
|
2016-10-28 17:04:43 +02:00
|
|
|
if (workQueue) {
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcessWorkQueue();
|
2016-10-28 17:04:43 +02:00
|
|
|
}
|
2016-05-19 22:59:54 +02:00
|
|
|
|
2018-04-15 16:40:03 +02:00
|
|
|
timeout = check_timers();
|
2018-06-19 01:24:28 +02:00
|
|
|
are_ready = clients_are_ready();
|
|
|
|
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
if (are_ready)
|
2016-05-26 19:30:56 +02:00
|
|
|
timeout = 0;
|
2006-10-29 02:40:57 +02:00
|
|
|
|
2016-05-26 19:30:56 +02:00
|
|
|
BlockHandler(&timeout);
|
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;
|
2016-05-26 19:40:44 +02:00
|
|
|
else
|
|
|
|
i = ospoll_wait(server_poll, timeout);
|
|
|
|
pollerr = GetErrno();
|
2015-09-02 03:51:14 +02:00
|
|
|
WakeupHandler(i);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (i <= 0) { /* An error or timeout occurred */
|
|
|
|
if (dispatchException)
|
2016-05-19 22:59:54 +02:00
|
|
|
return FALSE;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (i < 0) {
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
if (pollerr != EINTR && !ETEST(pollerr)) {
|
2016-05-26 19:40:44 +02:00
|
|
|
ErrorF("WaitForSomething(): poll: %s\n",
|
|
|
|
strerror(pollerr));
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
} else
|
|
|
|
are_ready = clients_are_ready();
|
2016-05-19 22:59:54 +02:00
|
|
|
|
2016-09-19 10:25:13 +02:00
|
|
|
if (InputCheckPending())
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
return FALSE;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
os: Clean up WaitFor.c
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 02:47:29 +02:00
|
|
|
if (are_ready) {
|
|
|
|
were_ready = TRUE;
|
|
|
|
if (!timer_is_running)
|
|
|
|
SmartScheduleStartTimer();
|
|
|
|
return TRUE;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 19:30:56 +02:00
|
|
|
void
|
|
|
|
AdjustWaitForDelay(void *waitTime, int newdelay)
|
|
|
|
{
|
|
|
|
int *timeoutp = waitTime;
|
|
|
|
int timeout = *timeoutp;
|
|
|
|
|
|
|
|
if (timeout < 0 || newdelay < timeout)
|
|
|
|
*timeoutp = newdelay;
|
|
|
|
}
|
|
|
|
|
2016-05-30 04:48:25 +02:00
|
|
|
static inline Bool timer_pending(OsTimerPtr timer) {
|
|
|
|
return !xorg_list_is_empty(&timer->list);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-06-05 21:32:19 +02:00
|
|
|
input_lock();
|
2012-03-21 20:55:09 +01:00
|
|
|
start:
|
2007-03-28 20:46:30 +02:00
|
|
|
now = GetTimeInMillis();
|
|
|
|
|
2016-05-30 04:48:25 +02:00
|
|
|
xorg_list_for_each_entry(timer, &timers, list) {
|
2006-10-29 02:40:57 +02:00
|
|
|
if (timer->expires - now > timer->delta + 250) {
|
2016-05-30 04:48:25 +02:00
|
|
|
DoTimer(timer, now);
|
2006-10-29 02:40:57 +02:00
|
|
|
goto start;
|
|
|
|
}
|
2006-10-25 22:55:43 +02:00
|
|
|
}
|
2016-06-05 21:32:19 +02:00
|
|
|
input_unlock();
|
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
|
2016-05-30 04:48:25 +02:00
|
|
|
DoTimer(OsTimerPtr timer, CARD32 now)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
CARD32 newTime;
|
|
|
|
|
2016-05-30 04:48:25 +02:00
|
|
|
xorg_list_del(&timer->list);
|
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);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2016-05-30 04:48:25 +02:00
|
|
|
static void
|
|
|
|
DoTimers(CARD32 now)
|
|
|
|
{
|
|
|
|
OsTimerPtr timer;
|
|
|
|
|
|
|
|
input_lock();
|
|
|
|
while ((timer = first_timer())) {
|
|
|
|
if ((int) (timer->expires - now) > 0)
|
|
|
|
break;
|
|
|
|
DoTimer(timer, now);
|
|
|
|
}
|
|
|
|
input_unlock();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2018-04-15 16:40:05 +02:00
|
|
|
OsTimerPtr existing;
|
2003-11-14 16:54:54 +01:00
|
|
|
CARD32 now = GetTimeInMillis();
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!timer) {
|
2016-05-30 04:48:25 +02:00
|
|
|
timer = calloc(1, sizeof(struct _OsTimerRec));
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!timer)
|
|
|
|
return NULL;
|
2016-05-30 04:48:25 +02:00
|
|
|
xorg_list_init(&timer->list);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
2016-06-05 21:32:19 +02:00
|
|
|
input_lock();
|
2016-05-30 04:48:25 +02:00
|
|
|
if (timer_pending(timer)) {
|
|
|
|
xorg_list_del(&timer->list);
|
|
|
|
if (flags & TimerForceOld)
|
|
|
|
(void) (*timer->callback) (timer, now, timer->arg);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2016-06-05 21:32:19 +02:00
|
|
|
input_unlock();
|
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;
|
2016-06-05 21:32:19 +02:00
|
|
|
input_lock();
|
2016-05-30 04:48:25 +02:00
|
|
|
|
|
|
|
/* Sort into list */
|
2018-04-15 16:40:05 +02:00
|
|
|
xorg_list_for_each_entry(existing, &timers, list)
|
2016-05-30 04:48:25 +02:00
|
|
|
if ((int) (existing->expires - millis) > 0)
|
|
|
|
break;
|
|
|
|
/* This even works at the end of the list -- existing->list will be timers */
|
2018-04-15 16:40:04 +02:00
|
|
|
xorg_list_append(&timer->list, &existing->list);
|
2016-05-30 04:48:25 +02:00
|
|
|
|
|
|
|
/* Check to see if the timer is ready to run now */
|
|
|
|
if ((int) (millis - now) <= 0)
|
|
|
|
DoTimer(timer, now);
|
|
|
|
|
2016-06-05 21:32:19 +02:00
|
|
|
input_unlock();
|
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
|
|
|
{
|
2016-05-30 04:48:25 +02:00
|
|
|
int pending;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2016-06-05 21:32:19 +02:00
|
|
|
input_lock();
|
2016-05-30 04:48:25 +02:00
|
|
|
pending = timer_pending(timer);
|
|
|
|
if (pending)
|
|
|
|
DoTimer(timer, GetTimeInMillis());
|
2016-06-05 21:32:19 +02:00
|
|
|
input_unlock();
|
2016-05-30 04:48:25 +02:00
|
|
|
return pending;
|
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
|
|
|
{
|
|
|
|
if (!timer)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2016-06-05 21:32:19 +02:00
|
|
|
input_lock();
|
2016-05-30 04:48:25 +02:00
|
|
|
xorg_list_del(&timer->list);
|
2016-06-05 21:32:19 +02:00
|
|
|
input_unlock();
|
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
|
|
|
{
|
2016-05-30 04:48:25 +02:00
|
|
|
DoTimers(GetTimeInMillis());
|
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
|
|
|
{
|
2016-05-30 04:48:25 +02:00
|
|
|
static Bool been_here;
|
|
|
|
OsTimerPtr timer, tmp;
|
|
|
|
|
|
|
|
if (!been_here) {
|
|
|
|
been_here = TRUE;
|
|
|
|
xorg_list_init((struct xorg_list*) &timers);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2016-05-30 04:48:25 +02:00
|
|
|
xorg_list_for_each_entry_safe(timer, tmp, &timers, list) {
|
|
|
|
xorg_list_del(&timer->list);
|
2012-03-21 20:55:09 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|