summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xi/exevents.c14
-rw-r--r--dix/getevents.c35
-rw-r--r--include/input.h9
3 files changed, 46 insertions, 12 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index df13190a8..e990aeb7e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -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])
diff --git a/dix/getevents.c b/dix/getevents.c
index 1d505e536..a9b6e82c3 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -91,6 +91,37 @@ GetMotionHistorySize(void)
}
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)
{
if (type == KEY_PROCESSED)
@@ -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;
}
diff --git a/include/input.h b/include/input.h
index 0a08ea425..55b1537f6 100644
--- a/include/input.h
+++ b/include/input.h
@@ -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);