summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-10-08 20:34:32 +0300
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-10-08 20:34:32 +0300
commit41bb9fce47f6366cc3f7d45790f7883f74289b5a (patch)
treea14e527db23b262d42f289082967974a3bc28d29 /mi
parentbe8dfafd1d58b27bbfd953fc1216311523353db1 (diff)
mipointer: take device arguments, split miPointerAbsoluteCursor
Update mipointer API to take a device argument to (almost) all functions, and split miPointerAbsoluteCursor into a couple of separate functions. Remove miPointerAbsoluteCursor call from mieq, as we now deal with it in GetPointerEvents. Make miPointerSetPosition (successor of miPointerAbsoluteCursor) take pointers to x and y, so it can return the clipped values. Modify callers of miPointer*() functions to generally use the new functions. This should fix things with multi-head setups.
Diffstat (limited to 'mi')
-rw-r--r--mi/mieq.c3
-rw-r--r--mi/mipointer.c105
-rw-r--r--mi/mipointer.h29
3 files changed, 94 insertions, 43 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index 856aa25c4..16e638c64 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -104,9 +104,6 @@ mieqEnqueue (xEvent *e)
&laste->event[0];
if (e->u.u.type == MotionNotify) {
- miPointerSetPosition(pDev, e->u.keyButtonPointer.rootX,
- e->u.keyButtonPointer.rootY,
- e->u.keyButtonPointer.time);
pDev = inputInfo.pointer;
isMotion = inputInfo.pointer->id & DEVICE_BITS;
}
diff --git a/mi/mipointer.c b/mi/mipointer.c
index c9b80bfe1..7f850adde 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -320,13 +320,18 @@ miPointerUpdateSprite (DeviceIntPtr pDev)
CursorPtr pCursor;
int x, y, devx, devy;
+ if (!pDev || !(pDev->coreEvents || pDev == inputInfo.pointer))
+ return;
+
pScreen = miPointer.pScreen;
+ if (!pScreen)
+ return;
+
x = miPointer.x;
y = miPointer.y;
devx = miPointer.devx;
devy = miPointer.devy;
- if (!pScreen)
- return;
+
pScreenPriv = GetScreenPrivate (pScreen);
/*
* if the cursor has switched screens, disable the sprite
@@ -385,13 +390,20 @@ miPointerUpdateSprite (DeviceIntPtr pDev)
void
miPointerDeltaCursor (int dx, int dy, unsigned long time)
{
- miPointerSetPosition(inputInfo.pointer, miPointer.x + dx,
- miPointer.y + dy, time);
+ int x = miPointer.x + dx, y = miPointer.y + dy;
+
+ miPointerSetPosition(inputInfo.pointer, &x, &y, time);
}
void
miPointerSetNewScreen(int screen_no, int x, int y)
{
+ miPointerSetScreen(inputInfo.pointer, screen_no, x, y);
+}
+
+void
+miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y)
+{
miPointerScreenPtr pScreenPriv;
ScreenPtr pScreen;
@@ -406,21 +418,26 @@ miPointerSetNewScreen(int screen_no, int x, int y)
_X_EXPORT ScreenPtr
miPointerCurrentScreen ()
{
- return (miPointer.pScreen);
+ return miPointerGetScreen(inputInfo.pointer);
}
-/*
- * miPointerAbsoluteCursor. The pointer has moved to x,y
- */
+_X_EXPORT ScreenPtr
+miPointerGetScreen(DeviceIntPtr pDev)
+{
+ return miPointer.pScreen;
+}
+/* Move the pointer to x, y on the current screen, update the sprite, and
+ * the motion history. Generates no events. Does not return changed x
+ * and y if they are clipped; use miPointerSetPosition instead. */
_X_EXPORT void
miPointerAbsoluteCursor (int x, int y, unsigned long time)
{
- miPointerSetPosition(inputInfo.pointer, x, y, time);
+ miPointerSetPosition(inputInfo.pointer, &x, &y, time);
}
_X_EXPORT void
-miPointerSetPosition(DeviceIntPtr pDev, int x, int y, unsigned long time)
+miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y, unsigned long time)
{
miPointerScreenPtr pScreenPriv;
ScreenPtr pScreen;
@@ -430,13 +447,16 @@ miPointerSetPosition(DeviceIntPtr pDev, int x, int y, unsigned long time)
if (!pScreen)
return; /* called before ready */
- if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height)
+ if (!pDev || !(pDev->coreEvents || pDev == inputInfo.pointer))
+ return;
+
+ if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height)
{
pScreenPriv = GetScreenPrivate (pScreen);
if (!miPointer.confined)
{
newScreen = pScreen;
- (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y);
+ (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y);
if (newScreen != pScreen)
{
pScreen = newScreen;
@@ -448,21 +468,20 @@ miPointerSetPosition(DeviceIntPtr pDev, int x, int y, unsigned long time)
}
}
}
- /*
- * constrain the hot-spot to the current
- * limits
- */
- if (x < miPointer.limits.x1)
- x = miPointer.limits.x1;
- if (x >= miPointer.limits.x2)
- x = miPointer.limits.x2 - 1;
- if (y < miPointer.limits.y1)
- y = miPointer.limits.y1;
- if (y >= miPointer.limits.y2)
- y = miPointer.limits.y2 - 1;
- if (miPointer.x == x && miPointer.y == y && miPointer.pScreen == pScreen)
+ /* Constrain the sprite to the current limits. */
+ if (*x < miPointer.limits.x1)
+ *x = miPointer.limits.x1;
+ if (*x >= miPointer.limits.x2)
+ *x = miPointer.limits.x2 - 1;
+ if (*y < miPointer.limits.y1)
+ *y = miPointer.limits.y1;
+ if (*y >= miPointer.limits.y2)
+ *y = miPointer.limits.y2 - 1;
+
+ if (miPointer.x == *x && miPointer.y == *y && miPointer.pScreen == pScreen)
return;
- miPointerMove (pScreen, x, y, time);
+
+ miPointerMoved(pDev, pScreen, *x, *y, time);
}
_X_EXPORT void
@@ -478,27 +497,39 @@ miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y)
*y = miPointer.y;
}
-/*
- * miPointerMove. The pointer has moved to x,y on current screen
- */
+void
+miPointerMove (ScreenPtr pScreen, int x, int y, unsigned long time)
+{
+ miPointerMoved(inputInfo.pointer, pScreen, x, y, time);
+}
-static void
-miPointerMove (pScreen, x, y, time)
- ScreenPtr pScreen;
- int x, y;
- unsigned long time;
+/* Move the pointer on the current screen, and update the sprite. */
+void
+miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
+ unsigned long time)
{
SetupScreen(pScreen);
- miHistoryPtr history;
- int prev, end, start;
- if (!pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
+ if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) &&
+ !pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
{
miPointer.devx = x;
miPointer.devy = y;
if(!miPointer.pCursor->bits->emptyMask)
(*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
}
+
+ miPointerUpdateHistory(pDev, pScreen, x, y, time);
+}
+
+/* The pointer has moved to x, y; update the motion history. */
+void
+miPointerUpdateHistory (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
+ unsigned long time)
+{
+ miHistoryPtr history;
+ int prev, end, start;
+
miPointer.x = x;
miPointer.y = y;
miPointer.pScreen = pScreen;
diff --git a/mi/mipointer.h b/mi/mipointer.h
index a910de61e..82ff045d6 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -149,22 +149,45 @@ extern ScreenPtr miPointerCurrentScreen(
extern ScreenPtr miPointerGetScreen(
DeviceIntPtr pDev);
extern void miPointerSetScreen(
- DeviceIntPtr pDev);
+ DeviceIntPtr pDev,
+ int screen_num,
+ int x,
+ int y);
+/* Returns the current cursor position. */
extern void miPointerGetPosition(
DeviceIntPtr pDev,
int *x,
int *y);
+/* Moves the cursor to the specified position. May clip the co-ordinates:
+ * x and y are modified in-place. */
extern void miPointerSetPosition(
DeviceIntPtr pDev,
- int x,
- int y,
+ int *x,
+ int *y,
unsigned long time);
extern void miPointerUpdateSprite(
DeviceIntPtr pDev);
+/* Moves the sprite to x, y on the current screen, and updates the event
+ * history. */
+extern void miPointerMoved(
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ unsigned long time);
+
+/* Updates the event history. */
+extern void miPointerUpdateHistory(
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ unsigned long time);
+
extern int miPointerScreenIndex;
#endif /* MIPOINTER_H */