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 "XNWindow.h"
|
||||||
#include "Events.h"
|
#include "Events.h"
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
|
#include "Pointer.h"
|
||||||
#include "mipointer.h"
|
#include "mipointer.h"
|
||||||
|
|
||||||
CARD32 lastEventTime = 0;
|
CARD32 lastEventTime = 0;
|
||||||
|
|
||||||
|
extern xEvent *xnestEvents;
|
||||||
|
|
||||||
void
|
void
|
||||||
ProcessInputEvents()
|
ProcessInputEvents()
|
||||||
{
|
{
|
||||||
|
@ -101,11 +104,12 @@ xnestCollectExposures()
|
||||||
void
|
void
|
||||||
xnestQueueKeyEvent(int type, unsigned int keycode)
|
xnestQueueKeyEvent(int type, unsigned int keycode)
|
||||||
{
|
{
|
||||||
xEvent x;
|
int i, n;
|
||||||
x.u.u.type = type;
|
|
||||||
x.u.u.detail = keycode;
|
lastEventTime = GetTimeInMillis();
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode);
|
||||||
mieqEnqueue(&x);
|
for (i = 0; i < n; i++)
|
||||||
|
mieqEnqueue(xnestKeyboardDevice, xnestEvents + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -113,6 +117,7 @@ xnestCollectEvents()
|
||||||
{
|
{
|
||||||
XEvent X;
|
XEvent X;
|
||||||
xEvent x;
|
xEvent x;
|
||||||
|
int i, n, valuators[2];
|
||||||
ScreenPtr pScreen;
|
ScreenPtr pScreen;
|
||||||
|
|
||||||
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
|
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
|
||||||
|
@ -129,30 +134,30 @@ xnestCollectEvents()
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
xnestUpdateModifierState(X.xkey.state);
|
xnestUpdateModifierState(X.xkey.state);
|
||||||
x.u.u.type = ButtonPress;
|
lastEventTime = GetTimeInMillis();
|
||||||
x.u.u.detail = X.xbutton.button;
|
n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL);
|
||||||
mieqEnqueue(&x);
|
for (i = 0; i < n; i++)
|
||||||
|
mieqEnqueue(xnestPointerDevice, xnestEvents + i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
xnestUpdateModifierState(X.xkey.state);
|
xnestUpdateModifierState(X.xkey.state);
|
||||||
x.u.u.type = ButtonRelease;
|
lastEventTime = GetTimeInMillis();
|
||||||
x.u.u.detail = X.xbutton.button;
|
n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL);
|
||||||
mieqEnqueue(&x);
|
for (i = 0; i < n; i++)
|
||||||
|
mieqEnqueue(xnestPointerDevice, xnestEvents + i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
#if 0
|
valuators[0] = X.xmotion.x;
|
||||||
x.u.u.type = MotionNotify;
|
valuators[1] = X.xmotion.y;
|
||||||
x.u.keyButtonPointer.rootX = X.xmotion.x;
|
lastEventTime = GetTimeInMillis();
|
||||||
x.u.keyButtonPointer.rootY = X.xmotion.y;
|
n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
0, POINTER_ABSOLUTE, 0, 2, valuators);
|
||||||
mieqEnqueue(&x);
|
for (i = 0; i < n; i++)
|
||||||
#endif
|
mieqEnqueue(xnestPointerDevice, xnestEvents + i);
|
||||||
miPointerAbsoluteCursor (X.xmotion.x, X.xmotion.y,
|
|
||||||
lastEventTime = GetTimeInMillis());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
@ -179,15 +184,13 @@ xnestCollectEvents()
|
||||||
pScreen = xnestScreen(X.xcrossing.window);
|
pScreen = xnestScreen(X.xcrossing.window);
|
||||||
if (pScreen) {
|
if (pScreen) {
|
||||||
NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y);
|
NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y);
|
||||||
#if 0
|
valuators[0] = X.xcrossing.x;
|
||||||
x.u.u.type = MotionNotify;
|
valuators[1] = X.xcrossing.y;
|
||||||
x.u.keyButtonPointer.rootX = X.xcrossing.x;
|
lastEventTime = GetTimeInMillis();
|
||||||
x.u.keyButtonPointer.rootY = X.xcrossing.y;
|
n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
|
||||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
|
0, POINTER_ABSOLUTE, 0, 2, valuators);
|
||||||
mieqEnqueue(&x);
|
for (i = 0; i < n; i++)
|
||||||
#endif
|
mieqEnqueue(xnestPointerDevice, xnestEvents + i);
|
||||||
miPointerAbsoluteCursor (X.xcrossing.x, X.xcrossing.y,
|
|
||||||
lastEventTime = GetTimeInMillis());
|
|
||||||
xnestDirectInstallColormaps(pScreen);
|
xnestDirectInstallColormaps(pScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@ is" without express or implied warranty.
|
||||||
|
|
||||||
Bool xnestDoFullGeneration = True;
|
Bool xnestDoFullGeneration = True;
|
||||||
|
|
||||||
|
xEvent *xnestEvents = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
|
InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -92,10 +94,15 @@ InitInput(int argc, char *argv[])
|
||||||
xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
|
xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
|
||||||
xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, 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);
|
RegisterPointerDevice(xnestPointerDevice);
|
||||||
RegisterKeyboardDevice(xnestKeyboardDevice);
|
RegisterKeyboardDevice(xnestKeyboardDevice);
|
||||||
|
|
||||||
mieqInit((DevicePtr)xnestKeyboardDevice, (DevicePtr)xnestPointerDevice);
|
mieqInit();
|
||||||
|
|
||||||
AddEnabledDevice(XConnectionNumber(xnestDisplay));
|
AddEnabledDevice(XConnectionNumber(xnestDisplay));
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ xnestPointerProc(DeviceIntPtr pDev, int onoff)
|
||||||
InitPointerDeviceStruct(&pDev->public, map, nmap,
|
InitPointerDeviceStruct(&pDev->public, map, nmap,
|
||||||
miPointerGetMotionEvents,
|
miPointerGetMotionEvents,
|
||||||
xnestChangePointerControl,
|
xnestChangePointerControl,
|
||||||
miPointerGetMotionBufferSize());
|
miPointerGetMotionBufferSize(), 2);
|
||||||
break;
|
break;
|
||||||
case DEVICE_ON:
|
case DEVICE_ON:
|
||||||
xnestEventMask |= XNEST_POINTER_EVENT_MASK;
|
xnestEventMask |= XNEST_POINTER_EVENT_MASK;
|
||||||
|
|
Loading…
Reference in New Issue