InitInput.c revision 4642e01f
1/* 2 3 Copyright 1993, 1998 The Open Group 4 5 Permission to use, copy, modify, distribute, and sell this software and its 6 documentation for any purpose is hereby granted without fee, provided that 7 the above copyright notice appear in all copies and that both that 8 copyright notice and this permission notice appear in supporting 9 documentation. 10 11 The above copyright notice and this permission notice shall be included 12 in all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 OTHER DEALINGS IN THE SOFTWARE. 21 22 Except as contained in this notice, the name of The Open Group shall 23 not be used in advertising or otherwise to promote the sale, use or 24 other dealings in this Software without prior written authorization 25 from The Open Group. 26 27*/ 28 29#ifdef HAVE_XWIN_CONFIG_H 30#include <xwin-config.h> 31#endif 32#include "win.h" 33#include "dixstruct.h" 34 35 36/* 37 * Local function prototypes 38 */ 39 40#ifdef XWIN_CLIPBOARD 41DISPATCH_PROC(winProcEstablishConnection); 42DISPATCH_PROC(winProcQueryTree); 43DISPATCH_PROC(winProcSetSelectionOwner); 44#endif 45 46 47/* 48 * Local global declarations 49 */ 50 51CARD32 g_c32LastInputEventTime = 0; 52 53 54/* 55 * References to external symbols 56 */ 57 58#ifdef HAS_DEVWINDOWS 59extern int g_fdMessageQueue; 60#endif 61extern Bool g_fXdmcpEnabled; 62#ifdef XWIN_CLIPBOARD 63extern winDispatchProcPtr winProcEstablishConnectionOrig; 64extern winDispatchProcPtr winProcQueryTreeOrig; 65#endif 66 67 68/* Called from dix/devices.c */ 69/* 70 * All of our keys generate up and down transition notifications, 71 * so all of our keys can be used as modifiers. 72 * 73 * An example of a modifier is mapping the A key to the Control key. 74 * A has to be a legal modifier. I think. 75 */ 76 77Bool 78LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice) 79{ 80 return TRUE; 81} 82 83 84/* Called from dix/dispatch.c */ 85/* 86 * Run through the Windows message queue(s) one more time. 87 * Tell mi to dequeue the events that we have sent it. 88 */ 89void 90ProcessInputEvents (void) 91{ 92#if 0 93 ErrorF ("ProcessInputEvents\n"); 94#endif 95 96 mieqProcessInputEvents (); 97 miPointerUpdate (); 98 99#if 0 100 ErrorF ("ProcessInputEvents - returning\n"); 101#endif 102} 103 104 105int 106TimeSinceLastInputEvent () 107{ 108 if (g_c32LastInputEventTime == 0) 109 g_c32LastInputEventTime = GetTickCount (); 110 return GetTickCount () - g_c32LastInputEventTime; 111} 112 113 114/* See Porting Layer Definition - p. 17 */ 115void 116InitInput (int argc, char *argv[]) 117{ 118 DeviceIntPtr pMouse, pKeyboard; 119 120#if CYGDEBUG 121 winDebug ("InitInput\n"); 122#endif 123 124#ifdef XWIN_CLIPBOARD 125 /* 126 * Wrap some functions at every generation of the server. 127 */ 128 if (InitialVector[2] != winProcEstablishConnection) 129 { 130 winProcEstablishConnectionOrig = InitialVector[2]; 131 InitialVector[2] = winProcEstablishConnection; 132 } 133 if (g_fXdmcpEnabled 134 && ProcVector[X_QueryTree] != winProcQueryTree) 135 { 136 winProcQueryTreeOrig = ProcVector[X_QueryTree]; 137 ProcVector[X_QueryTree] = winProcQueryTree; 138 } 139#endif 140 141 pMouse = AddInputDevice (winMouseProc, TRUE); 142 pKeyboard = AddInputDevice (winKeybdProc, TRUE); 143 144 RegisterPointerDevice (pMouse); 145 RegisterKeyboardDevice (pKeyboard); 146 147 miRegisterPointerDevice (screenInfo.screens[0], pMouse); 148 mieqInit ((DevicePtr)pKeyboard, (DevicePtr)pMouse); 149 150 /* Initialize the mode key states */ 151 winInitializeModeKeyStates (); 152 153#ifdef HAS_DEVWINDOWS 154 /* Only open the windows message queue device once */ 155 if (g_fdMessageQueue == WIN_FD_INVALID) 156 { 157 /* Open a file descriptor for the Windows message queue */ 158 g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY); 159 160 if (g_fdMessageQueue == -1) 161 { 162 FatalError ("InitInput - Failed opening %s\n", 163 WIN_MSG_QUEUE_FNAME); 164 } 165 166 /* Add the message queue as a device to wait for in WaitForSomething */ 167 AddEnabledDevice (g_fdMessageQueue); 168 } 169#endif 170 171#if CYGDEBUG 172 winDebug ("InitInput - returning\n"); 173#endif 174} 175