InitInput.c revision 6747b715
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#include "dixstruct.h"
346747b715Smrg#include "inputstr.h"
3505b261ecSmrg
3605b261ecSmrg
3705b261ecSmrg/*
3805b261ecSmrg * Local function prototypes
3905b261ecSmrg */
4005b261ecSmrg
4105b261ecSmrg#ifdef XWIN_CLIPBOARD
4205b261ecSmrgDISPATCH_PROC(winProcEstablishConnection);
4305b261ecSmrgDISPATCH_PROC(winProcQueryTree);
4405b261ecSmrgDISPATCH_PROC(winProcSetSelectionOwner);
4505b261ecSmrg#endif
4605b261ecSmrg
4705b261ecSmrg
4805b261ecSmrg/*
4905b261ecSmrg * Local global declarations
5005b261ecSmrg */
5105b261ecSmrg
526747b715SmrgDeviceIntPtr g_pwinPointer;
536747b715SmrgDeviceIntPtr g_pwinKeyboard;
5405b261ecSmrg
5505b261ecSmrg
5605b261ecSmrg/*
5705b261ecSmrg * References to external symbols
5805b261ecSmrg */
5905b261ecSmrg
6005b261ecSmrg#ifdef HAS_DEVWINDOWS
6105b261ecSmrgextern int			g_fdMessageQueue;
6205b261ecSmrg#endif
6305b261ecSmrgextern Bool			g_fXdmcpEnabled;
6405b261ecSmrg#ifdef XWIN_CLIPBOARD
6505b261ecSmrgextern winDispatchProcPtr	winProcEstablishConnectionOrig;
6605b261ecSmrgextern winDispatchProcPtr	winProcQueryTreeOrig;
6705b261ecSmrg#endif
6805b261ecSmrg
6905b261ecSmrg
7005b261ecSmrg/* Called from dix/devices.c */
7105b261ecSmrg/*
7205b261ecSmrg * All of our keys generate up and down transition notifications,
7305b261ecSmrg * so all of our keys can be used as modifiers.
7405b261ecSmrg *
7505b261ecSmrg * An example of a modifier is mapping the A key to the Control key.
7605b261ecSmrg * A has to be a legal modifier.  I think.
7705b261ecSmrg */
7805b261ecSmrg
7905b261ecSmrgBool
8005b261ecSmrgLegalModifier (unsigned int uiKey, DeviceIntPtr pDevice)
8105b261ecSmrg{
8205b261ecSmrg  return TRUE;
8305b261ecSmrg}
8405b261ecSmrg
8505b261ecSmrg
8605b261ecSmrg/* Called from dix/dispatch.c */
8705b261ecSmrg/*
8805b261ecSmrg * Run through the Windows message queue(s) one more time.
8905b261ecSmrg * Tell mi to dequeue the events that we have sent it.
9005b261ecSmrg */
9105b261ecSmrgvoid
9205b261ecSmrgProcessInputEvents (void)
9305b261ecSmrg{
9405b261ecSmrg#if 0
9505b261ecSmrg  ErrorF ("ProcessInputEvents\n");
9605b261ecSmrg#endif
9705b261ecSmrg
9805b261ecSmrg  mieqProcessInputEvents ();
9905b261ecSmrg
10005b261ecSmrg#if 0
10105b261ecSmrg  ErrorF ("ProcessInputEvents - returning\n");
10205b261ecSmrg#endif
10305b261ecSmrg}
10405b261ecSmrg
10505b261ecSmrg
1066747b715Smrgvoid DDXRingBell(int volume, int pitch, int duration)
10705b261ecSmrg{
1086747b715Smrg  /* winKeybdBell is used instead */
1096747b715Smrg  return;
11005b261ecSmrg}
11105b261ecSmrg
11205b261ecSmrg
11305b261ecSmrg/* See Porting Layer Definition - p. 17 */
11405b261ecSmrgvoid
11505b261ecSmrgInitInput (int argc, char *argv[])
11605b261ecSmrg{
11705b261ecSmrg#if CYGDEBUG
11805b261ecSmrg  winDebug ("InitInput\n");
11905b261ecSmrg#endif
12005b261ecSmrg
12105b261ecSmrg#ifdef XWIN_CLIPBOARD
12205b261ecSmrg  /*
12305b261ecSmrg   * Wrap some functions at every generation of the server.
12405b261ecSmrg   */
12505b261ecSmrg  if (InitialVector[2] != winProcEstablishConnection)
12605b261ecSmrg    {
12705b261ecSmrg      winProcEstablishConnectionOrig = InitialVector[2];
12805b261ecSmrg      InitialVector[2] = winProcEstablishConnection;
12905b261ecSmrg    }
13005b261ecSmrg  if (g_fXdmcpEnabled
13105b261ecSmrg      && ProcVector[X_QueryTree] != winProcQueryTree)
13205b261ecSmrg    {
13305b261ecSmrg      winProcQueryTreeOrig = ProcVector[X_QueryTree];
13405b261ecSmrg      ProcVector[X_QueryTree] = winProcQueryTree;
13505b261ecSmrg    }
13605b261ecSmrg#endif
13705b261ecSmrg
1386747b715Smrg  g_pwinPointer = AddInputDevice (serverClient, winMouseProc, TRUE);
1396747b715Smrg  g_pwinKeyboard = AddInputDevice (serverClient, winKeybdProc, TRUE);
14005b261ecSmrg
1416747b715Smrg  RegisterPointerDevice (g_pwinPointer);
1426747b715Smrg  RegisterKeyboardDevice (g_pwinKeyboard);
1436747b715Smrg
1446747b715Smrg  g_pwinPointer->name = strdup("Windows mouse");
1456747b715Smrg  g_pwinKeyboard->name = strdup("Windows keyboard");
14605b261ecSmrg
1476747b715Smrg  mieqInit ();
14805b261ecSmrg
14905b261ecSmrg  /* Initialize the mode key states */
15005b261ecSmrg  winInitializeModeKeyStates ();
15105b261ecSmrg
15205b261ecSmrg#ifdef HAS_DEVWINDOWS
15305b261ecSmrg  /* Only open the windows message queue device once */
15405b261ecSmrg  if (g_fdMessageQueue == WIN_FD_INVALID)
15505b261ecSmrg    {
15605b261ecSmrg      /* Open a file descriptor for the Windows message queue */
15705b261ecSmrg      g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
15805b261ecSmrg
15905b261ecSmrg      if (g_fdMessageQueue == -1)
16005b261ecSmrg	{
16105b261ecSmrg	  FatalError ("InitInput - Failed opening %s\n",
16205b261ecSmrg		      WIN_MSG_QUEUE_FNAME);
16305b261ecSmrg	}
16405b261ecSmrg
16505b261ecSmrg      /* Add the message queue as a device to wait for in WaitForSomething */
16605b261ecSmrg      AddEnabledDevice (g_fdMessageQueue);
16705b261ecSmrg    }
16805b261ecSmrg#endif
16905b261ecSmrg
17005b261ecSmrg#if CYGDEBUG
17105b261ecSmrg  winDebug ("InitInput - returning\n");
17205b261ecSmrg#endif
17305b261ecSmrg}
1746747b715Smrg
1756747b715Smrgvoid
1766747b715SmrgCloseInput (void)
1776747b715Smrg{
1786747b715Smrg}
179