Module: wine Branch: master Commit: 338fe8b9acf5085172662e9cf3109370dad77a4a URL: http://source.winehq.org/git/wine.git/?a=commit;h=338fe8b9acf5085172662e9cf3...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Apr 13 18:56:37 2011 +0200
winex11: Add handlers for the XInput2 raw mouse events.
---
dlls/winex11.drv/event.c | 2 +- dlls/winex11.drv/mouse.c | 115 +++++++++++++++++++++++++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 1 + 3 files changed, 117 insertions(+), 1 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index a05e906..d3ed4b0 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -140,7 +140,7 @@ static x11drv_event_handler handlers[MAX_EVENT_HANDLERS] = NULL, /* 32 ColormapNotify */ X11DRV_ClientMessage, /* 33 ClientMessage */ X11DRV_MappingNotify, /* 34 MappingNotify */ - NULL /* 35 GenericEvent */ + X11DRV_GenericEvent /* 35 GenericEvent */ };
static const char * event_names[MAX_EVENT_HANDLERS] = diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 1716916..e3774dc 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -25,6 +25,9 @@ #include <X11/Xlib.h> #include <X11/cursorfont.h> #include <stdarg.h> +#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H +#include <X11/extensions/XInput2.h> +#endif
#ifdef SONAME_LIBXCURSOR # include <X11/Xcursor/Xcursor.h> @@ -1089,3 +1092,115 @@ void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
send_mouse_input( hwnd, event->window, event->state, &input ); } + +#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H + +/*********************************************************************** + * X11DRV_RawButtonPress + */ +static void X11DRV_RawButtonPress( XIRawEvent *event ) +{ + int button = event->detail - 1; + INPUT input; + + if (button >= NB_BUTTONS) return; + + TRACE( "button %u\n", button ); + + input.type = INPUT_MOUSE; + input.u.mi.dx = 0; + input.u.mi.dy = 0; + input.u.mi.mouseData = button_down_data[button]; + input.u.mi.dwFlags = button_down_flags[button]; + input.u.mi.time = EVENT_x11_time_to_win32_time( event->time ); + input.u.mi.dwExtraInfo = 0; + + update_user_time( event->time ); + input.type = INPUT_MOUSE; + __wine_send_input( 0, &input ); +} + + +/*********************************************************************** + * X11DRV_RawButtonRelease + */ +static void X11DRV_RawButtonRelease( XIRawEvent *event ) +{ + int button = event->detail - 1; + INPUT input; + + if (button >= NB_BUTTONS) return; + + TRACE( "button %u\n", button ); + + input.u.mi.dx = 0; + input.u.mi.dy = 0; + input.u.mi.mouseData = button_up_data[button]; + input.u.mi.dwFlags = button_up_flags[button]; + input.u.mi.time = EVENT_x11_time_to_win32_time( event->time ); + input.u.mi.dwExtraInfo = 0; + + input.type = INPUT_MOUSE; + __wine_send_input( 0, &input ); +} + + +/*********************************************************************** + * X11DRV_RawMotion + */ +static void X11DRV_RawMotion( XIRawEvent *event ) +{ + const double *values = event->valuators.values; + INPUT input; + + if (!event->valuators.mask_len) return; + + input.u.mi.dx = 0; + input.u.mi.dy = 0; + input.u.mi.mouseData = 0; + input.u.mi.dwFlags = MOUSEEVENTF_MOVE; + input.u.mi.time = EVENT_x11_time_to_win32_time( event->time ); + input.u.mi.dwExtraInfo = 0; + + if (XIMaskIsSet( event->valuators.mask, 0 )) input.u.mi.dx = *values++; + if (XIMaskIsSet( event->valuators.mask, 1 )) input.u.mi.dy = *values++; + + TRACE( "pos %d,%d\n", input.u.mi.dx, input.u.mi.dy ); + + input.type = INPUT_MOUSE; + __wine_send_input( 0, &input ); +} + +#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */ + + +/*********************************************************************** + * X11DRV_GenericEvent + */ +void X11DRV_GenericEvent( HWND hwnd, XEvent *xev ) +{ +#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H + XGenericEventCookie *event = &xev->xcookie; + + if (!event->data) return; + + switch (event->evtype) + { + case XI_RawButtonPress: + X11DRV_RawButtonPress( event->data ); + break; + + case XI_RawButtonRelease: + X11DRV_RawButtonRelease( event->data ); + break; + + case XI_RawMotion: + X11DRV_RawMotion( event->data ); + break; + + default: + TRACE( "Unhandled event %#x\n", event->evtype ); + break; + } +#endif +} diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 5f6c5cf..ae91fc9 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -728,6 +728,7 @@ extern void X11DRV_DestroyNotify( HWND hwnd, XEvent *event ); extern void X11DRV_SelectionRequest( HWND hWnd, XEvent *event ); extern void X11DRV_SelectionClear( HWND hWnd, XEvent *event ); extern void X11DRV_MappingNotify( HWND hWnd, XEvent *event ); +extern void X11DRV_GenericEvent( HWND hwnd, XEvent *event );
extern Bool (*pXGetEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event ); extern void (*pXFreeEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event );