diff options
author | marha <marha@users.sourceforge.net> | 2012-03-26 14:23:28 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-26 14:23:28 +0200 |
commit | 76bcc36ed305418a3ddc5752d287ede894243e1b (patch) | |
tree | bacb320c825768471ce56f058f17ce863d592376 /xorg-server/os/WaitFor.c | |
parent | 7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff) | |
parent | 0f834b91a4768673833ab4917e87d86c237bb1a6 (diff) | |
download | vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2 vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
pixman/pixman/pixman-mmx.c
xorg-server/Xext/shm.c
xorg-server/Xext/syncsrv.h
xorg-server/Xext/xvmain.c
xorg-server/Xi/exevents.c
xorg-server/Xi/opendev.c
xorg-server/composite/compalloc.c
xorg-server/composite/compoverlay.c
xorg-server/dix/colormap.c
xorg-server/dix/devices.c
xorg-server/dix/dispatch.c
xorg-server/dix/dixfonts.c
xorg-server/dix/eventconvert.c
xorg-server/dix/events.c
xorg-server/dix/gc.c
xorg-server/dix/getevents.c
xorg-server/dix/main.c
xorg-server/dix/privates.c
xorg-server/dix/registry.c
xorg-server/dix/resource.c
xorg-server/exa/exa_accel.c
xorg-server/exa/exa_migration_classic.c
xorg-server/exa/exa_unaccel.c
xorg-server/fb/fb.h
xorg-server/fb/fbcopy.c
xorg-server/fb/fbpixmap.c
xorg-server/glx/dispatch.h
xorg-server/glx/glapi.h
xorg-server/glx/glapi_gentable.c
xorg-server/glx/glapitable.h
xorg-server/glx/glprocs.h
xorg-server/glx/glxcmds.c
xorg-server/glx/glxcmdsswap.c
xorg-server/glx/glxdricommon.c
xorg-server/glx/glxdriswrast.c
xorg-server/glx/glxext.c
xorg-server/glx/indirect_dispatch.c
xorg-server/glx/indirect_dispatch.h
xorg-server/glx/indirect_dispatch_swap.c
xorg-server/glx/indirect_size.h
xorg-server/glx/indirect_size_get.h
xorg-server/glx/indirect_table.c
xorg-server/glx/indirect_util.c
xorg-server/glx/rensize.c
xorg-server/glx/single2swap.c
xorg-server/glx/singlepix.c
xorg-server/glx/singlepixswap.c
xorg-server/glx/singlesize.c
xorg-server/hw/dmx/dmxinit.c
xorg-server/hw/kdrive/ephyr/ephyr.c
xorg-server/hw/kdrive/ephyr/hostx.c
xorg-server/hw/kdrive/ephyr/hostx.h
xorg-server/hw/kdrive/src/kinput.c
xorg-server/hw/xfree86/common/compiler.h
xorg-server/hw/xwin/InitInput.c
xorg-server/hw/xwin/InitOutput.c
xorg-server/hw/xwin/ddraw.h
xorg-server/hw/xwin/glx/glwrap.c
xorg-server/hw/xwin/glx/indirect.c
xorg-server/hw/xwin/glx/wgl_ext_api.h
xorg-server/hw/xwin/glx/winpriv.c
xorg-server/hw/xwin/win.h
xorg-server/hw/xwin/winallpriv.c
xorg-server/hw/xwin/winauth.c
xorg-server/hw/xwin/winclipboard.h
xorg-server/hw/xwin/winclipboardinit.c
xorg-server/hw/xwin/winclipboardthread.c
xorg-server/hw/xwin/winclipboardunicode.c
xorg-server/hw/xwin/winclipboardwndproc.c
xorg-server/hw/xwin/winclipboardwrappers.c
xorg-server/hw/xwin/winclipboardxevents.c
xorg-server/hw/xwin/wincmap.c
xorg-server/hw/xwin/winconfig.c
xorg-server/hw/xwin/wincreatewnd.c
xorg-server/hw/xwin/wincursor.c
xorg-server/hw/xwin/windialogs.c
xorg-server/hw/xwin/winengine.c
xorg-server/hw/xwin/winerror.c
xorg-server/hw/xwin/wingc.c
xorg-server/hw/xwin/wingetsp.c
xorg-server/hw/xwin/winkeybd.c
xorg-server/hw/xwin/winkeybd.h
xorg-server/hw/xwin/winlayouts.h
xorg-server/hw/xwin/winmisc.c
xorg-server/hw/xwin/winmonitors.c
xorg-server/hw/xwin/winmouse.c
xorg-server/hw/xwin/winmsg.c
xorg-server/hw/xwin/winmsg.h
xorg-server/hw/xwin/winmultiwindowclass.c
xorg-server/hw/xwin/winmultiwindowicons.c
xorg-server/hw/xwin/winmultiwindowshape.c
xorg-server/hw/xwin/winmultiwindowwindow.c
xorg-server/hw/xwin/winmultiwindowwm.c
xorg-server/hw/xwin/winmultiwindowwndproc.c
xorg-server/hw/xwin/winnativegdi.c
xorg-server/hw/xwin/winpfbdd.c
xorg-server/hw/xwin/winpixmap.c
xorg-server/hw/xwin/winpolyline.c
xorg-server/hw/xwin/winprefs.c
xorg-server/hw/xwin/winprocarg.c
xorg-server/hw/xwin/winregistry.c
xorg-server/hw/xwin/winscrinit.c
xorg-server/hw/xwin/winsetsp.c
xorg-server/hw/xwin/winshaddd.c
xorg-server/hw/xwin/winshadddnl.c
xorg-server/hw/xwin/winshadgdi.c
xorg-server/hw/xwin/wintrayicon.c
xorg-server/hw/xwin/winwin32rootless.c
xorg-server/hw/xwin/winwin32rootlesswindow.c
xorg-server/hw/xwin/winwin32rootlesswndproc.c
xorg-server/hw/xwin/winwindow.c
xorg-server/hw/xwin/winwindow.h
xorg-server/hw/xwin/winwindowswm.c
xorg-server/hw/xwin/winwndproc.c
xorg-server/include/callback.h
xorg-server/include/dixstruct.h
xorg-server/include/misc.h
xorg-server/include/os.h
xorg-server/include/scrnintstr.h
xorg-server/mi/micmap.c
xorg-server/mi/miinitext.c
xorg-server/mi/mioverlay.c
xorg-server/mi/misprite.c
xorg-server/mi/mivaltree.c
xorg-server/mi/miwindow.c
xorg-server/miext/damage/damage.c
xorg-server/miext/rootless/rootlessGC.c
xorg-server/miext/rootless/rootlessWindow.c
xorg-server/os/WaitFor.c
xorg-server/os/access.c
xorg-server/os/connection.c
xorg-server/os/io.c
xorg-server/os/log.c
xorg-server/os/osinit.c
xorg-server/os/utils.c
xorg-server/os/xdmcp.c
xorg-server/os/xprintf.c
xorg-server/os/xstrans.c
xorg-server/render/mipict.c
xorg-server/xkb/xkbActions.c
xorg-server/xkb/xkbInit.c
xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/os/WaitFor.c')
-rw-r--r-- | xorg-server/os/WaitFor.c | 619 |
1 files changed, 287 insertions, 332 deletions
diff --git a/xorg-server/os/WaitFor.c b/xorg-server/os/WaitFor.c index ddfa14903..6c8ede29d 100644 --- a/xorg-server/os/WaitFor.c +++ b/xorg-server/os/WaitFor.c @@ -22,7 +22,6 @@ 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 @@ -45,7 +44,6 @@ SOFTWARE. ******************************************************************/ - /***************************************************************** * OS Dependent input routines: * @@ -61,7 +59,7 @@ SOFTWARE. #ifdef WIN32 #include <X11/Xwinsock.h> #endif -#include <X11/Xos.h> /* for strings, fcntl, time */ +#include <X11/Xos.h> /* for strings, fcntl, time */ #include <errno.h> #include <stdio.h> #include <X11/X.h> @@ -100,12 +98,12 @@ mffs(fd_mask mask) { int i; - if (!mask) return 0; + if (!mask) + return 0; i = 1; - while (!(mask & 1)) - { - i++; - mask >>= 1; + while (!(mask & 1)) { + i++; + mask >>= 1; } return i; } @@ -115,11 +113,11 @@ mffs(fd_mask mask) #endif struct _OsTimerRec { - OsTimerPtr next; - CARD32 expires; - CARD32 delta; - OsTimerCallback callback; - pointer arg; + OsTimerPtr next; + CARD32 expires; + CARD32 delta; + OsTimerCallback callback; + pointer arg; }; static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev); @@ -156,7 +154,7 @@ WaitForSomething(int *pClientsReady) static int nready; fd_set devicesReadable; CARD32 now = 0; - Bool someReady = FALSE; + Bool someReady = FALSE; FD_ZERO(&clientsReadable); @@ -166,235 +164,214 @@ WaitForSomething(int *pClientsReady) /* We need a while loop here to handle crashed connections and the screen saver timeout */ - 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; - } - } - 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(); + 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; } + } + 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; + } + } + if (!wt) + { + wt = &waittime; + waittime.tv_sec = 0; + waittime.tv_usec = 100; + } + XFD_COPYSET(&AllSockets, &LastSelectMask); + } - 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; - } - } - if (!wt) - { - wt = &waittime; - waittime.tv_sec = 0; - waittime.tv_usec = 100; - } - XFD_COPYSET(&AllSockets, &LastSelectMask); - } - - BlockHandler((pointer)&wt, (pointer)&LastSelectMask); - 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(); - WakeupHandler(i, (pointer)&LastSelectMask); - 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)); + BlockHandler((pointer) &wt, (pointer) &LastSelectMask); + 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(); + WakeupHandler(i, (pointer) &LastSelectMask); + 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; } - 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; - } - if (*checkForInput[0] != *checkForInput[1]) - return 0; - - if (timers) - { + if (*checkForInput[0] != *checkForInput[1]) + return 0; + + if (timers) { int expired = 0; - now = GetTimeInMillis(); - if ((int) (timers->expires - now) <= 0) - expired = 1; - while (timers && (int) (timers->expires - now) <= 0) - DoTimer(timers, now, &timers); + now = GetTimeInMillis(); + if ((int) (timers->expires - now) <= 0) + expired = 1; + + while (timers && (int) (timers->expires - now) <= 0) + DoTimer(timers, now, &timers); if (expired) return 0; - } - } - else - { - fd_set tmp_set; - - if (*checkForInput[0] == *checkForInput[1]) { - if (timers) - { + } + } + else { + fd_set tmp_set; + + if (*checkForInput[0] == *checkForInput[1]) { + if (timers) { int expired = 0; - now = GetTimeInMillis(); - if ((int) (timers->expires - now) <= 0) - expired = 1; - while (timers && (int) (timers->expires - now) <= 0) - DoTimer(timers, now, &timers); + now = GetTimeInMillis(); + if ((int) (timers->expires - now) <= 0) + expired = 1; + + while (timers && (int) (timers->expires - now) <= 0) + DoTimer(timers, now, &timers); if (expired) return 0; - } - } - 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, - (pointer)&LastSelectMask); - - 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; - } + } + } + 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, + (pointer) &LastSelectMask); + + 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; + } } nready = 0; - if (XFD_ANYSET (&clientsReadable)) - { + if (XFD_ANYSET(&clientsReadable)) { #ifndef WIN32 - for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++) - { - int highest_priority = 0; + for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) { + int highest_priority = 0; - while (clientsReadable.fds_bits[i]) - { - int client_priority, client_index; + while (clientsReadable.fds_bits[i]) { + int client_priority, client_index; - curclient = mffs (clientsReadable.fds_bits[i]) - 1; - client_index = /* raphael: modified */ - ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))]; + curclient = mffs(clientsReadable.fds_bits[i]) - 1; + client_index = /* raphael: modified */ + ConnectionTranslation[curclient + + (i * (sizeof(fd_mask) * 8))]; #else - 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); + 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); #endif - /* 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; - } + /* 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; + } #ifndef WIN32 - clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient); - } + clientsReadable.fds_bits[i] &= ~(((fd_mask) 1L) << curclient); + } #else - FD_CLR(curclient, &clientsReadable); + FD_CLR(curclient, &clientsReadable); #endif - } + } } if (nready) @@ -411,7 +388,7 @@ CheckAllTimers(void) OsTimerPtr timer; CARD32 now; -start: + start: now = GetTimeInMillis(); for (timer = timers; timer; timer = timer->next) { @@ -429,60 +406,54 @@ DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev) *prev = timer->next; timer->next = NULL; - newTime = (*timer->callback)(timer, now, timer->arg); + newTime = (*timer->callback) (timer, now, timer->arg); if (newTime) - TimerSet(timer, 0, newTime, timer->callback, timer->arg); + TimerSet(timer, 0, newTime, timer->callback, timer->arg); } OsTimerPtr -TimerSet(OsTimerPtr timer, int flags, CARD32 millis, - OsTimerCallback func, pointer arg) +TimerSet(OsTimerPtr timer, int flags, CARD32 millis, + OsTimerCallback func, pointer arg) { register OsTimerPtr *prev; CARD32 now = GetTimeInMillis(); - if (!timer) - { - timer = malloc(sizeof(struct _OsTimerRec)); - if (!timer) - return NULL; + if (!timer) { + timer = malloc(sizeof(struct _OsTimerRec)); + if (!timer) + return NULL; } - else - { - for (prev = &timers; *prev; prev = &(*prev)->next) - { - if (*prev == timer) - { - *prev = timer->next; - if (flags & TimerForceOld) - (void)(*timer->callback)(timer, now, timer->arg); - break; - } - } + else { + for (prev = &timers; *prev; prev = &(*prev)->next) { + if (*prev == timer) { + *prev = timer->next; + if (flags & TimerForceOld) + (void) (*timer->callback) (timer, now, timer->arg); + break; + } + } } if (!millis) - return timer; + return timer; if (flags & TimerAbsolute) { timer->delta = millis - now; } else { timer->delta = millis; - millis += now; + millis += now; } timer->expires = millis; timer->callback = func; timer->arg = arg; - if ((int) (millis - now) <= 0) - { - timer->next = NULL; - millis = (*timer->callback)(timer, now, timer->arg); - if (!millis) - return timer; + if ((int) (millis - now) <= 0) { + timer->next = NULL; + millis = (*timer->callback) (timer, now, timer->arg); + if (!millis) + return timer; } for (prev = &timers; - *prev && (int) ((*prev)->expires - millis) <= 0; - prev = &(*prev)->next) - ; + *prev && (int) ((*prev)->expires - millis) <= 0; + prev = &(*prev)->next); timer->next = *prev; *prev = timer; return timer; @@ -493,32 +464,27 @@ TimerForce(OsTimerPtr timer) { OsTimerPtr *prev; - for (prev = &timers; *prev; prev = &(*prev)->next) - { - if (*prev == timer) - { - DoTimer(timer, GetTimeInMillis(), prev); - return TRUE; - } + for (prev = &timers; *prev; prev = &(*prev)->next) { + if (*prev == timer) { + DoTimer(timer, GetTimeInMillis(), prev); + return TRUE; + } } return FALSE; } - void TimerCancel(OsTimerPtr timer) { OsTimerPtr *prev; if (!timer) - return; - for (prev = &timers; *prev; prev = &(*prev)->next) - { - if (*prev == timer) - { - *prev = timer->next; - break; - } + return; + for (prev = &timers; *prev; prev = &(*prev)->next) { + if (*prev == timer) { + *prev = timer->next; + break; + } } } @@ -526,7 +492,7 @@ void TimerFree(OsTimerPtr timer) { if (!timer) - return; + return; TimerCancel(timer); free(timer); } @@ -537,7 +503,7 @@ TimerCheck(void) CARD32 now = GetTimeInMillis(); while (timers && (int) (timers->expires - now) <= 0) - DoTimer(timers, now, &timers); + DoTimer(timers, now, &timers); } void @@ -545,10 +511,9 @@ TimerInit(void) { OsTimerPtr timer; - while ((timer = timers)) - { - timers = timer->next; - free(timer); + while ((timer = timers)) { + timers = timer->next; + free(timer); } } @@ -569,27 +534,26 @@ NextDPMSTimeout(INT32 timeout) * Return the amount of time remaining until we should set * the next power level. Fallthroughs are intentional. */ - switch (DPMSPowerLevel) - { - case DPMSModeOn: - DPMS_CHECK_TIMEOUT(DPMSStandbyTime) + switch (DPMSPowerLevel) { + case DPMSModeOn: + DPMS_CHECK_TIMEOUT(DPMSStandbyTime) - case DPMSModeStandby: - DPMS_CHECK_TIMEOUT(DPMSSuspendTime) + case DPMSModeStandby: + DPMS_CHECK_TIMEOUT(DPMSSuspendTime) - case DPMSModeSuspend: - DPMS_CHECK_TIMEOUT(DPMSOffTime) + case DPMSModeSuspend: + DPMS_CHECK_TIMEOUT(DPMSOffTime) - default: /* DPMSModeOff */ - return 0; + default: /* DPMSModeOff */ + return 0; } } -#endif /* DPMSExtension */ +#endif /* DPMSExtension */ static CARD32 -ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg) +ScreenSaverTimeoutExpire(OsTimerPtr timer, CARD32 now, pointer arg) { - INT32 timeout = now - lastDeviceEventTime.milliseconds; + INT32 timeout = now - lastDeviceEventTime[XIAllDevices].milliseconds; CARD32 nextTimeout = 0; #ifdef DPMSExtension @@ -597,13 +561,12 @@ ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg) * Check each mode lowest to highest, since a lower mode can * have the same timeout as a higher one. */ - if (DPMSEnabled) - { - DPMS_CHECK_MODE(DPMSModeOff, DPMSOffTime) - DPMS_CHECK_MODE(DPMSModeSuspend, DPMSSuspendTime) - DPMS_CHECK_MODE(DPMSModeStandby, DPMSStandbyTime) + if (DPMSEnabled) { + DPMS_CHECK_MODE(DPMSModeOff, DPMSOffTime) + DPMS_CHECK_MODE(DPMSModeSuspend, DPMSSuspendTime) + DPMS_CHECK_MODE(DPMSModeStandby, DPMSStandbyTime) - nextTimeout = NextDPMSTimeout(timeout); + nextTimeout = NextDPMSTimeout(timeout); } /* @@ -611,27 +574,24 @@ ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg) * power saving mode */ if (DPMSPowerLevel != DPMSModeOn) - return nextTimeout; -#endif /* DPMSExtension */ + return nextTimeout; +#endif /* DPMSExtension */ if (!ScreenSaverTime) - return nextTimeout; + return nextTimeout; - if (timeout < ScreenSaverTime) - { - return nextTimeout > 0 ? - min(ScreenSaverTime - timeout, nextTimeout) : - ScreenSaverTime - timeout; + if (timeout < ScreenSaverTime) { + return nextTimeout > 0 ? + min(ScreenSaverTime - timeout, nextTimeout) : + ScreenSaverTime - timeout; } - ResetOsBuffers(); /* not ideal, but better than nothing */ + ResetOsBuffers(); /* not ideal, but better than nothing */ dixSaveScreens(serverClient, SCREEN_SAVER_ON, ScreenSaverActive); - if (ScreenSaverInterval > 0) - { - nextTimeout = nextTimeout > 0 ? - min(ScreenSaverInterval, nextTimeout) : - ScreenSaverInterval; + if (ScreenSaverInterval > 0) { + nextTimeout = nextTimeout > 0 ? + min(ScreenSaverInterval, nextTimeout) : ScreenSaverInterval; } return nextTimeout; @@ -643,8 +603,8 @@ void FreeScreenSaverTimer(void) { if (ScreenSaverTimer) { - TimerFree(ScreenSaverTimer); - ScreenSaverTimer = NULL; + TimerFree(ScreenSaverTimer); + ScreenSaverTimer = NULL; } } @@ -654,28 +614,24 @@ SetScreenSaverTimer(void) CARD32 timeout = 0; #ifdef DPMSExtension - 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; + 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; } #endif - if (ScreenSaverTime > 0) - { - timeout = timeout > 0 ? - min(ScreenSaverTime, timeout) : - ScreenSaverTime; + if (ScreenSaverTime > 0) { + timeout = timeout > 0 ? min(ScreenSaverTime, timeout) : ScreenSaverTime; } #ifdef SCREENSAVER @@ -683,11 +639,10 @@ SetScreenSaverTimer(void) #else if (timeout) { #endif - ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, timeout, - ScreenSaverTimeoutExpire, NULL); + ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, timeout, + ScreenSaverTimeoutExpire, NULL); } else if (ScreenSaverTimer) { - FreeScreenSaverTimer(); + FreeScreenSaverTimer(); } } - |