mirror of
https://github.com/X11Libre/xserver.git
synced 2026-10-21 01:13:38 +00:00
dix: add aux. functions for button_is_down, set_button_down, set_button_up.
Same as the matching key functions. Buttons, like keys, can have two states for down/up - one posted, one processed. Posted is set during event generation (usually in the signal handler). Processed is set during event processing when the event queue is emptied and events are being delivered to the client. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
32473d6bf3
commit
a1afe17255
3 changed files with 46 additions and 12 deletions
|
|
@ -90,6 +90,37 @@ GetMotionHistorySize(void)
|
|||
return MOTION_HISTORY_SIZE;
|
||||
}
|
||||
|
||||
void
|
||||
set_button_down(DeviceIntPtr pDev, int button, int type)
|
||||
{
|
||||
if (type == BUTTON_PROCESSED)
|
||||
SetBit(pDev->button->down, button);
|
||||
else
|
||||
SetBit(pDev->button->postdown, button);
|
||||
}
|
||||
|
||||
void
|
||||
set_button_up(DeviceIntPtr pDev, int button, int type)
|
||||
{
|
||||
if (type == BUTTON_PROCESSED)
|
||||
ClearBit(pDev->button->down, button);
|
||||
else
|
||||
ClearBit(pDev->button->postdown, button);
|
||||
}
|
||||
|
||||
Bool
|
||||
button_is_down(DeviceIntPtr pDev, int button, int type)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (type & BUTTON_PROCESSED)
|
||||
ret |= !!BitIsOn(pDev->button->down, button);
|
||||
if (type & BUTTON_POSTED)
|
||||
ret |= !!BitIsOn(pDev->button->postdown, button);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
set_key_down(DeviceIntPtr pDev, int key_code, int type)
|
||||
{
|
||||
|
|
@ -1123,11 +1154,11 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
|
|||
else {
|
||||
if (type == ButtonPress) {
|
||||
event->type = ET_ButtonPress;
|
||||
pDev->button->postdown[buttons >> 3] |= (1 << (buttons & 7));
|
||||
set_button_down(pDev, buttons, BUTTON_POSTED);
|
||||
}
|
||||
else if (type == ButtonRelease) {
|
||||
event->type = ET_ButtonRelease;
|
||||
pDev->button->postdown[buttons >> 3] &= ~(1 << (buttons & 7));
|
||||
set_button_up(pDev, buttons, BUTTON_POSTED);
|
||||
}
|
||||
event->detail.button = buttons;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue