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 /**********************************************************************/
44 #define NB_BUTTONS 5 /* Windows can handle 3 buttons and the wheel too */
46 static const UINT button_down_flags[NB_BUTTONS] =
49 MOUSEEVENTF_MIDDLEDOWN,
50 MOUSEEVENTF_RIGHTDOWN,
55 static const UINT button_up_flags[NB_BUTTONS] =
66 /***********************************************************************
69 * get the coordinates of a mouse event
71 static inline void get_coords( HWND hwnd, int x, int y, POINT *pt )
73 struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
77 pt->x = x + data->whole_rect.left;
78 pt->y = y + data->whole_rect.top;
82 /***********************************************************************
85 * Update the button state with what X provides us
87 static inline void update_button_state( unsigned int state )
89 key_state_table[VK_LBUTTON] = (state & Button1Mask ? 0x80 : 0);
90 key_state_table[VK_MBUTTON] = (state & Button2Mask ? 0x80 : 0);
91 key_state_table[VK_RBUTTON] = (state & Button3Mask ? 0x80 : 0);
95 /***********************************************************************
98 * Update the key state with what X provides us
100 static inline void update_key_state( unsigned int state )
102 key_state_table[VK_SHIFT] = (state & ShiftMask ? 0x80 : 0);
103 key_state_table[VK_CONTROL] = (state & ControlMask ? 0x80 : 0);
107 /***********************************************************************
110 * Update the various window states on a mouse event.
112 static void update_mouse_state( HWND hwnd, Window window, int x, int y, unsigned int state, POINT *pt )
114 struct x11drv_thread_data *data = x11drv_thread_data();
116 get_coords( hwnd, x, y, pt );
117 update_key_state( state );
119 /* update the cursor */
121 if (data->cursor_window != window)
123 data->cursor_window = window;
125 if (data->cursor) XDefineCursor( data->display, window, data->cursor );
129 /* update the wine server Z-order */
131 if (window != data->grab_window &&
132 /* ignore event if a button is pressed, since the mouse is then grabbed too */
133 !(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)))
135 SERVER_START_REQ( update_window_zorder )
138 req->rect.left = pt->x;
139 req->rect.top = pt->y;
140 req->rect.right = pt->x + 1;
141 req->rect.bottom = pt->y + 1;
142 wine_server_call( req );
149 /***********************************************************************
152 static WORD get_key_state(void)
156 if (GetSystemMetrics( SM_SWAPBUTTON ))
158 if (key_state_table[VK_RBUTTON] & 0x80) ret |= MK_LBUTTON;
159 if (key_state_table[VK_LBUTTON] & 0x80) ret |= MK_RBUTTON;
163 if (key_state_table[VK_LBUTTON] & 0x80) ret |= MK_LBUTTON;
164 if (key_state_table[VK_RBUTTON] & 0x80) ret |= MK_RBUTTON;
166 if (key_state_table[VK_MBUTTON] & 0x80) ret |= MK_MBUTTON;
167 if (key_state_table[VK_SHIFT] & 0x80) ret |= MK_SHIFT;
168 if (key_state_table[VK_CONTROL] & 0x80) ret |= MK_CONTROL;
169 if (key_state_table[VK_XBUTTON1] & 0x80) ret |= MK_XBUTTON1;
170 if (key_state_table[VK_XBUTTON2] & 0x80) ret |= MK_XBUTTON2;
175 /***********************************************************************
176 * queue_raw_mouse_message
178 static void queue_raw_mouse_message( UINT message, HWND hwnd, DWORD x, DWORD y,
179 DWORD data, DWORD time, DWORD extra_info, UINT injected_flags )
185 hook.mouseData = MAKELONG( 0, data );
186 hook.flags = injected_flags;
188 hook.dwExtraInfo = extra_info;
190 if (HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) return;
192 SERVER_START_REQ( send_message )
194 req->id = (injected_flags & LLMHF_INJECTED) ? 0 : GetCurrentThreadId();
195 req->type = MSG_HARDWARE;
199 req->wparam = MAKEWPARAM( get_key_state(), data );
204 req->info = extra_info;
206 req->callback = NULL;
207 wine_server_call( req );
214 /***********************************************************************
215 * X11DRV_send_mouse_input
217 void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
218 DWORD data, DWORD time, DWORD extra_info, UINT injected_flags )
222 if (flags & MOUSEEVENTF_ABSOLUTE)
224 if (injected_flags & LLMHF_INJECTED)
226 pt.x = (x * screen_width) >> 16;
227 pt.y = (y * screen_height) >> 16;
238 else if (flags & MOUSEEVENTF_MOVE)
240 int accel[3], xMult = 1, yMult = 1;
242 /* dx and dy can be negative numbers for relative movements */
243 SystemParametersInfoW(SPI_GETMOUSE, 0, accel, 0);
245 if (x > accel[0] && accel[2] != 0)
248 if ((x > accel[1]) && (accel[2] == 2)) xMult = 4;
250 if (y > accel[0] && accel[2] != 0)
253 if ((y > accel[1]) && (accel[2] == 2)) yMult = 4;
257 pt.x = cursor_pos.x + (long)x * xMult;
258 pt.y = cursor_pos.y + (long)y * yMult;
260 /* Clip to the current screen size */
261 if (pt.x < 0) pt.x = 0;
262 else if (pt.x >= screen_width) pt.x = screen_width - 1;
263 if (pt.y < 0) pt.y = 0;
264 else if (pt.y >= screen_height) pt.y = screen_height - 1;
275 if (flags & MOUSEEVENTF_MOVE)
277 queue_raw_mouse_message( WM_MOUSEMOVE, hwnd, pt.x, pt.y, data, time,
278 extra_info, injected_flags );
279 if (injected_flags & LLMHF_INJECTED) /* we have to actually move the cursor */
281 TRACE( "warping to (%ld,%ld)\n", pt.x, pt.y );
283 XWarpPointer( thread_display(), root_window, root_window, 0, 0, 0, 0, pt.x, pt.y );
287 if (flags & MOUSEEVENTF_LEFTDOWN)
289 key_state_table[VK_LBUTTON] |= 0xc0;
290 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_RBUTTONDOWN : WM_LBUTTONDOWN,
291 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
293 if (flags & MOUSEEVENTF_LEFTUP)
295 key_state_table[VK_LBUTTON] &= ~0x80;
296 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_RBUTTONUP : WM_LBUTTONUP,
297 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
299 if (flags & MOUSEEVENTF_RIGHTDOWN)
301 key_state_table[VK_RBUTTON] |= 0xc0;
302 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONDOWN : WM_RBUTTONDOWN,
303 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
305 if (flags & MOUSEEVENTF_RIGHTUP)
307 key_state_table[VK_RBUTTON] &= ~0x80;
308 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONUP : WM_RBUTTONUP,
309 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
311 if (flags & MOUSEEVENTF_MIDDLEDOWN)
313 key_state_table[VK_MBUTTON] |= 0xc0;
314 queue_raw_mouse_message( WM_MBUTTONDOWN, hwnd, pt.x, pt.y, data, time,
315 extra_info, injected_flags );
317 if (flags & MOUSEEVENTF_MIDDLEUP)
319 key_state_table[VK_MBUTTON] &= ~0x80;
320 queue_raw_mouse_message( WM_MBUTTONUP, hwnd, pt.x, pt.y, data, time,
321 extra_info, injected_flags );
323 if (flags & MOUSEEVENTF_WHEEL)
325 queue_raw_mouse_message( WM_MOUSEWHEEL, hwnd, pt.x, pt.y, data, time,
326 extra_info, injected_flags );
331 /***********************************************************************
334 * Create an X cursor from a Windows one.
336 static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
338 Pixmap pixmapBits, pixmapMask, pixmapMaskInv, pixmapAll;
340 Cursor cursor = None;
342 if (!ptr) /* Create an empty cursor */
344 static const char data[] = { 0 };
346 bg.red = bg.green = bg.blue = 0x0000;
347 pixmapBits = XCreateBitmapFromData( display, root_window, data, 1, 1 );
350 cursor = XCreatePixmapCursor( display, pixmapBits, pixmapBits,
352 XFreePixmap( display, pixmapBits );
355 else /* Create the X cursor from the bits */
360 TRACE("Bitmap %dx%d planes=%d bpp=%d bytesperline=%d\n",
361 ptr->nWidth, ptr->nHeight, ptr->bPlanes, ptr->bBitsPerPixel,
363 /* Create a pixmap and transfer all the bits to it */
365 /* NOTE: Following hack works, but only because XFree depth
366 * 1 images really use 1 bit/pixel (and so the same layout
367 * as the Windows cursor data). Perhaps use a more generic
370 /* This pixmap will be written with two bitmaps. The first is
371 * the mask and the second is the image.
373 if (!(pixmapAll = XCreatePixmap( display, root_window,
374 ptr->nWidth, ptr->nHeight * 2, 1 )))
376 if (!(image = XCreateImage( display, visual,
377 1, ZPixmap, 0, (char *)(ptr + 1), ptr->nWidth,
378 ptr->nHeight * 2, 16, ptr->nWidthBytes/ptr->bBitsPerPixel)))
380 XFreePixmap( display, pixmapAll );
383 gc = XCreateGC( display, pixmapAll, 0, NULL );
384 XSetGraphicsExposures( display, gc, False );
385 image->byte_order = MSBFirst;
386 image->bitmap_bit_order = MSBFirst;
387 image->bitmap_unit = 16;
388 _XInitImageFuncPtrs(image);
389 if (ptr->bPlanes * ptr->bBitsPerPixel == 1)
391 /* A plain old white on black cursor. */
392 fg.red = fg.green = fg.blue = 0xffff;
393 bg.red = bg.green = bg.blue = 0x0000;
394 XPutImage( display, pixmapAll, gc, image,
395 0, 0, 0, 0, ptr->nWidth, ptr->nHeight * 2 );
399 int rbits, gbits, bbits, red, green, blue;
400 int rfg, gfg, bfg, rbg, gbg, bbg;
401 int rscale, gscale, bscale;
402 int x, y, xmax, ymax, bitIndex, byteIndex, xorIndex;
403 unsigned char *theMask, *theImage, theChar;
404 int threshold, fgBits, bgBits, bitShifted;
405 BYTE pXorBits[128]; /* Up to 32x32 icons */
407 switch (ptr->bBitsPerPixel)
422 FIXME("Currently no support for cursors with %d bits per pixel\n",
424 XFreePixmap( display, pixmapAll );
425 XFreeGC( display, gc );
427 XDestroyImage( image );
430 /* The location of the mask. */
431 theMask = (char *)(ptr + 1);
432 /* The mask should still be 1 bit per pixel. The color image
433 * should immediately follow the mask.
435 theImage = &theMask[ptr->nWidth/8 * ptr->nHeight];
436 rfg = gfg = bfg = rbg = gbg = bbg = 0;
442 xmax = (ptr->nWidth > 32) ? 32 : ptr->nWidth;
443 if (ptr->nWidth > 32) {
444 ERR("Got a %dx%d cursor. Cannot handle larger than 32x32.\n",
445 ptr->nWidth, ptr->nHeight);
447 ymax = (ptr->nHeight > 32) ? 32 : ptr->nHeight;
449 memset(pXorBits, 0, 128);
450 for (y=0; y<ymax; y++)
452 for (x=0; x<xmax; x++)
454 red = green = blue = 0;
455 switch (ptr->bBitsPerPixel)
458 theChar = theImage[byteIndex++];
460 theChar = theImage[byteIndex++];
462 theChar = theImage[byteIndex++];
466 theChar = theImage[byteIndex++];
467 blue = theChar & 0x1F;
468 green = (theChar & 0xE0) >> 5;
469 theChar = theImage[byteIndex++];
470 green |= (theChar & 0x07) << 3;
471 red = (theChar & 0xF8) >> 3;
475 if (red+green+blue > threshold)
481 pXorBits[xorIndex] |= bitShifted;
495 bitShifted = bitShifted << 1;
498 rscale = 1 << (16 - rbits);
499 gscale = 1 << (16 - gbits);
500 bscale = 1 << (16 - bbits);
503 fg.red = rfg * rscale / fgBits;
504 fg.green = gfg * gscale / fgBits;
505 fg.blue = bfg * bscale / fgBits;
507 else fg.red = fg.green = fg.blue = 0;
508 bgBits = xmax * ymax - fgBits;
511 bg.red = rbg * rscale / bgBits;
512 bg.green = gbg * gscale / bgBits;
513 bg.blue = bbg * bscale / bgBits;
515 else bg.red = bg.green = bg.blue = 0;
516 pixmapBits = XCreateBitmapFromData( display, root_window, pXorBits, xmax, ymax );
519 XFreePixmap( display, pixmapAll );
520 XFreeGC( display, gc );
522 XDestroyImage( image );
527 XPutImage( display, pixmapAll, gc, image,
528 0, 0, 0, 0, ptr->nWidth, ptr->nHeight );
529 XSetFunction( display, gc, GXcopy );
531 XCopyArea( display, pixmapBits, pixmapAll, gc,
532 0, 0, xmax, ymax, 0, ptr->nHeight );
533 XFreePixmap( display, pixmapBits );
536 XDestroyImage( image );
538 /* Now create the 2 pixmaps for bits and mask */
540 pixmapBits = XCreatePixmap( display, root_window, ptr->nWidth, ptr->nHeight, 1 );
541 pixmapMask = XCreatePixmap( display, root_window, ptr->nWidth, ptr->nHeight, 1 );
542 pixmapMaskInv = XCreatePixmap( display, root_window, ptr->nWidth, ptr->nHeight, 1 );
544 /* Make sure everything went OK so far */
546 if (pixmapBits && pixmapMask && pixmapMaskInv)
550 /* We have to do some magic here, as cursors are not fully
551 * compatible between Windows and X11. Under X11, there
552 * are only 3 possible color cursor: black, white and
553 * masked. So we map the 4th Windows color (invert the
554 * bits on the screen) to black and an additional white bit on
555 * an other place (+1,+1). This require some boolean arithmetic:
558 * And Xor Result | Bits Mask Result
559 * 0 0 black | 0 1 background
560 * 0 1 white | 1 1 foreground
561 * 1 0 no change | X 0 no change
562 * 1 1 inverted | 0 1 background
565 * Bits = not 'And' and 'Xor' or 'And2' and 'Xor2'
566 * Mask = not 'And' or 'Xor' or 'And2' and 'Xor2'
568 * FIXME: apparently some servers do support 'inverted' color.
569 * I don't know if it's correct per the X spec, but maybe
570 * we ought to take advantage of it. -- AJ
572 XSetFunction( display, gc, GXcopy );
573 XCopyArea( display, pixmapAll, pixmapBits, gc,
574 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
575 XCopyArea( display, pixmapAll, pixmapMask, gc,
576 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
577 XCopyArea( display, pixmapAll, pixmapMaskInv, gc,
578 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
579 XSetFunction( display, gc, GXand );
580 XCopyArea( display, pixmapAll, pixmapMaskInv, gc,
581 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
582 XSetFunction( display, gc, GXandReverse );
583 XCopyArea( display, pixmapAll, pixmapBits, gc,
584 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
585 XSetFunction( display, gc, GXorReverse );
586 XCopyArea( display, pixmapAll, pixmapMask, gc,
587 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
588 /* Additional white */
589 XSetFunction( display, gc, GXor );
590 XCopyArea( display, pixmapMaskInv, pixmapMask, gc,
591 0, 0, ptr->nWidth, ptr->nHeight, 1, 1 );
592 XCopyArea( display, pixmapMaskInv, pixmapBits, gc,
593 0, 0, ptr->nWidth, ptr->nHeight, 1, 1 );
594 XSetFunction( display, gc, GXcopy );
596 /* Make sure hotspot is valid */
597 hotspot.x = ptr->ptHotSpot.x;
598 hotspot.y = ptr->ptHotSpot.y;
599 if (hotspot.x < 0 || hotspot.x >= ptr->nWidth ||
600 hotspot.y < 0 || hotspot.y >= ptr->nHeight)
602 hotspot.x = ptr->nWidth / 2;
603 hotspot.y = ptr->nHeight / 2;
605 cursor = XCreatePixmapCursor( display, pixmapBits, pixmapMask,
606 &fg, &bg, hotspot.x, hotspot.y );
609 /* Now free everything */
611 if (pixmapAll) XFreePixmap( display, pixmapAll );
612 if (pixmapBits) XFreePixmap( display, pixmapBits );
613 if (pixmapMask) XFreePixmap( display, pixmapMask );
614 if (pixmapMaskInv) XFreePixmap( display, pixmapMaskInv );
615 XFreeGC( display, gc );
621 /***********************************************************************
622 * SetCursor (X11DRV.@)
624 void X11DRV_SetCursor( CURSORICONINFO *lpCursor )
628 if (root_window != DefaultRootWindow(gdi_display))
630 /* If in desktop mode, set the cursor on the desktop window */
633 cursor = create_cursor( gdi_display, lpCursor );
636 XDefineCursor( gdi_display, root_window, cursor );
637 /* Make the change take effect immediately */
639 XFreeCursor( gdi_display, cursor );
643 else /* set the same cursor for all top-level windows of the current thread */
645 struct x11drv_thread_data *data = x11drv_thread_data();
648 cursor = create_cursor( data->display, lpCursor );
651 if (data->cursor) XFreeCursor( data->display, data->cursor );
652 data->cursor = cursor;
653 if (data->cursor_window)
655 XDefineCursor( data->display, data->cursor_window, cursor );
656 /* Make the change take effect immediately */
657 XFlush( data->display );
664 /***********************************************************************
665 * SetCursorPos (X11DRV.@)
667 BOOL X11DRV_SetCursorPos( INT x, INT y )
669 Display *display = thread_display();
671 TRACE( "warping to (%d,%d)\n", x, y );
674 XWarpPointer( display, root_window, root_window, 0, 0, 0, 0, x, y );
681 /***********************************************************************
682 * GetCursorPos (X11DRV.@)
684 BOOL X11DRV_GetCursorPos(LPPOINT pos)
686 Display *display = thread_display();
688 int rootX, rootY, winX, winY;
692 if (XQueryPointer( display, root_window, &root, &child,
693 &rootX, &rootY, &winX, &winY, &xstate ))
695 update_key_state( xstate );
696 update_button_state( xstate );
697 TRACE("pointer at (%d,%d)\n", winX, winY );
706 /***********************************************************************
709 void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
711 XButtonEvent *event = &xev->xbutton;
712 int buttonNum = event->button - 1;
716 if (buttonNum >= NB_BUTTONS) return;
725 wData = -WHEEL_DELTA;
729 update_mouse_state( hwnd, event->window, event->x, event->y, event->state, &pt );
731 X11DRV_send_mouse_input( hwnd, button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE,
732 pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
736 /***********************************************************************
737 * X11DRV_ButtonRelease
739 void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
741 XButtonEvent *event = &xev->xbutton;
742 int buttonNum = event->button - 1;
745 if (buttonNum >= NB_BUTTONS || !button_up_flags[buttonNum]) return;
748 update_mouse_state( hwnd, event->window, event->x, event->y, event->state, &pt );
750 X11DRV_send_mouse_input( hwnd, button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE,
751 pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
755 /***********************************************************************
756 * X11DRV_MotionNotify
758 void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
760 XMotionEvent *event = &xev->xmotion;
763 TRACE("hwnd %p, event->is_hint %d\n", hwnd, event->is_hint);
767 update_mouse_state( hwnd, event->window, event->x, event->y, event->state, &pt );
769 X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
770 pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
774 /***********************************************************************
777 void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
779 XCrossingEvent *event = &xev->xcrossing;
782 TRACE("hwnd %p, event->detail %d\n", hwnd, event->detail);
785 if (event->detail == NotifyVirtual || event->detail == NotifyNonlinearVirtual) return;
787 /* simulate a mouse motion event */
788 update_mouse_state( hwnd, event->window, event->x, event->y, event->state, &pt );
790 X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
791 pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
795 #ifdef HAVE_LIBXXF86DGA2
799 /**********************************************************************
800 * X11DRV_DGAMotionEvent
802 void X11DRV_DGAMotionEvent( HWND hwnd, XEvent *xev )
804 XDGAMotionEvent *event = (XDGAMotionEvent *)xev;
805 update_key_state( event->state );
806 X11DRV_send_mouse_input( DGAhwnd, MOUSEEVENTF_MOVE, event->dx, event->dy,
807 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
810 /**********************************************************************
811 * X11DRV_DGAButtonPressEvent
813 void X11DRV_DGAButtonPressEvent( HWND hwnd, XEvent *xev )
815 XDGAButtonEvent *event = (XDGAButtonEvent *)xev;
816 int buttonNum = event->button - 1;
818 if (buttonNum >= NB_BUTTONS) return;
819 update_key_state( event->state );
820 X11DRV_send_mouse_input( DGAhwnd, button_down_flags[buttonNum], 0, 0,
821 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
824 /**********************************************************************
825 * X11DRV_DGAButtonReleaseEvent
827 void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XEvent *xev )
829 XDGAButtonEvent *event = (XDGAButtonEvent *)xev;
830 int buttonNum = event->button - 1;
832 if (buttonNum >= NB_BUTTONS) return;
833 update_key_state( event->state );
834 X11DRV_send_mouse_input( DGAhwnd, button_up_flags[buttonNum], 0, 0,
835 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
838 #endif /* HAVE_LIBXXF86DGA2 */