aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/events.c12
-rw-r--r--xorg-server/dix/getevents.c49
2 files changed, 43 insertions, 18 deletions
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index 13c91f68a..c9a73dc90 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -3937,13 +3937,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
void
FixKeyState (DeviceEvent *event, DeviceIntPtr keybd)
{
- int key, bit;
- BYTE *kptr;
- KeyClassPtr keyc = keybd->key;
-
- key = event->detail.key;
- kptr = &keyc->down[key >> 3];
- bit = 1 << (key & 7);
+ int key = event->detail.key;
if (event->type == ET_KeyPress) {
DebugF("FixKeyState: Key %d %s\n",key,
@@ -3951,9 +3945,9 @@ FixKeyState (DeviceEvent *event, DeviceIntPtr keybd)
}
if (event->type == ET_KeyPress)
- *kptr |= bit;
+ set_key_down(keybd, key, KEY_PROCESSED);
else if (event->type == ET_KeyRelease)
- *kptr &= ~bit;
+ set_key_up(keybd, key, KEY_PROCESSED);
else
FatalError("Impossible keyboard event");
}
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index ea19e0cac..3885cd771 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -91,21 +91,52 @@ 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)
- pDev->key->down[key_code >> 3] |= (1 << (key_code & 7));
+ SetBit(pDev->key->down, key_code);
else
- pDev->key->postdown[key_code >> 3] |= (1 << (key_code & 7));
+ SetBit(pDev->key->postdown, key_code);
}
void
set_key_up(DeviceIntPtr pDev, int key_code, int type)
{
if (type == KEY_PROCESSED)
- pDev->key->down[key_code >> 3] &= ~(1 << (key_code & 7));
+ ClearBit(pDev->key->down, key_code);
else
- pDev->key->postdown[key_code >> 3] &= ~(1 << (key_code & 7));
+ ClearBit(pDev->key->postdown, key_code);
}
Bool
@@ -114,9 +145,9 @@ key_is_down(DeviceIntPtr pDev, int key_code, int type)
int ret = 0;
if (type & KEY_PROCESSED)
- ret |= !!(pDev->key->down[key_code >> 3] & (1 << (key_code & 7)));
- else if (type & KEY_POSTED)
- ret |= !!(pDev->key->postdown[key_code >> 3] & (1 << (key_code & 7)));
+ ret |= !!BitIsOn(pDev->key->down, key_code);
+ if (type & KEY_POSTED)
+ ret |= !!BitIsOn(pDev->key->postdown, key_code);
return ret;
}
@@ -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;
}