winblock.c revision 05b261ec
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 3805b261ecSmrg/* 3905b261ecSmrg * References to external symbols 4005b261ecSmrg */ 4105b261ecSmrg 4205b261ecSmrgextern HWND g_hDlgDepthChange; 4305b261ecSmrgextern HWND g_hDlgExit; 4405b261ecSmrgextern HWND g_hDlgAbout; 4505b261ecSmrg 4605b261ecSmrg 4705b261ecSmrg/* See Porting Layer Definition - p. 6 */ 4805b261ecSmrgvoid 4905b261ecSmrgwinBlockHandler (int nScreen, 5005b261ecSmrg pointer pBlockData, 5105b261ecSmrg pointer pTimeout, 5205b261ecSmrg pointer pReadMask) 5305b261ecSmrg{ 5405b261ecSmrg#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 5505b261ecSmrg winScreenPriv((ScreenPtr)pBlockData); 5605b261ecSmrg#endif 5705b261ecSmrg MSG msg; 5805b261ecSmrg#ifndef HAS_DEVWINDOWS 5905b261ecSmrg struct timeval **tvp = pTimeout; 6005b261ecSmrg if (*tvp != NULL) 6105b261ecSmrg { 6205b261ecSmrg (*tvp)->tv_sec = 0; 6305b261ecSmrg (*tvp)->tv_usec = 100; 6405b261ecSmrg } 6505b261ecSmrg#endif 6605b261ecSmrg 6705b261ecSmrg#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 6805b261ecSmrg /* Signal threaded modules to begin */ 6905b261ecSmrg if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) 7005b261ecSmrg { 7105b261ecSmrg int iReturn; 7205b261ecSmrg 7305b261ecSmrg winDebug ("winBlockHandler - Releasing pmServerStarted\n"); 7405b261ecSmrg 7505b261ecSmrg /* Flag that modules are to be started */ 7605b261ecSmrg pScreenPriv->fServerStarted = TRUE; 7705b261ecSmrg 7805b261ecSmrg /* Unlock the mutex for threaded modules */ 7905b261ecSmrg iReturn = pthread_mutex_unlock (&pScreenPriv->pmServerStarted); 8005b261ecSmrg if (iReturn != 0) 8105b261ecSmrg { 8205b261ecSmrg ErrorF ("winBlockHandler - pthread_mutex_unlock () failed: %d\n", 8305b261ecSmrg iReturn); 8405b261ecSmrg goto winBlockHandler_ProcessMessages; 8505b261ecSmrg } 8605b261ecSmrg 8705b261ecSmrg winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n"); 8805b261ecSmrg } 8905b261ecSmrg 9005b261ecSmrgwinBlockHandler_ProcessMessages: 9105b261ecSmrg#endif 9205b261ecSmrg 9305b261ecSmrg /* Process all messages on our queue */ 9405b261ecSmrg while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) 9505b261ecSmrg { 9605b261ecSmrg if ((g_hDlgDepthChange == 0 9705b261ecSmrg || !IsDialogMessage (g_hDlgDepthChange, &msg)) 9805b261ecSmrg && (g_hDlgExit == 0 9905b261ecSmrg || !IsDialogMessage (g_hDlgExit, &msg)) 10005b261ecSmrg && (g_hDlgAbout == 0 10105b261ecSmrg || !IsDialogMessage (g_hDlgAbout, &msg))) 10205b261ecSmrg { 10305b261ecSmrg DispatchMessage (&msg); 10405b261ecSmrg } 10505b261ecSmrg } 10605b261ecSmrg} 107