Release 951226
[wine/gsoc-2012-control.git] / windows / event.c
blob780cc3119f56ceb6be8bdee70ca5287fae9f06c4
1 /*
2 * X events handling functions
3 *
4 * Copyright 1993 Alexandre Julliard
5 *
6 */
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <X11/Xlib.h>
12 #include <X11/Xresource.h>
13 #include <X11/Xutil.h>
14 #include <X11/Xatom.h>
15 #include "gdi.h"
16 #include "windows.h"
17 #include "win.h"
18 #include "class.h"
19 #include "message.h"
20 #include "clipboard.h"
21 #include "options.h"
22 #include "winpos.h"
23 #include "registers.h"
24 #include "stackframe.h"
25 #include "stddebug.h"
26 /* #define DEBUG_EVENT */
27 /* #define DEBUG_KEY */
28 #include "debug.h"
31 #ifdef ndef
32 #ifndef FamilyAmoeba
33 typedef char *XPointer;
34 #endif
35 #endif
37 #ifdef WHO_NEEDS_DIRTY_HACKS
38 #ifdef sparc
39 /* Dirty hack to compile with Sun's OpenWindows */
40 typedef char *XPointer;
41 #endif
42 #endif
44 #define NB_BUTTONS 3 /* Windows can handle 3 buttons */
46 /* X context to associate a hwnd to an X window */
47 static XContext winContext = 0;
49 /* State variables */
50 BOOL MouseButtonsStates[NB_BUTTONS] = { FALSE, FALSE, FALSE };
51 BOOL AsyncMouseButtonsStates[NB_BUTTONS] = { FALSE, FALSE, FALSE };
52 BYTE KeyStateTable[256];
53 BYTE AsyncKeyStateTable[256];
54 static WORD ALTKeyState;
55 static HWND captureWnd = 0;
56 static BOOL InputEnabled = TRUE;
58 /* Keyboard translation tables */
59 static int special_key[] =
61 VK_BACK, VK_TAB, 0, VK_CLEAR, 0, VK_RETURN, 0, 0, /* FF08 */
62 0, 0, 0, VK_PAUSE, VK_SCROLL, 0, 0, 0, /* FF10 */
63 0, 0, 0, VK_ESCAPE /* FF18 */
66 static cursor_key[] =
68 VK_HOME, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_PRIOR,
69 VK_NEXT, VK_END /* FF50 */
72 static misc_key[] =
74 VK_SELECT, VK_SNAPSHOT, VK_EXECUTE, VK_INSERT, 0, 0, 0, 0, /* FF60 */
75 VK_CANCEL, VK_HELP, VK_CANCEL, VK_MENU /* FF68 */
78 static keypad_key[] =
80 VK_MENU, VK_NUMLOCK, /* FF7E */
81 0, 0, 0, 0, 0, 0, 0, 0, /* FF80 */
82 0, 0, 0, 0, 0, VK_RETURN, 0, 0, /* FF88 */
83 0, 0, 0, 0, 0, 0, 0, 0, /* FF90 */
84 0, 0, 0, 0, 0, 0, 0, 0, /* FF98 */
85 0, 0, 0, 0, 0, 0, 0, 0, /* FFA0 */
86 0, 0, VK_MULTIPLY, VK_ADD, VK_SEPARATOR, VK_SUBTRACT,
87 VK_DECIMAL, VK_DIVIDE, /* FFA8 */
88 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4,
89 VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, /* FFB0 */
90 VK_NUMPAD8, VK_NUMPAD9 /* FFB8 */
93 static function_key[] =
95 VK_F1, VK_F2, /* FFBE */
96 VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, /* FFC0 */
97 VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16 /* FFC8 */
100 static modifier_key[] =
102 VK_SHIFT, VK_SHIFT, VK_CONTROL, VK_CONTROL, VK_CAPITAL,
103 0, 0, /* FFE1 */
104 0, VK_MENU, VK_MENU /* FFE8 */
107 typedef union
109 struct
111 unsigned long count : 16;
112 unsigned long code : 8;
113 unsigned long extended : 1;
114 unsigned long : 4;
115 unsigned long context : 1;
116 unsigned long previous : 1;
117 unsigned long transition : 1;
118 } lp1;
119 unsigned long lp2;
120 } KEYLP;
122 static BOOL KeyDown = FALSE;
124 static const char *event_names[] =
126 "", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease",
127 "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut",
128 "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify",
129 "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",
130 "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify",
131 "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify",
132 "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify",
133 "ClientMessage", "MappingNotify"
136 /* Event handlers */
137 static void EVENT_key( XKeyEvent *event );
138 static void EVENT_ButtonPress( XButtonEvent *event );
139 static void EVENT_ButtonRelease( XButtonEvent *event );
140 static void EVENT_MotionNotify( XMotionEvent *event );
141 static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event );
142 static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event );
143 static void EVENT_Expose( HWND hwnd, XExposeEvent *event );
144 static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event );
145 static void EVENT_SelectionRequest( HWND hwnd, XSelectionRequestEvent *event);
146 static void EVENT_SelectionNotify( HWND hwnd, XSelectionEvent *event);
147 static void EVENT_SelectionClear( HWND hwnd, XSelectionClearEvent *event);
150 /***********************************************************************
151 * EVENT_ProcessEvent
153 * Process an X event.
155 void EVENT_ProcessEvent( XEvent *event )
157 HWND hwnd;
158 XPointer ptr;
160 XFindContext( display, ((XAnyEvent *)event)->window, winContext, &ptr );
161 hwnd = (HWND) (int)ptr;
163 dprintf_event(stddeb, "Got event %s for hwnd "NPFMT"\n",
164 event_names[event->type], hwnd );
166 switch(event->type)
168 case KeyPress:
169 case KeyRelease:
170 EVENT_key( (XKeyEvent*)event );
171 break;
173 case ButtonPress:
174 EVENT_ButtonPress( (XButtonEvent*)event );
175 break;
177 case ButtonRelease:
178 EVENT_ButtonRelease( (XButtonEvent*)event );
179 break;
181 case MotionNotify:
182 /* Wine between two fast machines across the overloaded campus
183 ethernet gets very boged down in MotionEvents. The following
184 simply finds the last motion event in the queue and drops
185 the rest. On a good link events are servered before they build
186 up so this doesn't take place. On a slow link this may cause
187 problems if the event order is important. I'm not yet seen
188 of any problems. Jon 7/6/96.
190 while (XCheckTypedWindowEvent(display, ((XAnyEvent *)event)->window,
191 MotionNotify, event));
192 EVENT_MotionNotify( (XMotionEvent*)event );
193 break;
195 case FocusIn:
196 EVENT_FocusIn( hwnd, (XFocusChangeEvent*)event );
197 break;
199 case FocusOut:
200 EVENT_FocusOut( hwnd, (XFocusChangeEvent*)event );
201 break;
203 case Expose:
204 EVENT_Expose( hwnd, (XExposeEvent*)event );
205 break;
207 case ConfigureNotify:
208 EVENT_ConfigureNotify( hwnd, (XConfigureEvent*)event );
209 break;
211 case SelectionRequest:
212 EVENT_SelectionRequest( hwnd, (XSelectionRequestEvent*)event );
213 break;
215 case SelectionNotify:
216 EVENT_SelectionNotify( hwnd, (XSelectionEvent*)event );
217 break;
219 case SelectionClear:
220 EVENT_SelectionClear( hwnd, (XSelectionClearEvent*) event );
221 break;
223 default:
224 dprintf_event(stddeb, "Unprocessed event %s for hwnd "NPFMT"\n",
225 event_names[event->type], hwnd );
226 break;
231 /***********************************************************************
232 * EVENT_RegisterWindow
234 * Associate an X window to a HWND.
236 void EVENT_RegisterWindow( Window w, HWND hwnd )
238 if (!winContext) winContext = XUniqueContext();
239 XSaveContext( display, w, winContext, (XPointer)(int)hwnd );
243 /***********************************************************************
244 * EVENT_XStateToKeyState
246 * Translate a X event state (Button1Mask, ShiftMask, etc...) to
247 * a Windows key state (MK_SHIFT, MK_CONTROL, etc...)
249 static WORD EVENT_XStateToKeyState( int state )
251 int kstate = 0;
253 if (state & Button1Mask) kstate |= MK_LBUTTON;
254 if (state & Button2Mask) kstate |= MK_MBUTTON;
255 if (state & Button3Mask) kstate |= MK_RBUTTON;
256 if (state & ShiftMask) kstate |= MK_SHIFT;
257 if (state & ControlMask) kstate |= MK_CONTROL;
258 return kstate;
262 /***********************************************************************
263 * EVENT_Expose
265 static void EVENT_Expose( HWND hwnd, XExposeEvent *event )
267 RECT rect;
268 WND * wndPtr = WIN_FindWndPtr( hwnd );
269 if (!wndPtr) return;
271 /* Make position relative to client area instead of window */
272 rect.left = event->x - (wndPtr->rectClient.left - wndPtr->rectWindow.left);
273 rect.top = event->y - (wndPtr->rectClient.top - wndPtr->rectWindow.top);
274 rect.right = rect.left + event->width;
275 rect.bottom = rect.top + event->height;
277 RedrawWindow( hwnd, &rect, 0,
278 RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE |
279 (event->count ? 0 : RDW_ERASENOW) );
283 /***********************************************************************
284 * EVENT_key
286 * Handle a X key event
288 static void EVENT_key( XKeyEvent *event )
290 char Str[24];
291 XComposeStatus cs;
292 KeySym keysym;
293 WORD vkey = 0;
294 WORD xkey, key_type, key;
295 KEYLP keylp;
296 BOOL extended = FALSE;
298 int count = XLookupString(event, Str, 1, &keysym, &cs);
299 Str[count] = '\0';
300 dprintf_key(stddeb,"WM_KEY??? : keysym=%lX, count=%u / %X / '%s'\n",
301 keysym, count, Str[0], Str);
303 xkey = LOWORD(keysym);
304 key_type = HIBYTE(xkey);
305 key = LOBYTE(xkey);
306 dprintf_key(stddeb," key_type=%X, key=%X\n", key_type, key);
308 if (key_type == 0xFF) /* non-character key */
310 if (key >= 0x08 && key <= 0x1B) /* special key */
311 vkey = special_key[key - 0x08];
312 else if (key >= 0x50 && key <= 0x57) /* cursor key */
313 vkey = cursor_key[key - 0x50];
314 else if (key >= 0x60 && key <= 0x6B) /* miscellaneous key */
315 vkey = misc_key[key - 0x60];
316 else if (key >= 0x7E && key <= 0xB9) /* keypad key */
318 vkey = keypad_key[key - 0x7E];
319 extended = TRUE;
321 else if (key >= 0xBE && key <= 0xCD) /* function key */
323 vkey = function_key[key - 0xBE];
324 extended = TRUE;
326 else if (key >= 0xE1 && key <= 0xEA) /* modifier key */
327 vkey = modifier_key[key - 0xE1];
328 else if (key == 0xFF) /* DEL key */
329 vkey = VK_DELETE;
331 else if (key_type == 0) /* character key */
333 if (isalnum(key))
334 vkey = toupper(key); /* convert lower to uppercase */
335 else
336 vkey = 0xbe;
339 if (event->type == KeyPress)
341 if (vkey == VK_MENU) ALTKeyState = TRUE;
342 if (!(KeyStateTable[vkey] & 0x0f))
343 KeyStateTable[vkey] ^= 0x80;
344 KeyStateTable[vkey] |= 0x01;
345 keylp.lp1.count = 1;
346 keylp.lp1.code = LOBYTE(event->keycode);
347 keylp.lp1.extended = (extended ? 1 : 0);
348 keylp.lp1.context = (event->state & Mod1Mask ? 1 : 0);
349 keylp.lp1.previous = (KeyDown ? 0 : 1);
350 keylp.lp1.transition = 0;
351 dprintf_key(stddeb," wParam=%X, lParam=%lX\n",
352 vkey, keylp.lp2 );
353 dprintf_key(stddeb," KeyState=%X\n", KeyStateTable[vkey]);
354 hardware_event( ALTKeyState ? WM_SYSKEYDOWN : WM_KEYDOWN,
355 vkey, keylp.lp2,
356 event->x_root - desktopX, event->y_root - desktopY,
357 event->time, 0 );
358 KeyDown = TRUE;
360 /* The key translation ought to take place in TranslateMessage().
361 * However, there is no way of passing the required information
362 * in a Windows message, so TranslateMessage does not currently
363 * do anything and the translation is done here.
365 if (count == 1) /* key has an ASCII representation */
367 dprintf_key(stddeb,"WM_CHAR : wParam=%X\n", (WORD)Str[0] );
368 PostMessage( GetFocus(), WM_CHAR, (WORD)(unsigned char)(Str[0]),
369 keylp.lp2 );
372 else
374 if (vkey == VK_MENU) ALTKeyState = FALSE;
375 KeyStateTable[vkey] &= 0xf0;
376 keylp.lp1.count = 1;
377 keylp.lp1.code = LOBYTE(event->keycode);
378 keylp.lp1.extended = (extended ? 1 : 0);
379 keylp.lp1.context = (event->state & Mod1Mask ? 1 : 0);
380 keylp.lp1.previous = 1;
381 keylp.lp1.transition = 1;
382 dprintf_key(stddeb," wParam=%X, lParam=%lX\n",
383 vkey, keylp.lp2 );
384 dprintf_key(stddeb," KeyState=%X\n", KeyStateTable[vkey]);
385 hardware_event( ((ALTKeyState || vkey == VK_MENU) ?
386 WM_SYSKEYUP : WM_KEYUP),
387 vkey, keylp.lp2,
388 event->x_root - desktopX, event->y_root - desktopY,
389 event->time, 0 );
390 KeyDown = FALSE;
395 /***********************************************************************
396 * EVENT_MotionNotify
398 static void EVENT_MotionNotify( XMotionEvent *event )
400 hardware_event( WM_MOUSEMOVE, EVENT_XStateToKeyState( event->state ), 0L,
401 event->x_root - desktopX, event->y_root - desktopY,
402 event->time, 0 );
406 /***********************************************************************
407 * EVENT_DummyMotionNotify
409 * Generate a dummy MotionNotify event. Used to force a WM_SETCURSOR message.
411 void EVENT_DummyMotionNotify(void)
413 Window root, child;
414 int rootX, rootY, childX, childY;
415 unsigned int state;
417 if (XQueryPointer( display, rootWindow, &root, &child,
418 &rootX, &rootY, &childX, &childY, &state ))
420 hardware_event(WM_MOUSEMOVE, EVENT_XStateToKeyState( state ), 0L,
421 rootX - desktopX, rootY - desktopY, GetTickCount(), 0 );
426 /***********************************************************************
427 * EVENT_ButtonPress
429 static void EVENT_ButtonPress( XButtonEvent *event )
431 static WORD messages[NB_BUTTONS] =
432 { WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN };
433 int buttonNum = event->button - 1;
435 if (buttonNum >= NB_BUTTONS) return;
436 MouseButtonsStates[buttonNum] = TRUE;
437 AsyncMouseButtonsStates[buttonNum] = TRUE;
438 hardware_event( messages[buttonNum],
439 EVENT_XStateToKeyState( event->state ), 0L,
440 event->x_root - desktopX, event->y_root - desktopY,
441 event->time, 0 );
445 /***********************************************************************
446 * EVENT_ButtonRelease
448 static void EVENT_ButtonRelease( XButtonEvent *event )
450 static const WORD messages[NB_BUTTONS] =
451 { WM_LBUTTONUP, WM_MBUTTONUP, WM_RBUTTONUP };
452 int buttonNum = event->button - 1;
454 if (buttonNum >= NB_BUTTONS) return;
455 MouseButtonsStates[buttonNum] = FALSE;
456 hardware_event( messages[buttonNum],
457 EVENT_XStateToKeyState( event->state ), 0L,
458 event->x_root - desktopX, event->y_root - desktopY,
459 event->time, 0 );
463 /**********************************************************************
464 * EVENT_FocusIn
466 static void EVENT_FocusIn (HWND hwnd, XFocusChangeEvent *event )
468 if (event->detail == NotifyPointer) return;
469 if (hwnd != GetActiveWindow()) WINPOS_ChangeActiveWindow( hwnd, FALSE );
470 if ((hwnd != GetFocus()) && ! IsChild( hwnd, GetFocus())) SetFocus( hwnd );
474 /**********************************************************************
475 * EVENT_FocusOut
477 * Note: only top-level override-redirect windows get FocusOut events.
479 static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event )
481 if (event->detail == NotifyPointer) return;
482 if (hwnd == GetActiveWindow()) WINPOS_ChangeActiveWindow( 0, FALSE );
483 if ((hwnd == GetFocus()) || IsChild( hwnd, GetFocus())) SetFocus( 0 );
487 /**********************************************************************
488 * EVENT_ConfigureNotify
490 * The ConfigureNotify event is only selected on the desktop window
491 * and on top-level windows when the -managed flag is used.
493 static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
495 if (hwnd == GetDesktopWindow())
497 desktopX = event->x;
498 desktopY = event->y;
500 else
502 /* A managed window; most of this code is shamelessly
503 * stolen from SetWindowPos
506 WND *wndPtr;
507 WINDOWPOS winpos;
508 RECT newWindowRect, newClientRect;
510 if (!(wndPtr = WIN_FindWndPtr( hwnd )))
512 dprintf_event(stddeb, "ConfigureNotify: invalid HWND "NPFMT"\n", hwnd);
513 return;
516 /* Artificial messages */
517 SendMessage(hwnd, WM_ENTERSIZEMOVE, 0, 0);
518 SendMessage(hwnd, WM_EXITSIZEMOVE, 0, 0);
520 /* Fill WINDOWPOS struct */
521 winpos.flags = SWP_NOACTIVATE | SWP_NOZORDER;
522 winpos.hwnd = hwnd;
523 winpos.x = event->x;
524 winpos.y = event->y;
525 winpos.cx = event->width;
526 winpos.cy = event->height;
528 /* Check for unchanged attributes */
529 if(winpos.x == wndPtr->rectWindow.left &&
530 winpos.y == wndPtr->rectWindow.top)
531 winpos.flags |= SWP_NOMOVE;
532 if(winpos.cx == wndPtr->rectWindow.right - wndPtr->rectWindow.left &&
533 winpos.cy == wndPtr->rectWindow.bottom - wndPtr->rectWindow.top)
534 winpos.flags |= SWP_NOSIZE;
536 /* Send WM_WINDOWPOSCHANGING */
537 SendMessage(hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)MAKE_SEGPTR(&winpos));
539 /* Calculate new position and size */
540 newWindowRect.left = event->x;
541 newWindowRect.right = event->x + event->width;
542 newWindowRect.top = event->y;
543 newWindowRect.bottom = event->y + event->height;
545 WINPOS_SendNCCalcSize( winpos.hwnd, TRUE, &newWindowRect,
546 &wndPtr->rectWindow, &wndPtr->rectClient,
547 &winpos, &newClientRect );
549 /* Set new size and position */
550 wndPtr->rectWindow = newWindowRect;
551 wndPtr->rectClient = newClientRect;
552 SendMessage(hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)MAKE_SEGPTR(&winpos));
557 /***********************************************************************
558 * EVENT_SelectionRequest
560 static void EVENT_SelectionRequest( HWND hwnd, XSelectionRequestEvent *event )
562 XSelectionEvent result;
563 Atom rprop;
564 Window request=event->requestor;
565 rprop=None;
566 if(event->target == XA_STRING)
568 HANDLE hText;
569 LPSTR text;
570 rprop=event->property;
571 if(rprop == None)rprop=event->target;
572 if(event->selection!=XA_PRIMARY)rprop=None;
573 else if(!IsClipboardFormatAvailable(CF_TEXT))rprop=None;
574 else{
575 /* Don't worry if we can't open */
576 BOOL couldOpen=OpenClipboard(hwnd);
577 hText=GetClipboardData(CF_TEXT);
578 text=GlobalLock(hText);
579 XChangeProperty(display,request,rprop,XA_STRING,
580 8,PropModeReplace,text,strlen(text));
581 GlobalUnlock(hText);
582 /* close only if we opened before */
583 if(couldOpen)CloseClipboard();
586 if(rprop==None) dprintf_event(stddeb,"Request for %s ignored\n",
587 XGetAtomName(display,event->target));
588 result.type=SelectionNotify;
589 result.display=display;
590 result.requestor=request;
591 result.selection=event->selection;
592 result.property=rprop;
593 result.target=event->target;
594 result.time=event->time;
595 XSendEvent(display,event->requestor,False,NoEventMask,(XEvent*)&result);
599 /***********************************************************************
600 * EVENT_SelectionNotify
602 static void EVENT_SelectionNotify(HWND hwnd, XSelectionEvent *event)
604 if(event->selection!=XA_PRIMARY)return;
605 if(event->target!=XA_STRING)CLIPBOARD_ReadSelection(0,None);
606 CLIPBOARD_ReadSelection(event->requestor,event->property);
610 /***********************************************************************
611 * EVENT_SelectionClear
613 static void EVENT_SelectionClear(HWND hwnd, XSelectionClearEvent *event)
615 if(event->selection!=XA_PRIMARY)return;
616 CLIPBOARD_ReleaseSelection(hwnd);
619 /**********************************************************************
620 * SetCapture (USER.18)
622 HWND SetCapture( HWND hwnd )
624 Window win;
625 HWND old_capture_wnd = captureWnd;
627 if (!hwnd)
629 ReleaseCapture();
630 return old_capture_wnd;
632 if (!(win = WIN_GetXWindow( hwnd ))) return 0;
633 if (XGrabPointer(display, win, False,
634 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
635 GrabModeAsync, GrabModeAsync,
636 None, None, CurrentTime ) == GrabSuccess)
638 dprintf_win(stddeb, "SetCapture: "NPFMT"\n", hwnd);
639 captureWnd = hwnd;
640 return old_capture_wnd;
642 else return 0;
646 /**********************************************************************
647 * ReleaseCapture (USER.19)
649 void ReleaseCapture()
651 if (captureWnd == 0) return;
652 XUngrabPointer( display, CurrentTime );
653 captureWnd = 0;
654 dprintf_win(stddeb, "ReleaseCapture\n");
657 /**********************************************************************
658 * GetCapture (USER.236)
660 HWND GetCapture()
662 return captureWnd;
666 /***********************************************************************
667 * GetMouseEventProc (USER.337)
669 FARPROC GetMouseEventProc(void)
671 char name[] = "Mouse_Event";
672 return GetProcAddress( GetModuleHandle("USER"), MAKE_SEGPTR(name) );
676 /***********************************************************************
677 * Mouse_Event (USER.299)
679 #ifndef WINELIB
680 void Mouse_Event( struct sigcontext_struct context )
682 /* Register values:
683 * AX = mouse event
684 * BX = horizontal displacement if AX & ME_MOVE
685 * CX = vertical displacement if AX & ME_MOVE
686 * DX = button state (?)
687 * SI = mouse event flags (?)
689 Window root, child;
690 int rootX, rootY, childX, childY;
691 unsigned int state;
693 if (AX_reg(&context) & ME_MOVE)
695 /* We have to actually move the cursor */
696 XWarpPointer( display, rootWindow, None, 0, 0, 0, 0,
697 (short)BX_reg(&context), (short)CX_reg(&context) );
698 return;
700 if (!XQueryPointer( display, rootWindow, &root, &child,
701 &rootX, &rootY, &childX, &childY, &state )) return;
702 if (AX_reg(&context) & ME_LDOWN)
703 hardware_event( WM_LBUTTONDOWN, EVENT_XStateToKeyState( state ), 0L,
704 rootX - desktopX, rootY - desktopY, GetTickCount(), 0);
705 if (AX_reg(&context) & ME_LUP)
706 hardware_event( WM_LBUTTONUP, EVENT_XStateToKeyState( state ), 0L,
707 rootX - desktopX, rootY - desktopY, GetTickCount(), 0);
708 if (AX_reg(&context) & ME_RDOWN)
709 hardware_event( WM_RBUTTONDOWN, EVENT_XStateToKeyState( state ), 0L,
710 rootX - desktopX, rootY - desktopY, GetTickCount(), 0);
711 if (AX_reg(&context) & ME_RUP)
712 hardware_event( WM_RBUTTONUP, EVENT_XStateToKeyState( state ), 0L,
713 rootX - desktopX, rootY - desktopY, GetTickCount(), 0);
715 #endif
718 /**********************************************************************
719 * EnableHardwareInput [USER.331]
721 BOOL EnableHardwareInput(BOOL bEnable)
723 BOOL bOldState = InputEnabled;
724 dprintf_event(stdnimp,"EMPTY STUB !!! EnableHardwareInput(%d);\n", bEnable);
725 InputEnabled = bEnable;
726 return (bOldState && !bEnable);