InitInput.c revision 05b261ec
105b261ecSmrg/*
205b261ecSmrg
305b261ecSmrg  Copyright 1993, 1998  The Open Group
405b261ecSmrg
505b261ecSmrg  Permission to use, copy, modify, distribute, and sell this software and its
605b261ecSmrg  documentation for any purpose is hereby granted without fee, provided that
705b261ecSmrg  the above copyright notice appear in all copies and that both that
805b261ecSmrg  copyright notice and this permission notice appear in supporting
905b261ecSmrg  documentation.
1005b261ecSmrg
1105b261ecSmrg  The above copyright notice and this permission notice shall be included
1205b261ecSmrg  in all copies or substantial portions of the Software.
1305b261ecSmrg
1405b261ecSmrg  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1505b261ecSmrg  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1605b261ecSmrg  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1705b261ecSmrg  IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
1805b261ecSmrg  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1905b261ecSmrg  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2005b261ecSmrg  OTHER DEALINGS IN THE SOFTWARE.
2105b261ecSmrg
2205b261ecSmrg  Except as contained in this notice, the name of The Open Group shall
2305b261ecSmrg  not be used in advertising or otherwise to promote the sale, use or
2405b261ecSmrg  other dealings in this Software without prior written authorization
2505b261ecSmrg  from The Open Group.
2605b261ecSmrg
2705b261ecSmrg*/
2805b261ecSmrg
2905b261ecSmrg#ifdef HAVE_XWIN_CONFIG_H
3005b261ecSmrg#include <xwin-config.h>
3105b261ecSmrg#endif
3205b261ecSmrg#include "win.h"
3305b261ecSmrg#ifdef XWIN_CLIPBOARD
3405b261ecSmrg# include "../../Xext/xf86miscproc.h"
3505b261ecSmrg#endif
3605b261ecSmrg#include "dixstruct.h"
3705b261ecSmrg
3805b261ecSmrg
3905b261ecSmrg/*
4005b261ecSmrg * Local function prototypes
4105b261ecSmrg */
4205b261ecSmrg
4305b261ecSmrg#ifdef XWIN_CLIPBOARD
4405b261ecSmrgDISPATCH_PROC(winProcEstablishConnection);
4505b261ecSmrgDISPATCH_PROC(winProcQueryTree);
4605b261ecSmrgDISPATCH_PROC(winProcSetSelectionOwner);
4705b261ecSmrg#endif
4805b261ecSmrg
4905b261ecSmrg
5005b261ecSmrg/*
5105b261ecSmrg * Local global declarations
5205b261ecSmrg */
5305b261ecSmrg
5405b261ecSmrgCARD32				g_c32LastInputEventTime = 0;
5505b261ecSmrg
5605b261ecSmrg
5705b261ecSmrg/*
5805b261ecSmrg * References to external symbols
5905b261ecSmrg */
6005b261ecSmrg
6105b261ecSmrg#ifdef HAS_DEVWINDOWS
6205b261ecSmrgextern int			g_fdMessageQueue;
6305b261ecSmrg#endif
6405b261ecSmrgextern Bool			g_fXdmcpEnabled;
6505b261ecSmrg#ifdef XWIN_CLIPBOARD
6605b261ecSmrgextern winDispatchProcPtr	winProcEstablishConnectionOrig;
6705b261ecSmrgextern winDispatchProcPtr	winProcQueryTreeOrig;
6805b261ecSmrg#endif
6905b261ecSmrg
7005b261ecSmrg
7105b261ecSmrg/* Called from dix/devices.c */
7205b261ecSmrg/*
7305b261ecSmrg * All of our keys generate up and down transition notifications,
7405b261ecSmrg * so all of our keys can be used as modifiers.
7505b261ecSmrg *
7605b261ecSmrg * An example of a modifier is mapping the A key to the Control key.
7705b261ecSmrg * A has to be a legal modifier.  I think.
7805b261ecSmrg */
7905b261ecSmrg
8005b261ecSmrgBool
8105b261ecSmrgLegalModifier (unsigned int uiKey, DeviceIntPtr pDevice)
8205b261ecSmrg{
8305b261ecSmrg  return TRUE;
8405b261ecSmrg}
8505b261ecSmrg
8605b261ecSmrg
8705b261ecSmrg/* Called from dix/dispatch.c */
8805b261ecSmrg/*
8905b261ecSmrg * Run through the Windows message queue(s) one more time.
9005b261ecSmrg * Tell mi to dequeue the events that we have sent it.
9105b261ecSmrg */
9205b261ecSmrgvoid
9305b261ecSmrgProcessInputEvents (void)
9405b261ecSmrg{
9505b261ecSmrg#if 0
9605b261ecSmrg  ErrorF ("ProcessInputEvents\n");
9705b261ecSmrg#endif
9805b261ecSmrg
9905b261ecSmrg  mieqProcessInputEvents ();
10005b261ecSmrg  miPointerUpdate ();
10105b261ecSmrg
10205b261ecSmrg#if 0
10305b261ecSmrg  ErrorF ("ProcessInputEvents - returning\n");
10405b261ecSmrg#endif
10505b261ecSmrg}
10605b261ecSmrg
10705b261ecSmrg
10805b261ecSmrgint
10905b261ecSmrgTimeSinceLastInputEvent ()
11005b261ecSmrg{
11105b261ecSmrg  if (g_c32LastInputEventTime == 0)
11205b261ecSmrg    g_c32LastInputEventTime = GetTickCount ();
11305b261ecSmrg  return GetTickCount () - g_c32LastInputEventTime;
11405b261ecSmrg}
11505b261ecSmrg
11605b261ecSmrg
11705b261ecSmrg/* See Porting Layer Definition - p. 17 */
11805b261ecSmrgvoid
11905b261ecSmrgInitInput (int argc, char *argv[])
12005b261ecSmrg{
12105b261ecSmrg  DeviceIntPtr		pMouse, pKeyboard;
12205b261ecSmrg
12305b261ecSmrg#if CYGDEBUG
12405b261ecSmrg  winDebug ("InitInput\n");
12505b261ecSmrg#endif
12605b261ecSmrg
12705b261ecSmrg#ifdef XWIN_CLIPBOARD
12805b261ecSmrg  /*
12905b261ecSmrg   * Wrap some functions at every generation of the server.
13005b261ecSmrg   */
13105b261ecSmrg  if (InitialVector[2] != winProcEstablishConnection)
13205b261ecSmrg    {
13305b261ecSmrg      winProcEstablishConnectionOrig = InitialVector[2];
13405b261ecSmrg      InitialVector[2] = winProcEstablishConnection;
13505b261ecSmrg    }
13605b261ecSmrg  if (g_fXdmcpEnabled
13705b261ecSmrg      && ProcVector[X_QueryTree] != winProcQueryTree)
13805b261ecSmrg    {
13905b261ecSmrg      winProcQueryTreeOrig = ProcVector[X_QueryTree];
14005b261ecSmrg      ProcVector[X_QueryTree] = winProcQueryTree;
14105b261ecSmrg    }
14205b261ecSmrg#endif
14305b261ecSmrg
14405b261ecSmrg  pMouse = AddInputDevice (winMouseProc, TRUE);
14505b261ecSmrg  pKeyboard = AddInputDevice (winKeybdProc, TRUE);
14605b261ecSmrg
14705b261ecSmrg  RegisterPointerDevice (pMouse);
14805b261ecSmrg  RegisterKeyboardDevice (pKeyboard);
14905b261ecSmrg
15005b261ecSmrg  miRegisterPointerDevice (screenInfo.screens[0], pMouse);
15105b261ecSmrg  mieqInit ((DevicePtr)pKeyboard, (DevicePtr)pMouse);
15205b261ecSmrg
15305b261ecSmrg  /* Initialize the mode key states */
15405b261ecSmrg  winInitializeModeKeyStates ();
15505b261ecSmrg
15605b261ecSmrg#ifdef HAS_DEVWINDOWS
15705b261ecSmrg  /* Only open the windows message queue device once */
15805b261ecSmrg  if (g_fdMessageQueue == WIN_FD_INVALID)
15905b261ecSmrg    {
16005b261ecSmrg      /* Open a file descriptor for the Windows message queue */
16105b261ecSmrg      g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
16205b261ecSmrg
16305b261ecSmrg      if (g_fdMessageQueue == -1)
16405b261ecSmrg	{
16505b261ecSmrg	  FatalError ("InitInput - Failed opening %s\n",
16605b261ecSmrg		      WIN_MSG_QUEUE_FNAME);
16705b261ecSmrg	}
16805b261ecSmrg
16905b261ecSmrg      /* Add the message queue as a device to wait for in WaitForSomething */
17005b261ecSmrg      AddEnabledDevice (g_fdMessageQueue);
17105b261ecSmrg    }
17205b261ecSmrg#endif
17305b261ecSmrg
17405b261ecSmrg#if CYGDEBUG
17505b261ecSmrg  winDebug ("InitInput - returning\n");
17605b261ecSmrg#endif
17705b261ecSmrg}
178