InitInput.c revision 05b261ec
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#ifdef XWIN_CLIPBOARD 34# include "../../Xext/xf86miscproc.h" 35#endif 36#include "dixstruct.h" 37 38 39/* 40 * Local function prototypes 41 */ 42 43#ifdef XWIN_CLIPBOARD 44DISPATCH_PROC(winProcEstablishConnection); 45DISPATCH_PROC(winProcQueryTree); 46DISPATCH_PROC(winProcSetSelectionOwner); 47#endif 48 49 50/* 51 * Local global declarations 52 */ 53 54CARD32 g_c32LastInputEventTime = 0; 55 56 57/* 58 * References to external symbols 59 */ 60 61#ifdef HAS_DEVWINDOWS 62extern int g_fdMessageQueue; 63#endif 64extern Bool g_fXdmcpEnabled; 65#ifdef XWIN_CLIPBOARD 66extern winDispatchProcPtr winProcEstablishConnectionOrig; 67extern winDispatchProcPtr winProcQueryTreeOrig; 68#endif 69 70 71/* Called from dix/devices.c */ 72/* 73 * All of our keys generate up and down transition notifications, 74 * so all of our keys can be used as modifiers. 75 * 76 * An example of a modifier is mapping the A key to the Control key. 77 * A has to be a legal modifier. I think. 78 */ 79 80Bool 81LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice) 82{ 83 return TRUE; 84} 85 86 87/* Called from dix/dispatch.c */ 88/* 89 * Run through the Windows message queue(s) one more time. 90 * Tell mi to dequeue the events that we have sent it. 91 */ 92void 93ProcessInputEvents (void) 94{ 95#if 0 96 ErrorF ("ProcessInputEvents\n"); 97#endif 98 99 mieqProcessInputEvents (); 100 miPointerUpdate (); 101 102#if 0 103 ErrorF ("ProcessInputEvents - returning\n"); 104#endif 105} 106 107 108int 109TimeSinceLastInputEvent () 110{ 111 if (g_c32LastInputEventTime == 0) 112 g_c32LastInputEventTime = GetTickCount (); 113 return GetTickCount () - g_c32LastInputEventTime; 114} 115 116 117/* See Porting Layer Definition - p. 17 */ 118void 119InitInput (int argc, char *argv[]) 120{ 121 DeviceIntPtr pMouse, pKeyboard; 122 123#if CYGDEBUG 124 winDebug ("InitInput\n"); 125#endif 126 127#ifdef XWIN_CLIPBOARD 128 /* 129 * Wrap some functions at every generation of the server. 130 */ 131 if (InitialVector[2] != winProcEstablishConnection) 132 { 133 winProcEstablishConnectionOrig = InitialVector[2]; 134 InitialVector[2] = winProcEstablishConnection; 135 } 136 if (g_fXdmcpEnabled 137 && ProcVector[X_QueryTree] != winProcQueryTree) 138 { 139 winProcQueryTreeOrig = ProcVector[X_QueryTree]; 140 ProcVector[X_QueryTree] = winProcQueryTree; 141 } 142#endif 143 144 pMouse = AddInputDevice (winMouseProc, TRUE); 145 pKeyboard = AddInputDevice (winKeybdProc, TRUE); 146 147 RegisterPointerDevice (pMouse); 148 RegisterKeyboardDevice (pKeyboard); 149 150 miRegisterPointerDevice (screenInfo.screens[0], pMouse); 151 mieqInit ((DevicePtr)pKeyboard, (DevicePtr)pMouse); 152 153 /* Initialize the mode key states */ 154 winInitializeModeKeyStates (); 155 156#ifdef HAS_DEVWINDOWS 157 /* Only open the windows message queue device once */ 158 if (g_fdMessageQueue == WIN_FD_INVALID) 159 { 160 /* Open a file descriptor for the Windows message queue */ 161 g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY); 162 163 if (g_fdMessageQueue == -1) 164 { 165 FatalError ("InitInput - Failed opening %s\n", 166 WIN_MSG_QUEUE_FNAME); 167 } 168 169 /* Add the message queue as a device to wait for in WaitForSomething */ 170 AddEnabledDevice (g_fdMessageQueue); 171 } 172#endif 173 174#if CYGDEBUG 175 winDebug ("InitInput - returning\n"); 176#endif 177} 178