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
|
@ -747,7 +747,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
|
|||
KeyClassPtr k = NULL;
|
||||
ButtonClassPtr b = NULL;
|
||||
ValuatorClassPtr v = NULL;
|
||||
BYTE *kptr = NULL;
|
||||
|
||||
/* This event is always the first we get, before the actual events with
|
||||
* the data. However, the way how the DDX is set up, "device" will
|
||||
|
@ -835,10 +834,10 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
|
|||
if (!b)
|
||||
return DONT_PROCESS;
|
||||
|
||||
kptr = &b->down[key >> 3];
|
||||
if ((*kptr & bit) != 0)
|
||||
if (button_is_down(device, key, BUTTON_PROCESSED))
|
||||
return DONT_PROCESS;
|
||||
*kptr |= bit;
|
||||
|
||||
set_button_down(device, key, BUTTON_PROCESSED);
|
||||
if (device->valuator)
|
||||
device->valuator->motionHintWindow = NullWindow;
|
||||
if (!b->map[key])
|
||||
|
@ -858,8 +857,7 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
|
|||
if (!b)
|
||||
return DONT_PROCESS;
|
||||
|
||||
kptr = &b->down[key>>3];
|
||||
if (!(*kptr & bit))
|
||||
if (!button_is_down(device, key, BUTTON_PROCESSED))
|
||||
return DONT_PROCESS;
|
||||
if (IsMaster(device)) {
|
||||
DeviceIntPtr sd;
|
||||
|
@ -874,11 +872,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
|
|||
continue;
|
||||
if (!sd->button)
|
||||
continue;
|
||||
if ((sd->button->down[key>>3] & bit) != 0)
|
||||
if (button_is_down(sd, key, BUTTON_PROCESSED))
|
||||
return DONT_PROCESS;
|
||||
}
|
||||
}
|
||||
*kptr &= ~bit;
|
||||
set_button_up(device, key, BUTTON_PROCESSED);
|
||||
if (device->valuator)
|
||||
device->valuator->motionHintWindow = NullWindow;
|
||||
if (!b->map[key])
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -228,14 +228,19 @@ typedef struct _InputAttributes {
|
|||
#define ATTR_TOUCHPAD (1<<4)
|
||||
#define ATTR_TOUCHSCREEN (1<<5)
|
||||
|
||||
/* Key has been run through all input processing and events sent to clients. */
|
||||
/* Key/Button has been run through all input processing and events sent to clients. */
|
||||
#define KEY_PROCESSED 1
|
||||
/* Key has not been fully processed, no events have been sent. */
|
||||
#define BUTTON_PROCESSED 1
|
||||
/* Key/Button has not been fully processed, no events have been sent. */
|
||||
#define KEY_POSTED 2
|
||||
#define BUTTON_POSTED 2
|
||||
|
||||
extern void set_key_down(DeviceIntPtr pDev, int key_code, int type);
|
||||
extern void set_key_up(DeviceIntPtr pDev, int key_code, int type);
|
||||
extern int key_is_down(DeviceIntPtr pDev, int key_code, int type);
|
||||
extern void set_button_down(DeviceIntPtr pDev, int button, int type);
|
||||
extern void set_button_up(DeviceIntPtr pDev, int button, int type);
|
||||
extern int button_is_down(DeviceIntPtr pDev, int button, int type);
|
||||
|
||||
extern void InitCoreDevices(void);
|
||||
extern void InitXTestDevices(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user