105b261ecSmrg/* 205b261ecSmrg *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. 305b261ecSmrg * 405b261ecSmrg *Permission is hereby granted, free of charge, to any person obtaining 505b261ecSmrg * a copy of this software and associated documentation files (the 605b261ecSmrg *"Software"), to deal in the Software without restriction, including 705b261ecSmrg *without limitation the rights to use, copy, modify, merge, publish, 805b261ecSmrg *distribute, sublicense, and/or sell copies of the Software, and to 905b261ecSmrg *permit persons to whom the Software is furnished to do so, subject to 1005b261ecSmrg *the following conditions: 1105b261ecSmrg * 1205b261ecSmrg *The above copyright notice and this permission notice shall be 1305b261ecSmrg *included in all copies or substantial portions of the Software. 1405b261ecSmrg * 1505b261ecSmrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1605b261ecSmrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1705b261ecSmrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1805b261ecSmrg *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR 1905b261ecSmrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 2005b261ecSmrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2105b261ecSmrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2205b261ecSmrg * 2305b261ecSmrg *Except as contained in this notice, the name of Harold L Hunt II 2405b261ecSmrg *shall not be used in advertising or otherwise to promote the sale, use 2505b261ecSmrg *or other dealings in this Software without prior written authorization 2605b261ecSmrg *from Harold L Hunt II. 2705b261ecSmrg * 2805b261ecSmrg * Authors: Harold L Hunt II 2905b261ecSmrg */ 3005b261ecSmrg 3105b261ecSmrg#ifdef HAVE_XWIN_CONFIG_H 3205b261ecSmrg#include <xwin-config.h> 3305b261ecSmrg#endif 3405b261ecSmrg#include "win.h" 3505b261ecSmrg#include "winmsg.h" 3605b261ecSmrg 3705b261ecSmrg/* See Porting Layer Definition - p. 6 */ 3805b261ecSmrgvoid 391b5d61b8SmrgwinBlockHandler(ScreenPtr pScreen, void *pTimeout) 4005b261ecSmrg{ 4135c4bbdfSmrg winScreenPriv(pScreen); 4235c4bbdfSmrg 4305b261ecSmrg#ifndef HAS_DEVWINDOWS 4435c4bbdfSmrg struct timeval **tvp = pTimeout; 4535c4bbdfSmrg 4635c4bbdfSmrg if (*tvp != NULL) { 4735c4bbdfSmrg if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) { 4835c4bbdfSmrg /* If there are still messages to process on the Windows message 4935c4bbdfSmrg queue, make sure select() just polls rather than blocking. 5035c4bbdfSmrg */ 5135c4bbdfSmrg (*tvp)->tv_sec = 0; 5235c4bbdfSmrg (*tvp)->tv_usec = 0; 5335c4bbdfSmrg } 5435c4bbdfSmrg else { 5535c4bbdfSmrg /* Otherwise, lacking /dev/windows, we must wake up again in 5635c4bbdfSmrg a reasonable time to check the Windows message queue. without 5735c4bbdfSmrg noticeable delay. 5835c4bbdfSmrg */ 5935c4bbdfSmrg (*tvp)->tv_sec = 0; 6035c4bbdfSmrg (*tvp)->tv_usec = 100; 6135c4bbdfSmrg } 6235c4bbdfSmrg } 6305b261ecSmrg#endif 6405b261ecSmrg 6535c4bbdfSmrg /* Signal threaded modules to begin */ 6635c4bbdfSmrg if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) { 6735c4bbdfSmrg int iReturn; 6805b261ecSmrg 691b5d61b8Smrg winDebug("winBlockHandler - pthread_mutex_unlock()\n"); 7005b261ecSmrg 7135c4bbdfSmrg /* Flag that modules are to be started */ 7235c4bbdfSmrg pScreenPriv->fServerStarted = TRUE; 7305b261ecSmrg 7435c4bbdfSmrg /* Unlock the mutex for threaded modules */ 7535c4bbdfSmrg iReturn = pthread_mutex_unlock(&pScreenPriv->pmServerStarted); 7635c4bbdfSmrg if (iReturn != 0) { 7735c4bbdfSmrg ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n", 7835c4bbdfSmrg iReturn); 7935c4bbdfSmrg } 8035c4bbdfSmrg else { 8135c4bbdfSmrg winDebug("winBlockHandler - pthread_mutex_unlock () returned\n"); 8235c4bbdfSmrg } 8305b261ecSmrg } 8405b261ecSmrg 8535c4bbdfSmrg /* 8635c4bbdfSmrg At least one X client has asked to suspend the screensaver, so 8735c4bbdfSmrg reset Windows' display idle timer 8835c4bbdfSmrg */ 8935c4bbdfSmrg#ifdef SCREENSAVER 9035c4bbdfSmrg if (screenSaverSuspended) 9135c4bbdfSmrg SetThreadExecutionState(ES_DISPLAY_REQUIRED); 9235c4bbdfSmrg#endif 9305b261ecSmrg} 94