summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mi/mipointer.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/mi/mipointer.c b/mi/mipointer.c
index c28911bc6..b94feaa91 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -70,6 +70,8 @@ static Bool miPointerSetCursorPosition(ScreenPtr pScreen, int x, int y,
static Bool miPointerCloseScreen(int index, ScreenPtr pScreen);
static void miPointerMove(ScreenPtr pScreen, int x, int y, unsigned long time);
+static xEvent* events; /* for WarpPointer MotionNotifies */
+
_X_EXPORT Bool
miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
ScreenPtr pScreen;
@@ -128,6 +130,9 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
miPointer.confined = FALSE;
miPointer.x = 0;
miPointer.y = 0;
+
+ events = NULL;
+
return TRUE;
}
@@ -144,6 +149,8 @@ miPointerCloseScreen (index, pScreen)
miPointer.pSpriteScreen = 0;
pScreen->CloseScreen = pScreenPriv->CloseScreen;
xfree ((pointer) pScreenPriv);
+ xfree ((pointer) events);
+ events = NULL;
return (*pScreen->CloseScreen) (index, pScreen);
}
@@ -466,7 +473,31 @@ miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y)
void
miPointerMove (ScreenPtr pScreen, int x, int y, unsigned long time)
{
+ int i, nevents;
+ int valuators[2];
+
miPointerMoved(inputInfo.pointer, pScreen, x, y, time);
+
+ /* generate motion notify */
+ valuators[0] = x;
+ valuators[1] = y;
+
+ if (!events)
+ {
+ events = (xEvent*)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+
+ if (!events)
+ {
+ FatalError("Could not allocate event store.\n");
+ return;
+ }
+ }
+
+ nevents = GetPointerEvents(events, inputInfo.pointer, MotionNotify, 0,
+ POINTER_ABSOLUTE, 0, 2, valuators);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(inputInfo.pointer, &events[i]);
}
/* Move the pointer on the current screen, and update the sprite. */
@@ -474,10 +505,6 @@ void
miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
unsigned long time)
{
- xEvent* events;
- int i, nevents;
- int valuators[2];
-
SetupScreen(pScreen);
if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) &&
@@ -492,23 +519,4 @@ miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
miPointer.x = x;
miPointer.y = y;
miPointer.pScreen = pScreen;
-
- /* generate motion notify */
- valuators[0] = x;
- valuators[1] = y;
-
- events = (xEvent*)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
- if (!events)
- {
- FatalError("Could not allocate event store.\n");
- return;
- }
-
- nevents = GetPointerEvents(events, pDev, MotionNotify, 0,
- POINTER_ABSOLUTE, 0, 2, valuators);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(pDev, &events[i]);
-
- xfree(events);
}