mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
sim: correctly handle X11 button state/events
This commit is contained in:
@@ -58,11 +58,13 @@ extern Display *g_display;
|
|||||||
* Name: up_buttonmap
|
* Name: up_buttonmap
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int up_buttonmap(int state)
|
static int up_buttonmap(int state, int button)
|
||||||
{
|
{
|
||||||
int buttons = 0;
|
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)
|
if ((state & Button1Mask) != 0)
|
||||||
{
|
{
|
||||||
@@ -79,6 +81,23 @@ static int up_buttonmap(int state)
|
|||||||
buttons |= 4;
|
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;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +134,7 @@ void up_x11events(void)
|
|||||||
case MotionNotify : /* Enabled by ButtonMotionMask */
|
case MotionNotify : /* Enabled by ButtonMotionMask */
|
||||||
{
|
{
|
||||||
up_buttonevent(event.xmotion.x, event.xmotion.y,
|
up_buttonevent(event.xmotion.x, event.xmotion.y,
|
||||||
up_buttonmap(event.xmotion.state));
|
up_buttonmap(event.xmotion.state, 0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -123,7 +142,8 @@ void up_x11events(void)
|
|||||||
case ButtonRelease: /* Enabled by ButtonReleaseMask */
|
case ButtonRelease: /* Enabled by ButtonReleaseMask */
|
||||||
{
|
{
|
||||||
up_buttonevent(event.xbutton.x, event.xbutton.y,
|
up_buttonevent(event.xbutton.x, event.xbutton.y,
|
||||||
up_buttonmap(event.xbutton.state));
|
up_buttonmap(event.xbutton.state,
|
||||||
|
event.xbutton.button));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user