[PATCH 2/4] input: Provide Queue{Button|Keyboard|Proximity}Event helpers
Peter Hutterer
peter.hutterer at who-t.net
Thu Apr 14 19:47:23 PDT 2011
Don't require every caller to use GPE + mieqEnqueue, provide matching
Queue...Event functions instead.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
dix/getevents.c | 80 ++++++++++++++++++++++++++++++++++++++++
hw/dmx/input/dmxevents.c | 54 ++++++++-------------------
hw/kdrive/src/kinput.c | 18 ++------
hw/xfree86/common/xf86Events.c | 6 +--
hw/xfree86/common/xf86Xinput.c | 36 ++++-------------
hw/xnest/Events.c | 32 +++++-----------
hw/xquartz/darwinEvents.c | 20 +++------
hw/xwin/winkeybd.c | 6 +--
hw/xwin/winmouse.c | 15 ++-----
include/input.h | 21 ++++++++++
10 files changed, 155 insertions(+), 133 deletions(-)
diff --git a/dix/getevents.c b/dix/getevents.c
index 0fa8046..5953bc1 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -47,6 +47,7 @@
#include "eventstr.h"
#include "eventconvert.h"
#include "inpututils.h"
+#include "mi.h"
#include <X11/extensions/XKBproto.h>
#include "xkbsrv.h"
@@ -925,6 +926,39 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
}
}
+static void
+queueEventList(DeviceIntPtr device, EventList *events, int nevents)
+{
+ int i;
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(device, (InternalEvent*)((events + i)->event));
+}
+
+/**
+ * Generate internal events representing this keyboard event and enqueue
+ * them on the event queue.
+ *
+ * FIXME: don't require the event list to be passed in.
+ * FIXME: flags for relative/abs motion?
+ *
+ * @param events Event list used as temporary storage
+ * @param device The device to generate the event for
+ * @param type Event type, one of KeyPress or KeyRelease
+ * @param keycode Key code of the pressed/released key
+ * @param mask Valuator mask for valuators present for this event.
+ *
+ */
+void
+QueueKeyboardEvents(EventList *events, DeviceIntPtr device, int type,
+ int keycode, const ValuatorMask *mask)
+{
+ int nevents;
+
+ nevents = GetKeyboardEvents(events, device, type, keycode, mask);
+ queueEventList(device, events, nevents);
+}
+
/**
* Returns a set of InternalEvents for KeyPress/KeyRelease, optionally
* also with valuator events.
@@ -1072,6 +1106,30 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
}
/**
+ * Generate internal events representing this pointer event and enqueue them
+ * on the event queue.
+ *
+ * FIXME: don't require the event list to be passed in.
+ *
+ * @param events Event list used as temporary storage
+ * @param device The device to generate the event for
+ * @param type Event type, one of ButtonPress, ButtonRelease, MotionNotify
+ * @param buttons Button number of the buttons modified. Must be 0 for
+ * MotionNotify
+ * @param flags Event modification flags
+ * @param mask Valuator mask for valuators present for this event.
+ */
+void
+QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
+ int buttons, int flags, const ValuatorMask *mask)
+{
+ int nevents;
+
+ nevents = GetPointerEvents(events, device, type, buttons, flags, mask);
+ queueEventList(device, events, nevents);
+}
+
+/**
* Generate a series of InternalEvents (filled into the EventList)
* representing pointer motion, or button presses.
*
@@ -1215,6 +1273,28 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
return num_events;
}
+/**
+ * Generate internal events representing this proximity event and enqueue
+ * them on the event queue.
+ *
+ * FIXME: don't require the event list to be passed in.
+ *
+ * @param events Event list used as temporary storage
+ * @param device The device to generate the event for
+ * @param type Event type, one of ProximityIn or ProximityOut
+ * @param keycode Key code of the pressed/released key
+ * @param mask Valuator mask for valuators present for this event.
+ *
+ */
+void
+QueueProximityEvents(EventList *events, DeviceIntPtr device, int type,
+ const ValuatorMask *mask)
+{
+ int nevents;
+
+ nevents = GetProximityEvents(events, device, type, mask);
+ queueEventList(device, events, nevents);
+}
/**
* Generate ProximityIn/ProximityOut InternalEvents, accompanied by
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 15d80f5..3f9035c 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -176,7 +176,7 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
{
GETDMXLOCALFROMPDEV;
DeviceIntPtr p = dmxLocal->pDevice;
- int i, nevents, valuators[3];
+ int valuators[3];
EventListPtr events;
int detail = 0; /* XXX should this be mask of pressed buttons? */
ValuatorMask mask;
@@ -185,10 +185,8 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
valuator_mask_set_range(&mask, 0, 2, valuators);
GetEventList(&events);
- nevents = GetPointerEvents(events, p, MotionNotify, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(events, p, MotionNotify, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
return;
}
@@ -291,10 +289,8 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
deviceValuator *xv = (deviceValuator *)xev+1;
int thisX = 0;
int thisY = 0;
- int i;
int count;
EventListPtr events;
- int nevents;
ValuatorMask mask;
memset(xE, 0, sizeof(xE));
@@ -348,6 +344,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
}
count = 2;
} else {
+ int i;
for (i = 0, count = 0; i < axesCount; i += 6) {
xev->time = GetTimeInMillis();
xev->type = DeviceMotionNotify;
@@ -376,10 +373,8 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
dmxSigioBlock();
valuator_mask_set_range(&mask, firstAxis, axesCount, v);
GetEventList(&events);
- nevents = GetPointerEvents(events, pDevice, MotionNotify, 0,
- POINTER_ABSOLUTE, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(events, pDevice, MotionNotify, 0,
+ POINTER_ABSOLUTE, &mask);
if (block)
dmxSigioUnblock();
@@ -395,7 +390,6 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
DeviceIntPtr pDevice = dmxLocal->pDevice;
int valuators[MAX_VALUATORS];
EventListPtr events;
- int nevents, i;
ValuatorMask mask;
if (!e)
@@ -453,11 +447,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
if (block)
dmxSigioBlock();
GetEventList(&events);
- nevents = GetKeyboardEvents(events, pDevice, event,
- ke->keycode, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+ QueueKeyboardEvents(events, pDevice, event, ke->keycode, &mask);
if (block)
dmxSigioUnblock();
break;
@@ -468,11 +458,8 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
if (block)
dmxSigioBlock();
GetEventList(&events);
- nevents = GetPointerEvents(events, pDevice, event, ke->keycode,
- POINTER_ABSOLUTE, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+ QueuePointerEvents(events, pDevice, event, ke->keycode,
+ POINTER_ABSOLUTE, &mask);
if (block)
dmxSigioUnblock();
break;
@@ -483,10 +470,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
if (block)
dmxSigioBlock();
GetEventList(&events);
- nevents = GetProximityEvents(events, pDevice, event, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+ QueueProximityEvents(events, pDevice, event, &mask);
if (block)
dmxSigioUnblock();
break;
@@ -667,7 +651,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
GETDMXINPUTFROMPDEV;
xEvent xE;
DeviceIntPtr p = dmxLocal->pDevice;
- int i, nevents, valuators[3];
+ int valuators[3];
EventListPtr events;
ValuatorMask mask;
@@ -685,9 +669,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
GetEventList(&events);
/*ErrorF("KEY %d sym %d\n", detail, (int) keySym);*/
- nevents = GetKeyboardEvents(events, p, type, detail, NULL);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueueKeyboardEvents(events, p, type, detail, NULL);
return;
case ButtonPress:
@@ -695,10 +677,8 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
detail = dmxGetButtonMapping(dmxLocal, detail);
valuator_mask_zero(&mask);
GetEventList(&events);
- nevents = GetPointerEvents(events, p, type, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(events, p, type, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
return;
case MotionNotify:
@@ -707,10 +687,8 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
valuators[1] = e->xmotion.y;
valuators[2] = e->xmotion.state; /* FIXME: WTF?? */
valuator_mask_set_range(&mask, 0, 3, valuators);
- nevents = GetPointerEvents(events, p, type, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+ QueuePointerEvents(events, p, type, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
return;
case EnterNotify:
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index f21475f..521542c 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1793,7 +1793,7 @@ void
KdReleaseAllKeys (void)
{
#if 0
- int key, nEvents, i;
+ int key;
KdKeyboardInfo *ki;
KdBlockSigio ();
@@ -1804,9 +1804,7 @@ KdReleaseAllKeys (void)
if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) {
KdHandleKeyboardEvent(ki, KeyRelease, key);
GetEventList(&kdEvents);
- nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key, NULL);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent (ki->dixdev, (kdEvents + i)->event);
+ QueueGetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key, NULL);
}
}
}
@@ -1842,7 +1840,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
unsigned char key_code;
KeyClassPtr keyc = NULL;
KeybdCtrl *ctrl = NULL;
- int type, nEvents, i;
+ int type;
if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
return;
@@ -1863,10 +1861,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
type = KeyPress;
GetEventList(&kdEvents);
-
- nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code, NULL);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent(ki->dixdev, (InternalEvent *)((kdEvents + i)->event));
+ QueueKeyboardEvents(kdEvents, ki->dixdev, type, key_code, NULL);
}
else {
ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
@@ -1965,7 +1960,6 @@ void
_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
int b, int absrel, Bool force)
{
- int nEvents = 0, i = 0;
int valuators[3] = { x, y, z };
ValuatorMask mask;
@@ -1976,9 +1970,7 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
valuator_mask_set_range(&mask, 0, 3, valuators);
GetEventList(&kdEvents);
- nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, &mask);
- for (i = 0; i < nEvents; i++)
- KdQueueEvent(pi->dixdev, (InternalEvent *)((kdEvents + i)->event));
+ QueuePointerEvents(kdEvents, pi->dixdev, type, b, absrel, &mask);
}
void
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 3006ad1..6402d72 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -376,7 +376,7 @@ static void
xf86ReleaseKeys(DeviceIntPtr pDev)
{
KeyClassPtr keyc;
- int i, j, nevents, sigstate;
+ int i, sigstate;
if (!pDev || !pDev->key)
return;
@@ -399,9 +399,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
i++) {
if (key_is_down(pDev, i, KEY_POSTED)) {
sigstate = xf86BlockSIGIO ();
- nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i, NULL);
- for (j = 0; j < nevents; j++)
- mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
+ QueueKeyboardEvents(xf86Events, pDev, KeyRelease, i, NULL);
xf86UnblockSIGIO(sigstate);
}
}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ef4542c..a6c261c 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1050,11 +1050,7 @@ xf86PostMotionEventM(DeviceIntPtr device,
}
#endif
- nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
-
- for (i = 0; i < nevents; i++) {
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
- }
+ QueuePointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
}
void
@@ -1099,13 +1095,8 @@ xf86PostProximityEventM(DeviceIntPtr device,
int is_in,
const ValuatorMask *mask)
{
- int i, nevents;
-
- nevents = GetProximityEvents(xf86Events, device,
- is_in ? ProximityIn : ProximityOut, mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-
+ QueueProximityEvents(xf86Events, device,
+ is_in ? ProximityIn : ProximityOut, mask);
}
void
@@ -1177,13 +1168,9 @@ xf86PostButtonEventM(DeviceIntPtr device,
}
#endif
- nevents = GetPointerEvents(xf86Events, device,
- is_down ? ButtonPress : ButtonRelease, button,
- flags, mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-
+ QueuePointerEvents(xf86Events, device,
+ is_down ? ButtonPress : ButtonRelease, button,
+ flags, mask);
}
void
@@ -1235,8 +1222,6 @@ xf86PostKeyEventM(DeviceIntPtr device,
int is_absolute,
const ValuatorMask *mask)
{
- int i = 0, nevents = 0;
-
#if XFreeXDGA
DeviceIntPtr pointer;
@@ -1250,12 +1235,9 @@ xf86PostKeyEventM(DeviceIntPtr device,
}
#endif
- nevents = GetKeyboardEvents(xf86Events, device,
- is_down ? KeyPress : KeyRelease,
- key_code, mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
+ QueueKeyboardEvents(xf86Events, device,
+ is_down ? KeyPress : KeyRelease,
+ key_code, mask);
}
void
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 5c80086..574e4e4 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -104,20 +104,16 @@ xnestCollectExposures(void)
void
xnestQueueKeyEvent(int type, unsigned int keycode)
{
- int i, n;
-
GetEventList(&xnestEvents);
lastEventTime = GetTimeInMillis();
- n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode, NULL);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestKeyboardDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueueKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode, NULL);
}
void
xnestCollectEvents(void)
{
XEvent X;
- int i, n, valuators[2];
+ int valuators[2];
ValuatorMask mask;
ScreenPtr pScreen;
GetEventList(&xnestEvents);
@@ -138,20 +134,16 @@ xnestCollectEvents(void)
valuator_mask_set_range(&mask, 0, 0, NULL);
xnestUpdateModifierState(X.xkey.state);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
- X.xbutton.button, POINTER_RELATIVE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
+ X.xbutton.button, POINTER_RELATIVE, &mask);
break;
case ButtonRelease:
valuator_mask_set_range(&mask, 0, 0, NULL);
xnestUpdateModifierState(X.xkey.state);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
- X.xbutton.button, POINTER_RELATIVE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
+ X.xbutton.button, POINTER_RELATIVE, &mask);
break;
case MotionNotify:
@@ -159,10 +151,8 @@ xnestCollectEvents(void)
valuators[1] = X.xmotion.y;
valuator_mask_set_range(&mask, 0, 2, valuators);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
- 0, POINTER_ABSOLUTE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, &mask);
break;
case FocusIn:
@@ -193,10 +183,8 @@ xnestCollectEvents(void)
valuators[1] = X.xcrossing.y;
valuator_mask_set_range(&mask, 0, 2, valuators);
lastEventTime = GetTimeInMillis();
- n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
- 0, POINTER_ABSOLUTE, &mask);
- for (i = 0; i < n; i++)
- mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ QueuePointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, &mask);
xnestDirectInstallColormaps(pScreen);
}
}
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 451129e..f20e37b 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -413,7 +413,6 @@ static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
float pressure, float tilt_x, float tilt_y) {
static int darwinFakeMouseButtonDown = 0;
- int i, num_events;
ScreenPtr screen;
int valuators[5];
@@ -466,15 +465,13 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa
darwinEvents_lock(); {
ValuatorMask mask;
valuator_mask_set_range(&mask, 0, (pDev == darwinTabletCurrent) ? 5 : 2, valuators);
- num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button,
- POINTER_ABSOLUTE, &mask);
- for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
- if(num_events > 0) DarwinPokeEQ();
+ QueuePointerEvents(darwinEvents, pDev, ev_type, ev_button,
+ POINTER_ABSOLUTE, &mask);
+ DarwinPokeEQ();
} darwinEvents_unlock();
}
void DarwinSendKeyboardEvents(int ev_type, int keycode) {
- int i, num_events;
if(!darwinEvents) {
DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
@@ -482,14 +479,12 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
}
darwinEvents_lock(); {
- num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
- for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard, (InternalEvent*)darwinEvents[i].event);
- if(num_events > 0) DarwinPokeEQ();
+ QueueKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
+ DarwinPokeEQ();
} darwinEvents_unlock();
}
void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
- int i, num_events;
ScreenPtr screen;
DeviceIntPtr pDev = darwinTabletCurrent;
int valuators[5];
@@ -511,9 +506,8 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
darwinEvents_lock(); {
ValuatorMask mask;
valuator_mask_set_range(&mask, 0, 5, valuators);
- num_events = GetProximityEvents(darwinEvents, pDev, ev_type, &mask);
- for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
- if(num_events > 0) DarwinPokeEQ();
+ QueueProximityEvents(darwinEvents, pDev, ev_type, &mask);
+ DarwinPokeEQ();
} darwinEvents_unlock();
}
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 912e2de..cf0dea2 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -473,7 +473,6 @@ void
winSendKeyEvent (DWORD dwKey, Bool fDown)
{
EventListPtr events;
- int i, nevents;
/*
* When alt-tabing between screens we can get phantom key up messages
@@ -485,10 +484,7 @@ winSendKeyEvent (DWORD dwKey, Bool fDown)
g_winKeyState[dwKey] = fDown;
GetEventList(&events);
- nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinKeyboard, (InternalEvent*)events[i].event);
+ QueueKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
dwKey, fDown, nevents);
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 080e096..0e36687 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -235,7 +235,6 @@ void
winMouseButtonsSendEvent (int iEventType, int iButton)
{
EventListPtr events;
- int i, nevents;
ValuatorMask mask;
if (g_winMouseButtonMap)
@@ -243,11 +242,8 @@ winMouseButtonsSendEvent (int iEventType, int iButton)
valuator_mask_zero(&mask);
GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
- POINTER_RELATIVE, &mask);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
+ QueuePointerEvents(events, g_pwinPointer, iEventType, iButton,
+ POINTER_RELATIVE, &mask);
#if CYGDEBUG
ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
@@ -367,7 +363,6 @@ winMouseButtonsHandle (ScreenPtr pScreen,
*/
void winEnqueueMotion(int x, int y)
{
- int i, nevents;
int valuators[2];
ValuatorMask mask;
EventListPtr events;
@@ -378,9 +373,7 @@ void winEnqueueMotion(int x, int y)
valuator_mask_set_range(&mask, 0, 2, valuators);
GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+ QueuePointerEvents(events, g_pwinPointer, MotionNotify, 0,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
}
diff --git a/include/input.h b/include/input.h
index d0a86aa..ac4c7b9 100644
--- a/include/input.h
+++ b/include/input.h
@@ -455,6 +455,14 @@ extern _X_EXPORT int GetPointerEvents(
int flags,
const ValuatorMask *mask);
+extern _X_EXPORT void QueuePointerEvents(
+ EventListPtr events,
+ DeviceIntPtr pDev,
+ int type,
+ int buttons,
+ int flags,
+ const ValuatorMask *mask);
+
extern _X_EXPORT int GetKeyboardEvents(
EventListPtr events,
DeviceIntPtr pDev,
@@ -462,12 +470,25 @@ extern _X_EXPORT int GetKeyboardEvents(
int key_code,
const ValuatorMask *mask);
+extern _X_EXPORT void QueueKeyboardEvents(
+ EventListPtr events,
+ DeviceIntPtr pDev,
+ int type,
+ int key_code,
+ const ValuatorMask *mask);
+
extern int GetProximityEvents(
EventListPtr events,
DeviceIntPtr pDev,
int type,
const ValuatorMask *mask);
+extern void QueueProximityEvents(
+ EventListPtr events,
+ DeviceIntPtr pDev,
+ int type,
+ const ValuatorMask *mask);
+
extern void PostSyntheticMotion(
DeviceIntPtr pDev,
int x,
--
1.7.4.2
More information about the xorg-devel
mailing list