Xnest: port to new input API
Port Xnest to Get{Pointer,Keyboard}Events, plus the new mieq API.
This commit is contained in:
parent
08928afb05
commit
2f33f4065d
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user