diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-10-23 02:52:35 +0300 |
---|---|---|
committer | Daniel Stone <daniels@endtroducing.fooishbar.org> | 2006-10-23 02:52:35 +0300 |
commit | 2f33f4065d89ae2b6fdda43c7105d72f89920cae (patch) | |
tree | de4172bbe6cbffb3e91d48fce191bbd99b189984 /hw | |
parent | 08928afb0500d46b0caa0a1d1244dee2ed80e6a0 (diff) |
Xnest: port to new input API
Port Xnest to Get{Pointer,Keyboard}Events, plus the new mieq API.
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xnest/Events.c | 65 | ||||
-rw-r--r-- | hw/xnest/Init.c | 9 | ||||
-rw-r--r-- | hw/xnest/Pointer.c | 2 |
3 files changed, 43 insertions, 33 deletions
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index e5cf99e2c..a20924128 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -37,10 +37,13 @@ is" without express or implied warranty. #include "XNWindow.h" #include "Events.h" #include "Keyboard.h" +#include "Pointer.h" #include "mipointer.h" CARD32 lastEventTime = 0; +extern xEvent *xnestEvents; + void ProcessInputEvents() { @@ -101,11 +104,12 @@ xnestCollectExposures() void xnestQueueKeyEvent(int type, unsigned int keycode) { - xEvent x; - x.u.u.type = type; - x.u.u.detail = keycode; - x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); - mieqEnqueue(&x); + int i, n; + + lastEventTime = GetTimeInMillis(); + n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode); + for (i = 0; i < n; i++) + mieqEnqueue(xnestKeyboardDevice, xnestEvents + i); } void @@ -113,6 +117,7 @@ xnestCollectEvents() { XEvent X; xEvent x; + int i, n, valuators[2]; ScreenPtr pScreen; while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) { @@ -129,30 +134,30 @@ xnestCollectEvents() case ButtonPress: xnestUpdateModifierState(X.xkey.state); - x.u.u.type = ButtonPress; - x.u.u.detail = X.xbutton.button; - x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); - mieqEnqueue(&x); + lastEventTime = GetTimeInMillis(); + n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress, + X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL); + for (i = 0; i < n; i++) + mieqEnqueue(xnestPointerDevice, xnestEvents + i); break; case ButtonRelease: xnestUpdateModifierState(X.xkey.state); - x.u.u.type = ButtonRelease; - x.u.u.detail = X.xbutton.button; - x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); - mieqEnqueue(&x); + lastEventTime = GetTimeInMillis(); + n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease, + X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL); + for (i = 0; i < n; i++) + mieqEnqueue(xnestPointerDevice, xnestEvents + i); break; case MotionNotify: -#if 0 - x.u.u.type = MotionNotify; - x.u.keyButtonPointer.rootX = X.xmotion.x; - x.u.keyButtonPointer.rootY = X.xmotion.y; - x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); - mieqEnqueue(&x); -#endif - miPointerAbsoluteCursor (X.xmotion.x, X.xmotion.y, - lastEventTime = GetTimeInMillis()); + valuators[0] = X.xmotion.x; + valuators[1] = X.xmotion.y; + lastEventTime = GetTimeInMillis(); + n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify, + 0, POINTER_ABSOLUTE, 0, 2, valuators); + for (i = 0; i < n; i++) + mieqEnqueue(xnestPointerDevice, xnestEvents + i); break; case FocusIn: @@ -179,15 +184,13 @@ xnestCollectEvents() pScreen = xnestScreen(X.xcrossing.window); if (pScreen) { NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y); -#if 0 - x.u.u.type = MotionNotify; - x.u.keyButtonPointer.rootX = X.xcrossing.x; - x.u.keyButtonPointer.rootY = X.xcrossing.y; - x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); - mieqEnqueue(&x); -#endif - miPointerAbsoluteCursor (X.xcrossing.x, X.xcrossing.y, - lastEventTime = GetTimeInMillis()); + valuators[0] = X.xcrossing.x; + valuators[1] = X.xcrossing.y; + lastEventTime = GetTimeInMillis(); + n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify, + 0, POINTER_ABSOLUTE, 0, 2, valuators); + for (i = 0; i < n; i++) + mieqEnqueue(xnestPointerDevice, xnestEvents + i); xnestDirectInstallColormaps(pScreen); } } diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c index 8c397a7bb..5bf0300c6 100644 --- a/hw/xnest/Init.c +++ b/hw/xnest/Init.c @@ -45,6 +45,8 @@ is" without express or implied warranty. Bool xnestDoFullGeneration = True; +xEvent *xnestEvents = NULL; + void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) { @@ -92,10 +94,15 @@ InitInput(int argc, char *argv[]) xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE); xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, TRUE); + if (!xnestEvents) + xnestEvents = (xEvent *) xcalloc(sizeof(xEvent), GetMaximumEventsNum()); + if (!xnestEvents) + FatalError("couldn't allocate room for events\n"); + RegisterPointerDevice(xnestPointerDevice); RegisterKeyboardDevice(xnestKeyboardDevice); - mieqInit((DevicePtr)xnestKeyboardDevice, (DevicePtr)xnestPointerDevice); + mieqInit(); AddEnabledDevice(XConnectionNumber(xnestDisplay)); diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c index 454449732..b5e45db12 100644 --- a/hw/xnest/Pointer.c +++ b/hw/xnest/Pointer.c @@ -59,7 +59,7 @@ xnestPointerProc(DeviceIntPtr pDev, int onoff) InitPointerDeviceStruct(&pDev->public, map, nmap, miPointerGetMotionEvents, xnestChangePointerControl, - miPointerGetMotionBufferSize()); + miPointerGetMotionBufferSize(), 2); break; case DEVICE_ON: xnestEventMask |= XNEST_POINTER_EVENT_MASK; |