sim: correctly handle X11 button state/events
This commit is contained in:
parent
f0e8d10d1a
commit
010ac2bcf4
1 changed files with 24 additions and 4 deletions
|
|
@ -58,11 +58,13 @@ extern Display *g_display;
|
|||
* Name: up_buttonmap
|
||||
****************************************************************************/
|
||||
|
||||
static int up_buttonmap(int state)
|
||||
static int up_buttonmap(int state, int button)
|
||||
{
|
||||
int buttons = 0;
|
||||
|
||||
/* Remove any X11 dependencies. Just maps ButtonNMask to bit N. */
|
||||
/* "state" is a bitmask representing the state prior to the event, so
|
||||
* translate that first to our button bitmap
|
||||
*/
|
||||
|
||||
if ((state & Button1Mask) != 0)
|
||||
{
|
||||
|
|
@ -79,6 +81,23 @@ static int up_buttonmap(int state)
|
|||
buttons |= 4;
|
||||
}
|
||||
|
||||
/* button represents the button which changed state, so change the
|
||||
* corresponding bit now
|
||||
*/
|
||||
|
||||
switch(button)
|
||||
{
|
||||
case Button1:
|
||||
buttons ^= 1;
|
||||
break;
|
||||
case Button2:
|
||||
buttons ^= 2;
|
||||
break;
|
||||
case Button3:
|
||||
buttons ^= 4;
|
||||
break;
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +134,7 @@ void up_x11events(void)
|
|||
case MotionNotify : /* Enabled by ButtonMotionMask */
|
||||
{
|
||||
up_buttonevent(event.xmotion.x, event.xmotion.y,
|
||||
up_buttonmap(event.xmotion.state));
|
||||
up_buttonmap(event.xmotion.state, 0));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -123,7 +142,8 @@ void up_x11events(void)
|
|||
case ButtonRelease: /* Enabled by ButtonReleaseMask */
|
||||
{
|
||||
up_buttonevent(event.xbutton.x, event.xbutton.y,
|
||||
up_buttonmap(event.xbutton.state));
|
||||
up_buttonmap(event.xbutton.state,
|
||||
event.xbutton.button));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue