From e7150db5350bc2113ff4126019b489847a4dc217 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 11 Apr 2011 15:48:15 +1000 Subject: input: Provide Queue{Button|Keyboard|Proximity}Event helpers Don't require every caller to use GPE + mieqEnqueue, provide matching Queue...Event functions instead. Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston --- hw/dmx/input/dmxevents.c | 54 +++++++++++++----------------------------- hw/kdrive/src/kinput.c | 18 ++++---------- hw/xfree86/common/xf86Events.c | 6 ++--- hw/xfree86/common/xf86Xinput.c | 38 +++++++---------------------- hw/xnest/Events.c | 32 ++++++++----------------- hw/xquartz/darwinEvents.c | 20 ++++++---------- hw/xwin/winkeybd.c | 6 +---- hw/xwin/winmouse.c | 15 ++++-------- 8 files changed, 54 insertions(+), 135 deletions(-) (limited to 'hw') diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c index 15d80f5bb..3f9035cdd 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 f21475fb6..521542c91 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 3006ad183..6402d72b3 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 aae665864..111f16f50 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -1012,7 +1012,6 @@ xf86PostMotionEventM(DeviceIntPtr device, int is_absolute, const ValuatorMask *mask) { - int i = 0, nevents = 0; int flags = 0; if (valuator_mask_num_valuators(mask) > 0) @@ -1050,11 +1049,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 +1094,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 @@ -1157,7 +1147,6 @@ xf86PostButtonEventM(DeviceIntPtr device, int is_down, const ValuatorMask *mask) { - int i = 0, nevents = 0; int flags = 0; if (valuator_mask_num_valuators(mask) > 0) @@ -1177,13 +1166,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 +1220,6 @@ xf86PostKeyEventM(DeviceIntPtr device, int is_absolute, const ValuatorMask *mask) { - int i = 0, nevents = 0; - #if XFreeXDGA DeviceIntPtr pointer; @@ -1250,12 +1233,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 5c800860a..574e4e415 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 f3e12250e..99956e012 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -433,7 +433,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]; @@ -486,15 +485,13 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa darwinEvents_lock(); { ValuatorMask mask; valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators); - num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, - POINTER_ABSOLUTE, &mask); - for(i=0; i 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"); @@ -502,15 +499,13 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) { } darwinEvents_lock(); { - num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL); - for(i=0; i 0) DarwinPokeEQ(); + QueueKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL); + DarwinPokeEQ(); } darwinEvents_unlock(); } void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y, float pressure, float tilt_x, float tilt_y) { - int i, num_events; ScreenPtr screen; int valuators[5]; @@ -531,9 +526,8 @@ void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, darwinEvents_lock(); { ValuatorMask mask; valuator_mask_set_range(&mask, 0, 5, valuators); - num_events = GetProximityEvents(darwinEvents, pDev, ev_type, &mask); - for(i=0; i 0) DarwinPokeEQ(); + QueueProximityEvents(darwinEvents, pDev, ev_type, &mask); + DarwinPokeEQ(); } darwinEvents_unlock(); } diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index 912e2de1c..cf0dea22e 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 080e09626..0e36687cf 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); } -- cgit v1.2.3