4 * Copyright 1998 Ulrich Weigand
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifdef HAVE_LIBXXF86DGA2
25 #include <X11/extensions/xf86dga.h>
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
33 #include "wine/winuser16.h"
37 #include "wine/server.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(cursor
);
42 /**********************************************************************/
45 #define Button6Mask (1<<13)
48 #define Button7Mask (1<<14)
51 #define NB_BUTTONS 7 /* Windows can handle 5 buttons and the wheel too */
53 static const UINT button_down_flags
[NB_BUTTONS
] =
56 MOUSEEVENTF_MIDDLEDOWN
,
57 MOUSEEVENTF_RIGHTDOWN
,
64 static const UINT button_up_flags
[NB_BUTTONS
] =
77 /***********************************************************************
80 * get the coordinates of a mouse event
82 static inline void get_coords( HWND hwnd
, int x
, int y
, POINT
*pt
)
84 struct x11drv_win_data
*data
= X11DRV_get_win_data( hwnd
);
88 pt
->x
= x
+ data
->whole_rect
.left
;
89 pt
->y
= y
+ data
->whole_rect
.top
;
93 /***********************************************************************
96 * Update the button state with what X provides us
98 static inline void update_button_state( unsigned int state
)
100 key_state_table
[VK_LBUTTON
] = (state
& Button1Mask
? 0x80 : 0);
101 key_state_table
[VK_MBUTTON
] = (state
& Button2Mask
? 0x80 : 0);
102 key_state_table
[VK_RBUTTON
] = (state
& Button3Mask
? 0x80 : 0);
103 key_state_table
[VK_XBUTTON1
]= (state
& Button6Mask
? 0x80 : 0);
104 key_state_table
[VK_XBUTTON2
]= (state
& Button7Mask
? 0x80 : 0);
108 /***********************************************************************
111 * Update the key state with what X provides us
113 static inline void update_key_state( unsigned int state
)
115 key_state_table
[VK_SHIFT
] = (state
& ShiftMask
? 0x80 : 0);
116 key_state_table
[VK_CONTROL
] = (state
& ControlMask
? 0x80 : 0);
120 /***********************************************************************
123 * Update the various window states on a mouse event.
125 static void update_mouse_state( HWND hwnd
, Window window
, int x
, int y
, unsigned int state
, POINT
*pt
)
127 struct x11drv_thread_data
*data
= x11drv_thread_data();
129 get_coords( hwnd
, x
, y
, pt
);
130 update_key_state( state
);
132 /* update the cursor */
134 if (data
->cursor_window
!= window
)
136 data
->cursor_window
= window
;
138 if (data
->cursor
) XDefineCursor( data
->display
, window
, data
->cursor
);
142 /* update the wine server Z-order */
144 if (window
!= data
->grab_window
&&
145 /* ignore event if a button is pressed, since the mouse is then grabbed too */
146 !(state
& (Button1Mask
|Button2Mask
|Button3Mask
|Button4Mask
|Button5Mask
|Button6Mask
|Button7Mask
)))
148 SERVER_START_REQ( update_window_zorder
)
151 req
->rect
.left
= pt
->x
;
152 req
->rect
.top
= pt
->y
;
153 req
->rect
.right
= pt
->x
+ 1;
154 req
->rect
.bottom
= pt
->y
+ 1;
155 wine_server_call( req
);
162 /***********************************************************************
165 static WORD
get_key_state(void)
169 if (GetSystemMetrics( SM_SWAPBUTTON
))
171 if (key_state_table
[VK_RBUTTON
] & 0x80) ret
|= MK_LBUTTON
;
172 if (key_state_table
[VK_LBUTTON
] & 0x80) ret
|= MK_RBUTTON
;
176 if (key_state_table
[VK_LBUTTON
] & 0x80) ret
|= MK_LBUTTON
;
177 if (key_state_table
[VK_RBUTTON
] & 0x80) ret
|= MK_RBUTTON
;
179 if (key_state_table
[VK_MBUTTON
] & 0x80) ret
|= MK_MBUTTON
;
180 if (key_state_table
[VK_SHIFT
] & 0x80) ret
|= MK_SHIFT
;
181 if (key_state_table
[VK_CONTROL
] & 0x80) ret
|= MK_CONTROL
;
182 if (key_state_table
[VK_XBUTTON1
] & 0x80) ret
|= MK_XBUTTON1
;
183 if (key_state_table
[VK_XBUTTON2
] & 0x80) ret
|= MK_XBUTTON2
;
188 /***********************************************************************
189 * queue_raw_mouse_message
191 static void queue_raw_mouse_message( UINT message
, HWND hwnd
, DWORD x
, DWORD y
,
192 DWORD data
, DWORD time
, DWORD extra_info
, UINT injected_flags
)
198 hook
.mouseData
= MAKELONG( 0, data
);
199 hook
.flags
= injected_flags
;
201 hook
.dwExtraInfo
= extra_info
;
203 if (HOOK_CallHooks( WH_MOUSE_LL
, HC_ACTION
, message
, (LPARAM
)&hook
, TRUE
)) return;
205 SERVER_START_REQ( send_message
)
207 req
->id
= (injected_flags
& LLMHF_INJECTED
) ? 0 : GetCurrentThreadId();
208 req
->type
= MSG_HARDWARE
;
212 req
->wparam
= MAKEWPARAM( get_key_state(), data
);
217 req
->info
= extra_info
;
219 req
->callback
= NULL
;
220 wine_server_call( req
);
227 /***********************************************************************
228 * X11DRV_send_mouse_input
230 void X11DRV_send_mouse_input( HWND hwnd
, DWORD flags
, DWORD x
, DWORD y
,
231 DWORD data
, DWORD time
, DWORD extra_info
, UINT injected_flags
)
235 if (flags
& MOUSEEVENTF_ABSOLUTE
)
237 if (injected_flags
& LLMHF_INJECTED
)
239 pt
.x
= (x
* screen_width
) >> 16;
240 pt
.y
= (y
* screen_height
) >> 16;
251 else if (flags
& MOUSEEVENTF_MOVE
)
253 int accel
[3], xMult
= 1, yMult
= 1;
255 /* dx and dy can be negative numbers for relative movements */
256 SystemParametersInfoW(SPI_GETMOUSE
, 0, accel
, 0);
258 if (x
> accel
[0] && accel
[2] != 0)
261 if ((x
> accel
[1]) && (accel
[2] == 2)) xMult
= 4;
263 if (y
> accel
[0] && accel
[2] != 0)
266 if ((y
> accel
[1]) && (accel
[2] == 2)) yMult
= 4;
270 pt
.x
= cursor_pos
.x
+ (long)x
* xMult
;
271 pt
.y
= cursor_pos
.y
+ (long)y
* yMult
;
273 /* Clip to the current screen size */
274 if (pt
.x
< 0) pt
.x
= 0;
275 else if (pt
.x
>= screen_width
) pt
.x
= screen_width
- 1;
276 if (pt
.y
< 0) pt
.y
= 0;
277 else if (pt
.y
>= screen_height
) pt
.y
= screen_height
- 1;
288 if (flags
& MOUSEEVENTF_MOVE
)
290 queue_raw_mouse_message( WM_MOUSEMOVE
, hwnd
, pt
.x
, pt
.y
, data
, time
,
291 extra_info
, injected_flags
);
292 if (injected_flags
& LLMHF_INJECTED
) /* we have to actually move the cursor */
294 TRACE( "warping to (%ld,%ld)\n", pt
.x
, pt
.y
);
296 XWarpPointer( thread_display(), root_window
, root_window
, 0, 0, 0, 0, pt
.x
, pt
.y
);
300 if (flags
& MOUSEEVENTF_LEFTDOWN
)
302 key_state_table
[VK_LBUTTON
] |= 0xc0;
303 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON
) ? WM_RBUTTONDOWN
: WM_LBUTTONDOWN
,
304 hwnd
, pt
.x
, pt
.y
, data
, time
, extra_info
, injected_flags
);
306 if (flags
& MOUSEEVENTF_LEFTUP
)
308 key_state_table
[VK_LBUTTON
] &= ~0x80;
309 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON
) ? WM_RBUTTONUP
: WM_LBUTTONUP
,
310 hwnd
, pt
.x
, pt
.y
, data
, time
, extra_info
, injected_flags
);
312 if (flags
& MOUSEEVENTF_RIGHTDOWN
)
314 key_state_table
[VK_RBUTTON
] |= 0xc0;
315 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON
) ? WM_LBUTTONDOWN
: WM_RBUTTONDOWN
,
316 hwnd
, pt
.x
, pt
.y
, data
, time
, extra_info
, injected_flags
);
318 if (flags
& MOUSEEVENTF_RIGHTUP
)
320 key_state_table
[VK_RBUTTON
] &= ~0x80;
321 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON
) ? WM_LBUTTONUP
: WM_RBUTTONUP
,
322 hwnd
, pt
.x
, pt
.y
, data
, time
, extra_info
, injected_flags
);
324 if (flags
& MOUSEEVENTF_MIDDLEDOWN
)
326 key_state_table
[VK_MBUTTON
] |= 0xc0;
327 queue_raw_mouse_message( WM_MBUTTONDOWN
, hwnd
, pt
.x
, pt
.y
, data
, time
,
328 extra_info
, injected_flags
);
330 if (flags
& MOUSEEVENTF_MIDDLEUP
)
332 key_state_table
[VK_MBUTTON
] &= ~0x80;
333 queue_raw_mouse_message( WM_MBUTTONUP
, hwnd
, pt
.x
, pt
.y
, data
, time
,
334 extra_info
, injected_flags
);
336 if (flags
& MOUSEEVENTF_WHEEL
)
338 queue_raw_mouse_message( WM_MOUSEWHEEL
, hwnd
, pt
.x
, pt
.y
, data
, time
,
339 extra_info
, injected_flags
);
341 if (flags
& MOUSEEVENTF_XDOWN
)
343 key_state_table
[VK_XBUTTON1
+ data
- 1] |= 0xc0;
344 queue_raw_mouse_message( WM_XBUTTONDOWN
, hwnd
, pt
.x
, pt
.y
, data
, time
,
345 extra_info
, injected_flags
);
347 if (flags
& MOUSEEVENTF_XUP
)
349 key_state_table
[VK_XBUTTON1
+ data
- 1] &= ~0x80;
350 queue_raw_mouse_message( WM_XBUTTONUP
, hwnd
, pt
.x
, pt
.y
, data
, time
,
351 extra_info
, injected_flags
);
356 /***********************************************************************
359 * Create an X cursor from a Windows one.
361 static Cursor
create_cursor( Display
*display
, CURSORICONINFO
*ptr
)
363 Pixmap pixmapBits
, pixmapMask
, pixmapMaskInv
, pixmapAll
;
365 Cursor cursor
= None
;
367 if (!ptr
) /* Create an empty cursor */
369 static const char data
[] = { 0 };
371 bg
.red
= bg
.green
= bg
.blue
= 0x0000;
372 pixmapBits
= XCreateBitmapFromData( display
, root_window
, data
, 1, 1 );
375 cursor
= XCreatePixmapCursor( display
, pixmapBits
, pixmapBits
,
377 XFreePixmap( display
, pixmapBits
);
380 else /* Create the X cursor from the bits */
385 TRACE("Bitmap %dx%d planes=%d bpp=%d bytesperline=%d\n",
386 ptr
->nWidth
, ptr
->nHeight
, ptr
->bPlanes
, ptr
->bBitsPerPixel
,
388 /* Create a pixmap and transfer all the bits to it */
390 /* NOTE: Following hack works, but only because XFree depth
391 * 1 images really use 1 bit/pixel (and so the same layout
392 * as the Windows cursor data). Perhaps use a more generic
395 /* This pixmap will be written with two bitmaps. The first is
396 * the mask and the second is the image.
398 if (!(pixmapAll
= XCreatePixmap( display
, root_window
,
399 ptr
->nWidth
, ptr
->nHeight
* 2, 1 )))
401 if (!(image
= XCreateImage( display
, visual
,
402 1, ZPixmap
, 0, (char *)(ptr
+ 1), ptr
->nWidth
,
403 ptr
->nHeight
* 2, 16, ptr
->nWidthBytes
/ptr
->bBitsPerPixel
)))
405 XFreePixmap( display
, pixmapAll
);
408 gc
= XCreateGC( display
, pixmapAll
, 0, NULL
);
409 XSetGraphicsExposures( display
, gc
, False
);
410 image
->byte_order
= MSBFirst
;
411 image
->bitmap_bit_order
= MSBFirst
;
412 image
->bitmap_unit
= 16;
413 _XInitImageFuncPtrs(image
);
414 if (ptr
->bPlanes
* ptr
->bBitsPerPixel
== 1)
416 /* A plain old white on black cursor. */
417 fg
.red
= fg
.green
= fg
.blue
= 0xffff;
418 bg
.red
= bg
.green
= bg
.blue
= 0x0000;
419 XPutImage( display
, pixmapAll
, gc
, image
,
420 0, 0, 0, 0, ptr
->nWidth
, ptr
->nHeight
* 2 );
424 int rbits
, gbits
, bbits
, red
, green
, blue
;
425 int rfg
, gfg
, bfg
, rbg
, gbg
, bbg
;
426 int rscale
, gscale
, bscale
;
427 int x
, y
, xmax
, ymax
, bitIndex
, byteIndex
, xorIndex
;
428 unsigned char *theMask
, *theImage
, theChar
;
429 int threshold
, fgBits
, bgBits
, bitShifted
;
430 BYTE pXorBits
[128]; /* Up to 32x32 icons */
432 switch (ptr
->bBitsPerPixel
)
447 FIXME("Currently no support for cursors with %d bits per pixel\n",
449 XFreePixmap( display
, pixmapAll
);
450 XFreeGC( display
, gc
);
452 XDestroyImage( image
);
455 /* The location of the mask. */
456 theMask
= (char *)(ptr
+ 1);
457 /* The mask should still be 1 bit per pixel. The color image
458 * should immediately follow the mask.
460 theImage
= &theMask
[ptr
->nWidth
/8 * ptr
->nHeight
];
461 rfg
= gfg
= bfg
= rbg
= gbg
= bbg
= 0;
467 xmax
= (ptr
->nWidth
> 32) ? 32 : ptr
->nWidth
;
468 if (ptr
->nWidth
> 32) {
469 ERR("Got a %dx%d cursor. Cannot handle larger than 32x32.\n",
470 ptr
->nWidth
, ptr
->nHeight
);
472 ymax
= (ptr
->nHeight
> 32) ? 32 : ptr
->nHeight
;
474 memset(pXorBits
, 0, 128);
475 for (y
=0; y
<ymax
; y
++)
477 for (x
=0; x
<xmax
; x
++)
479 red
= green
= blue
= 0;
480 switch (ptr
->bBitsPerPixel
)
483 theChar
= theImage
[byteIndex
++];
485 theChar
= theImage
[byteIndex
++];
487 theChar
= theImage
[byteIndex
++];
491 theChar
= theImage
[byteIndex
++];
492 blue
= theChar
& 0x1F;
493 green
= (theChar
& 0xE0) >> 5;
494 theChar
= theImage
[byteIndex
++];
495 green
|= (theChar
& 0x07) << 3;
496 red
= (theChar
& 0xF8) >> 3;
500 if (red
+green
+blue
> threshold
)
506 pXorBits
[xorIndex
] |= bitShifted
;
520 bitShifted
= bitShifted
<< 1;
523 rscale
= 1 << (16 - rbits
);
524 gscale
= 1 << (16 - gbits
);
525 bscale
= 1 << (16 - bbits
);
528 fg
.red
= rfg
* rscale
/ fgBits
;
529 fg
.green
= gfg
* gscale
/ fgBits
;
530 fg
.blue
= bfg
* bscale
/ fgBits
;
532 else fg
.red
= fg
.green
= fg
.blue
= 0;
533 bgBits
= xmax
* ymax
- fgBits
;
536 bg
.red
= rbg
* rscale
/ bgBits
;
537 bg
.green
= gbg
* gscale
/ bgBits
;
538 bg
.blue
= bbg
* bscale
/ bgBits
;
540 else bg
.red
= bg
.green
= bg
.blue
= 0;
541 pixmapBits
= XCreateBitmapFromData( display
, root_window
, (char *)pXorBits
, xmax
, ymax
);
544 XFreePixmap( display
, pixmapAll
);
545 XFreeGC( display
, gc
);
547 XDestroyImage( image
);
552 XPutImage( display
, pixmapAll
, gc
, image
,
553 0, 0, 0, 0, ptr
->nWidth
, ptr
->nHeight
);
554 XSetFunction( display
, gc
, GXcopy
);
556 XCopyArea( display
, pixmapBits
, pixmapAll
, gc
,
557 0, 0, xmax
, ymax
, 0, ptr
->nHeight
);
558 XFreePixmap( display
, pixmapBits
);
561 XDestroyImage( image
);
563 /* Now create the 2 pixmaps for bits and mask */
565 pixmapBits
= XCreatePixmap( display
, root_window
, ptr
->nWidth
, ptr
->nHeight
, 1 );
566 pixmapMask
= XCreatePixmap( display
, root_window
, ptr
->nWidth
, ptr
->nHeight
, 1 );
567 pixmapMaskInv
= XCreatePixmap( display
, root_window
, ptr
->nWidth
, ptr
->nHeight
, 1 );
569 /* Make sure everything went OK so far */
571 if (pixmapBits
&& pixmapMask
&& pixmapMaskInv
)
575 /* We have to do some magic here, as cursors are not fully
576 * compatible between Windows and X11. Under X11, there
577 * are only 3 possible color cursor: black, white and
578 * masked. So we map the 4th Windows color (invert the
579 * bits on the screen) to black and an additional white bit on
580 * an other place (+1,+1). This require some boolean arithmetic:
583 * And Xor Result | Bits Mask Result
584 * 0 0 black | 0 1 background
585 * 0 1 white | 1 1 foreground
586 * 1 0 no change | X 0 no change
587 * 1 1 inverted | 0 1 background
590 * Bits = not 'And' and 'Xor' or 'And2' and 'Xor2'
591 * Mask = not 'And' or 'Xor' or 'And2' and 'Xor2'
593 * FIXME: apparently some servers do support 'inverted' color.
594 * I don't know if it's correct per the X spec, but maybe
595 * we ought to take advantage of it. -- AJ
597 XSetFunction( display
, gc
, GXcopy
);
598 XCopyArea( display
, pixmapAll
, pixmapBits
, gc
,
599 0, 0, ptr
->nWidth
, ptr
->nHeight
, 0, 0 );
600 XCopyArea( display
, pixmapAll
, pixmapMask
, gc
,
601 0, 0, ptr
->nWidth
, ptr
->nHeight
, 0, 0 );
602 XCopyArea( display
, pixmapAll
, pixmapMaskInv
, gc
,
603 0, 0, ptr
->nWidth
, ptr
->nHeight
, 0, 0 );
604 XSetFunction( display
, gc
, GXand
);
605 XCopyArea( display
, pixmapAll
, pixmapMaskInv
, gc
,
606 0, ptr
->nHeight
, ptr
->nWidth
, ptr
->nHeight
, 0, 0 );
607 XSetFunction( display
, gc
, GXandReverse
);
608 XCopyArea( display
, pixmapAll
, pixmapBits
, gc
,
609 0, ptr
->nHeight
, ptr
->nWidth
, ptr
->nHeight
, 0, 0 );
610 XSetFunction( display
, gc
, GXorReverse
);
611 XCopyArea( display
, pixmapAll
, pixmapMask
, gc
,
612 0, ptr
->nHeight
, ptr
->nWidth
, ptr
->nHeight
, 0, 0 );
613 /* Additional white */
614 XSetFunction( display
, gc
, GXor
);
615 XCopyArea( display
, pixmapMaskInv
, pixmapMask
, gc
,
616 0, 0, ptr
->nWidth
, ptr
->nHeight
, 1, 1 );
617 XCopyArea( display
, pixmapMaskInv
, pixmapBits
, gc
,
618 0, 0, ptr
->nWidth
, ptr
->nHeight
, 1, 1 );
619 XSetFunction( display
, gc
, GXcopy
);
621 /* Make sure hotspot is valid */
622 hotspot
.x
= ptr
->ptHotSpot
.x
;
623 hotspot
.y
= ptr
->ptHotSpot
.y
;
624 if (hotspot
.x
< 0 || hotspot
.x
>= ptr
->nWidth
||
625 hotspot
.y
< 0 || hotspot
.y
>= ptr
->nHeight
)
627 hotspot
.x
= ptr
->nWidth
/ 2;
628 hotspot
.y
= ptr
->nHeight
/ 2;
630 cursor
= XCreatePixmapCursor( display
, pixmapBits
, pixmapMask
,
631 &fg
, &bg
, hotspot
.x
, hotspot
.y
);
634 /* Now free everything */
636 if (pixmapAll
) XFreePixmap( display
, pixmapAll
);
637 if (pixmapBits
) XFreePixmap( display
, pixmapBits
);
638 if (pixmapMask
) XFreePixmap( display
, pixmapMask
);
639 if (pixmapMaskInv
) XFreePixmap( display
, pixmapMaskInv
);
640 XFreeGC( display
, gc
);
646 /***********************************************************************
647 * SetCursor (X11DRV.@)
649 void X11DRV_SetCursor( CURSORICONINFO
*lpCursor
)
653 if (root_window
!= DefaultRootWindow(gdi_display
))
655 /* If in desktop mode, set the cursor on the desktop window */
658 cursor
= create_cursor( gdi_display
, lpCursor
);
661 XDefineCursor( gdi_display
, root_window
, cursor
);
662 /* Make the change take effect immediately */
664 XFreeCursor( gdi_display
, cursor
);
668 else /* set the same cursor for all top-level windows of the current thread */
670 struct x11drv_thread_data
*data
= x11drv_thread_data();
673 cursor
= create_cursor( data
->display
, lpCursor
);
676 if (data
->cursor
) XFreeCursor( data
->display
, data
->cursor
);
677 data
->cursor
= cursor
;
678 if (data
->cursor_window
)
680 XDefineCursor( data
->display
, data
->cursor_window
, cursor
);
681 /* Make the change take effect immediately */
682 XFlush( data
->display
);
689 /***********************************************************************
690 * SetCursorPos (X11DRV.@)
692 BOOL
X11DRV_SetCursorPos( INT x
, INT y
)
694 Display
*display
= thread_display();
696 TRACE( "warping to (%d,%d)\n", x
, y
);
699 XWarpPointer( display
, root_window
, root_window
, 0, 0, 0, 0, x
, y
);
706 /***********************************************************************
707 * GetCursorPos (X11DRV.@)
709 BOOL
X11DRV_GetCursorPos(LPPOINT pos
)
711 Display
*display
= thread_display();
713 int rootX
, rootY
, winX
, winY
;
717 if (XQueryPointer( display
, root_window
, &root
, &child
,
718 &rootX
, &rootY
, &winX
, &winY
, &xstate
))
720 update_key_state( xstate
);
721 update_button_state( xstate
);
722 TRACE("pointer at (%d,%d)\n", winX
, winY
);
731 /***********************************************************************
734 void X11DRV_ButtonPress( HWND hwnd
, XEvent
*xev
)
736 XButtonEvent
*event
= &xev
->xbutton
;
737 int buttonNum
= event
->button
- 1;
741 if (buttonNum
>= NB_BUTTONS
) return;
750 wData
= -WHEEL_DELTA
;
760 update_mouse_state( hwnd
, event
->window
, event
->x
, event
->y
, event
->state
, &pt
);
762 X11DRV_send_mouse_input( hwnd
, button_down_flags
[buttonNum
] | MOUSEEVENTF_ABSOLUTE
,
763 pt
.x
, pt
.y
, wData
, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
767 /***********************************************************************
768 * X11DRV_ButtonRelease
770 void X11DRV_ButtonRelease( HWND hwnd
, XEvent
*xev
)
772 XButtonEvent
*event
= &xev
->xbutton
;
773 int buttonNum
= event
->button
- 1;
777 if (buttonNum
>= NB_BUTTONS
|| !button_up_flags
[buttonNum
]) return;
790 update_mouse_state( hwnd
, event
->window
, event
->x
, event
->y
, event
->state
, &pt
);
792 X11DRV_send_mouse_input( hwnd
, button_up_flags
[buttonNum
] | MOUSEEVENTF_ABSOLUTE
,
793 pt
.x
, pt
.y
, wData
, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
797 /***********************************************************************
798 * X11DRV_MotionNotify
800 void X11DRV_MotionNotify( HWND hwnd
, XEvent
*xev
)
802 XMotionEvent
*event
= &xev
->xmotion
;
805 TRACE("hwnd %p, event->is_hint %d\n", hwnd
, event
->is_hint
);
809 update_mouse_state( hwnd
, event
->window
, event
->x
, event
->y
, event
->state
, &pt
);
811 X11DRV_send_mouse_input( hwnd
, MOUSEEVENTF_MOVE
| MOUSEEVENTF_ABSOLUTE
,
812 pt
.x
, pt
.y
, 0, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
816 /***********************************************************************
819 void X11DRV_EnterNotify( HWND hwnd
, XEvent
*xev
)
821 XCrossingEvent
*event
= &xev
->xcrossing
;
824 TRACE("hwnd %p, event->detail %d\n", hwnd
, event
->detail
);
827 if (event
->detail
== NotifyVirtual
|| event
->detail
== NotifyNonlinearVirtual
) return;
829 /* simulate a mouse motion event */
830 update_mouse_state( hwnd
, event
->window
, event
->x
, event
->y
, event
->state
, &pt
);
832 X11DRV_send_mouse_input( hwnd
, MOUSEEVENTF_MOVE
| MOUSEEVENTF_ABSOLUTE
,
833 pt
.x
, pt
.y
, 0, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
837 #ifdef HAVE_LIBXXF86DGA2
841 /**********************************************************************
842 * X11DRV_DGAMotionEvent
844 void X11DRV_DGAMotionEvent( HWND hwnd
, XEvent
*xev
)
846 XDGAMotionEvent
*event
= (XDGAMotionEvent
*)xev
;
847 update_key_state( event
->state
);
848 X11DRV_send_mouse_input( DGAhwnd
, MOUSEEVENTF_MOVE
, event
->dx
, event
->dy
,
849 0, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
852 /**********************************************************************
853 * X11DRV_DGAButtonPressEvent
855 void X11DRV_DGAButtonPressEvent( HWND hwnd
, XEvent
*xev
)
857 XDGAButtonEvent
*event
= (XDGAButtonEvent
*)xev
;
858 int buttonNum
= event
->button
- 1;
860 if (buttonNum
>= NB_BUTTONS
) return;
861 update_key_state( event
->state
);
862 X11DRV_send_mouse_input( DGAhwnd
, button_down_flags
[buttonNum
], 0, 0,
863 0, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
866 /**********************************************************************
867 * X11DRV_DGAButtonReleaseEvent
869 void X11DRV_DGAButtonReleaseEvent( HWND hwnd
, XEvent
*xev
)
871 XDGAButtonEvent
*event
= (XDGAButtonEvent
*)xev
;
872 int buttonNum
= event
->button
- 1;
874 if (buttonNum
>= NB_BUTTONS
) return;
875 update_key_state( event
->state
);
876 X11DRV_send_mouse_input( DGAhwnd
, button_up_flags
[buttonNum
], 0, 0,
877 0, EVENT_x11_time_to_win32_time(event
->time
), 0, 0 );
880 #endif /* HAVE_LIBXXF86DGA2 */