summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-02-16 09:57:57 +1030
committerPeter Hutterer <whot@hyena.localdomain>2007-02-16 09:57:57 +1030
commit37fe4c49dc3a5faf2d3d56112b6bd78453045f6a (patch)
treef5c8ea2f056a4d2eebcb5421981596585ef91265 /mi
parentc2f3f705f1db8ca78292912544a7e416116175f3 (diff)
mi: Move WarpPointer event generation to miPointerMove to avoid duplicate
events, cache event array allocation.
Diffstat (limited to 'mi')
-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);
}