The mapping from XInput button mask to the standard X event button mask is not 1-1, fixed.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1386 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
jtsiomb 2012-08-09 01:36:31 +00:00
parent 03fea19290
commit b8ea74d51e

View File

@ -13,6 +13,9 @@
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
/* convert the XInput button state mask to the regular X mouse event button mask */
#define BUTTON_MASK(xistate) ((xistate) << 8)
/* import function from freeglut_main.c */
extern int fgPlatformGetModifiers( int state );
@ -187,7 +190,7 @@ void fgHandleExtensionEvents( XEvent* base_ev )
std_ev.xcrossing.detail = evcross->detail;
std_ev.xcrossing.same_screen = evcross->same_screen;
std_ev.xcrossing.focus = evcross->focus;
std_ev.xcrossing.state = *(unsigned int*)evcross->buttons.mask;
std_ev.xcrossing.state = BUTTON_MASK(*(unsigned int*)evcross->buttons.mask);
XPutBackEvent(fgDisplay.pDisplay.Display, &std_ev);
break;
@ -212,7 +215,7 @@ void fgHandleExtensionEvents( XEvent* base_ev )
std_ev.xbutton.y = event->event_y;
std_ev.xbutton.x_root = event->root_x;
std_ev.xbutton.y_root = event->root_y;
std_ev.xbutton.state = *(unsigned int*)event->buttons.mask;
std_ev.xbutton.state = BUTTON_MASK(*(unsigned int*)event->buttons.mask);
std_ev.xbutton.button = event->detail;
XPutBackEvent(fgDisplay.pDisplay.Display, &std_ev);
@ -244,7 +247,7 @@ void fgHandleExtensionEvents( XEvent* base_ev )
std_ev.xmotion.y = event->event_y;
std_ev.xmotion.x_root = event->root_x;
std_ev.xmotion.y_root = event->root_y;
std_ev.xmotion.state = *(unsigned int*)event->buttons.mask;
std_ev.xmotion.state = BUTTON_MASK(*(unsigned int*)event->buttons.mask);
std_ev.xmotion.is_hint = NotifyNormal;
XPutBackEvent(fgDisplay.pDisplay.Display, &std_ev);