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 #include "inputstr.h"
35 
36 /*
37  * Local function prototypes
38  */
39 
40 int winProcEstablishConnection(ClientPtr /* client */ );
41 
42 /*
43  * Local global declarations
44  */
45 
46 DeviceIntPtr g_pwinPointer;
47 DeviceIntPtr g_pwinKeyboard;
48 
49 /* Called from dix/dispatch.c */
50 /*
51  * Run through the Windows message queue(s) one more time.
52  * Tell mi to dequeue the events that we have sent it.
53  */
54 void
ProcessInputEvents(void)55 ProcessInputEvents(void)
56 {
57 #if 0
58     ErrorF("ProcessInputEvents\n");
59 #endif
60 
61     mieqProcessInputEvents();
62 
63 #if 0
64     ErrorF("ProcessInputEvents - returning\n");
65 #endif
66 }
67 
68 void
DDXRingBell(int volume,int pitch,int duration)69 DDXRingBell(int volume, int pitch, int duration)
70 {
71     /* winKeybdBell is used instead */
72     return;
73 }
74 
75 
76 #ifdef HAS_DEVWINDOWS
77 static void
xwinDevWindowsHandlerNotify(int fd,int ready,void * data)78 xwinDevWindowsHandlerNotify(int fd, int ready, void *data)
79 {
80     /* This should process Windows messages, but instead all of that is delayed
81      * until the wakeup handler is called.
82      */
83     ;
84 }
85 #endif
86 
87 /* See Porting Layer Definition - p. 17 */
88 void
InitInput(int argc,char * argv[])89 InitInput(int argc, char *argv[])
90 {
91 #if CYGDEBUG
92     winDebug("InitInput\n");
93 #endif
94 
95     /*
96      * Wrap some functions at every generation of the server.
97      */
98     if (InitialVector[2] != winProcEstablishConnection) {
99         winProcEstablishConnectionOrig = InitialVector[2];
100         InitialVector[2] = winProcEstablishConnection;
101     }
102 
103     if (AllocDevicePair(serverClient, "Windows",
104                         &g_pwinPointer, &g_pwinKeyboard,
105                         winMouseProc, winKeybdProc,
106                         FALSE) != Success)
107         FatalError("InitInput - Failed to allocate slave devices.\n");
108 
109     mieqInit();
110 
111     /* Initialize the mode key states */
112     winInitializeModeKeyStates();
113 
114 #ifdef HAS_DEVWINDOWS
115     /* Only open the windows message queue device once */
116     if (g_fdMessageQueue == WIN_FD_INVALID) {
117         /* Open a file descriptor for the Windows message queue */
118         g_fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
119 
120         if (g_fdMessageQueue == -1) {
121             FatalError("InitInput - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
122         }
123 
124         /* Add the message queue as a device to wait for in WaitForSomething */
125         SetNotifyFd(g_fdMessageQueue, xwinDevWindowsHandlerNotify, X_NOTIFY_READ, NULL);
126     }
127 #endif
128 
129 #if CYGDEBUG
130     winDebug("InitInput - returning\n");
131 #endif
132 }
133 
134 void
CloseInput(void)135 CloseInput(void)
136 {
137     mieqFini();
138 }
139