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 * Local function prototypes
3805b261ecSmrg */
3905b261ecSmrg
4035c4bbdfSmrgint winProcEstablishConnection(ClientPtr /* client */ );
4105b261ecSmrg
4205b261ecSmrg/*
4305b261ecSmrg * Local global declarations
4405b261ecSmrg */
4505b261ecSmrg
466747b715SmrgDeviceIntPtr g_pwinPointer;
476747b715SmrgDeviceIntPtr g_pwinKeyboard;
4805b261ecSmrg
4905b261ecSmrg/* Called from dix/dispatch.c */
5005b261ecSmrg/*
5105b261ecSmrg * Run through the Windows message queue(s) one more time.
5205b261ecSmrg * Tell mi to dequeue the events that we have sent it.
5305b261ecSmrg */
5405b261ecSmrgvoid
5535c4bbdfSmrgProcessInputEvents(void)
5605b261ecSmrg{
5705b261ecSmrg#if 0
5835c4bbdfSmrg    ErrorF("ProcessInputEvents\n");
5905b261ecSmrg#endif
6005b261ecSmrg
6135c4bbdfSmrg    mieqProcessInputEvents();
6205b261ecSmrg
6305b261ecSmrg#if 0
6435c4bbdfSmrg    ErrorF("ProcessInputEvents - returning\n");
6505b261ecSmrg#endif
6605b261ecSmrg}
6705b261ecSmrg
6835c4bbdfSmrgvoid
6935c4bbdfSmrgDDXRingBell(int volume, int pitch, int duration)
7005b261ecSmrg{
7135c4bbdfSmrg    /* winKeybdBell is used instead */
7235c4bbdfSmrg    return;
7305b261ecSmrg}
7405b261ecSmrg
751b5d61b8Smrg
761b5d61b8Smrg#ifdef HAS_DEVWINDOWS
771b5d61b8Smrgstatic void
781b5d61b8SmrgxwinDevWindowsHandlerNotify(int fd, int ready, void *data)
791b5d61b8Smrg{
801b5d61b8Smrg    /* This should process Windows messages, but instead all of that is delayed
811b5d61b8Smrg     * until the wakeup handler is called.
821b5d61b8Smrg     */
831b5d61b8Smrg    ;
841b5d61b8Smrg}
851b5d61b8Smrg#endif
861b5d61b8Smrg
8705b261ecSmrg/* See Porting Layer Definition - p. 17 */
8805b261ecSmrgvoid
8935c4bbdfSmrgInitInput(int argc, char *argv[])
9005b261ecSmrg{
9105b261ecSmrg#if CYGDEBUG
9235c4bbdfSmrg    winDebug("InitInput\n");
9305b261ecSmrg#endif
9405b261ecSmrg
9535c4bbdfSmrg    /*
9635c4bbdfSmrg     * Wrap some functions at every generation of the server.
9735c4bbdfSmrg     */
9835c4bbdfSmrg    if (InitialVector[2] != winProcEstablishConnection) {
9935c4bbdfSmrg        winProcEstablishConnectionOrig = InitialVector[2];
10035c4bbdfSmrg        InitialVector[2] = winProcEstablishConnection;
10105b261ecSmrg    }
10205b261ecSmrg
10335c4bbdfSmrg    if (AllocDevicePair(serverClient, "Windows",
10435c4bbdfSmrg                        &g_pwinPointer, &g_pwinKeyboard,
10535c4bbdfSmrg                        winMouseProc, winKeybdProc,
10635c4bbdfSmrg                        FALSE) != Success)
10735c4bbdfSmrg        FatalError("InitInput - Failed to allocate slave devices.\n");
10805b261ecSmrg
10935c4bbdfSmrg    mieqInit();
11005b261ecSmrg
11135c4bbdfSmrg    /* Initialize the mode key states */
11235c4bbdfSmrg    winInitializeModeKeyStates();
11305b261ecSmrg
11405b261ecSmrg#ifdef HAS_DEVWINDOWS
11535c4bbdfSmrg    /* Only open the windows message queue device once */
11635c4bbdfSmrg    if (g_fdMessageQueue == WIN_FD_INVALID) {
11735c4bbdfSmrg        /* Open a file descriptor for the Windows message queue */
11835c4bbdfSmrg        g_fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
11935c4bbdfSmrg
12035c4bbdfSmrg        if (g_fdMessageQueue == -1) {
12135c4bbdfSmrg            FatalError("InitInput - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
12235c4bbdfSmrg        }
12335c4bbdfSmrg
12435c4bbdfSmrg        /* Add the message queue as a device to wait for in WaitForSomething */
1251b5d61b8Smrg        SetNotifyFd(g_fdMessageQueue, xwinDevWindowsHandlerNotify, X_NOTIFY_READ, NULL);
12605b261ecSmrg    }
12705b261ecSmrg#endif
12805b261ecSmrg
12905b261ecSmrg#if CYGDEBUG
13035c4bbdfSmrg    winDebug("InitInput - returning\n");
13105b261ecSmrg#endif
13205b261ecSmrg}
1336747b715Smrg
1346747b715Smrgvoid
13535c4bbdfSmrgCloseInput(void)
1366747b715Smrg{
13735c4bbdfSmrg    mieqFini();
1386747b715Smrg}
139