pass keyboard modifier key states in button press event

This commit is contained in:
Josh Holtrop 2017-10-14 12:38:39 -04:00
parent 7648bee12e
commit 5239f128cc
2 changed files with 22 additions and 12 deletions

View File

@ -40,6 +40,25 @@ static unsigned int GetXState()
}
#endif
static uint32_t XStateToJtkKeyMods(unsigned int x_state)
{
uint32_t mods = 0u;
/* OR in the modifier states */
if (x_state & ShiftMask)
{
mods |= JTK_KEY_MODS_SHIFT;
}
if (x_state & LockMask)
{
mods |= JTK_KEY_MODS_LOCK;
}
if (x_state & ControlMask)
{
mods |= JTK_KEY_MODS_CTRL;
}
return mods;
}
static uint32_t XKeyToJtkKey(unsigned int x_keycode, unsigned int x_state)
{
XKeyEvent x_key_event;
@ -177,18 +196,7 @@ static uint32_t XKeyToJtkKey(unsigned int x_keycode, unsigned int x_state)
}
/* OR in the modifier states */
if (x_state & ShiftMask)
{
key |= JTK_KEY_MODS_SHIFT;
}
if (x_state & LockMask)
{
key |= JTK_KEY_MODS_LOCK;
}
if (x_state & ControlMask)
{
key |= JTK_KEY_MODS_CTRL;
}
key |= XStateToJtkKeyMods(x_state);
return key;
}
@ -291,6 +299,7 @@ static Bool MatchButtonPress(Display * display, XEvent * event, XPointer arg)
static bool ProcessXButtonPressEvent(XEvent * x_event, Jtk_Event * event)
{
event->type = JTK_EVENT_BUTTON_PRESS;
event->button.mods = XStateToJtkKeyMods(x_event->xbutton.state);
event->button.button = x_event->xbutton.button;
/* If this is a mouse wheel scroll event, remove any following scroll
* events. */

View File

@ -24,6 +24,7 @@ typedef struct
typedef struct
{
uint32_t mods;
uint8_t button;
} Jtk_ButtonEvent;