summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-08-21 16:38:53 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-09-04 12:59:43 +1000
commit219ae5b628f9ffe2be0876d5911cc04e52bef5f8 (patch)
tree7b1ed0df6ad05ebf9ae4a7f14d4027e9c6117f24
parentbfb219f532f3c78ba905424365ee7c5f7b5f21a2 (diff)
dix: hide the sequenceNumber key repeat hack behind two functions.
Just in case we figure out a better way to do it in the future. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/eventconvert.c36
-rw-r--r--dix/events.c8
2 files changed, 37 insertions, 7 deletions
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 69d2f1fec..21eed40e1 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -55,6 +55,35 @@ static int eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count);
static int eventToDeviceChanged(DeviceChangedEvent *ev, xEvent **dcce);
static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi);
static int eventToRawEvent(RawDeviceEvent *ev, xEvent **xi);
+
+/* Do not use, read comments below */
+BOOL EventIsKeyRepeat(xEvent *event);
+
+/**
+ * Hack to allow detectable autorepeat for core and XI1 events.
+ * The sequence number is unused until we send to the client and can be
+ * misused to store data. More or less, anyway.
+ *
+ * Do not use this. It may change any time without warning, eat your babies
+ * and piss on your cat.
+ */
+static void
+EventSetKeyRepeatFlag(xEvent *event, BOOL on)
+{
+ event->u.u.sequenceNumber = on;
+}
+
+/**
+ * Check if the event was marked as a repeat event before.
+ * NOTE: This is a nasty hack and should NOT be used by anyone else but
+ * TryClientEvents.
+ */
+BOOL
+EventIsKeyRepeat(xEvent *event)
+{
+ return !!event->u.u.sequenceNumber;
+}
+
/**
* Convert the given event to the respective core event.
*
@@ -90,8 +119,7 @@ EventToCore(InternalEvent *event, xEvent *core)
core->u.keyButtonPointer.rootX = e->root_x;
core->u.keyButtonPointer.rootY = e->root_y;
core->u.keyButtonPointer.state = e->corestate;
- if (e->type == ET_KeyPress && e->key_repeat)
- core->u.u.sequenceNumber = 1;
+ EventSetKeyRepeatFlag(core, (e->type == ET_KeyPress && e->key_repeat));
}
break;
case ET_ProximityIn:
@@ -239,8 +267,8 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count)
kbp->root_y = ev->root_y;
kbp->deviceid = ev->deviceid;
kbp->state = ev->corestate;
- if (ev->type == ET_KeyPress && ev->key_repeat)
- kbp->sequenceNumber = 1;
+ EventSetKeyRepeatFlag((xEvent*)kbp,
+ (ev->type == ET_KeyPress && ev->key_repeat));
if (num_events > 1)
kbp->deviceid |= MORE_EVENTS;
diff --git a/dix/events.c b/dix/events.c
index 62eb6c225..90a2675c4 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -226,6 +226,9 @@ static Bool CheckPassiveGrabsOnWindow(WindowPtr pWin,
DeviceEvent *event,
BOOL checkCore);
+/** Key repeat hack. Do not use but in TryClientEvents */
+extern BOOL EventIsKeyRepeat(xEvent *event);
+
/**
* Main input device struct.
* inputInfo.pointer
@@ -1948,8 +1951,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
return 1;
} else if (type == KeyPress)
{
- /* sequenceNumber == 1 if autorepeat is set */
- if (pEvents->u.u.sequenceNumber)
+ if (EventIsKeyRepeat(pEvents))
{
if (!_XkbWantsDetectableAutoRepeat(client))
{
@@ -1970,7 +1972,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
} else if (type == DeviceKeyPress)
{
- if (((deviceKeyButtonPointer *)pEvents)->sequenceNumber)
+ if (EventIsKeyRepeat(pEvents))
{
if (!_XkbWantsDetectableAutoRepeat(client))
{