summaryrefslogtreecommitdiff
path: root/xserver/mi/mipointer.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2013-06-07 17:28:57 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2013-06-07 17:28:57 +0000
commitc0190187060808fe0ad2a09b31f4244757572ff9 (patch)
treeb028697436476ae3ff34218b0b233a233d8a7818 /xserver/mi/mipointer.c
parent33eda071f5846d332b428de759c5b1649e9cf1ba (diff)
Update to X server 1.14.1. Tested by many during t2k13. Thanks.
Diffstat (limited to 'xserver/mi/mipointer.c')
-rw-r--r--xserver/mi/mipointer.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/xserver/mi/mipointer.c b/xserver/mi/mipointer.c
index de6698a37..b8503f450 100644
--- a/xserver/mi/mipointer.c
+++ b/xserver/mi/mipointer.c
@@ -91,14 +91,14 @@ static void miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen,
BoxPtr pTopLeftBox);
static Bool miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen,
int x, int y, Bool generateEvent);
-static Bool miPointerCloseScreen(int index, ScreenPtr pScreen);
+static Bool miPointerCloseScreen(ScreenPtr pScreen);
static void miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
static Bool miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
static void miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
static void miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x,
int y);
-static InternalEvent *events; /* for WarpPointer MotionNotifies */
+static InternalEvent *mipointermove_events; /* for WarpPointer MotionNotifies */
Bool
miPointerInitialize(ScreenPtr pScreen,
@@ -143,7 +143,7 @@ miPointerInitialize(ScreenPtr pScreen,
pScreen->DeviceCursorInitialize = miPointerDeviceInitialize;
pScreen->DeviceCursorCleanup = miPointerDeviceCleanup;
- events = NULL;
+ mipointermove_events = NULL;
return TRUE;
}
@@ -154,15 +154,15 @@ miPointerInitialize(ScreenPtr pScreen,
* @param pScreen The actual screen pointer
*/
static Bool
-miPointerCloseScreen(int index, ScreenPtr pScreen)
+miPointerCloseScreen(ScreenPtr pScreen)
{
SetupScreen(pScreen);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
free((pointer) pScreenPriv);
- FreeEventList(events, GetMaximumEventsNum());
- events = NULL;
- return (*pScreen->CloseScreen) (index, pScreen);
+ FreeEventList(mipointermove_events, GetMaximumEventsNum());
+ mipointermove_events = NULL;
+ return (*pScreen->CloseScreen) (pScreen);
}
/*
@@ -565,23 +565,21 @@ miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
*/
ScreenPtr
miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
- double *screeny)
+ double *screeny,
+ int *nevents, InternalEvent* events)
{
miPointerScreenPtr pScreenPriv;
ScreenPtr pScreen;
ScreenPtr newScreen;
int x, y;
Bool switch_screen = FALSE;
+ Bool should_constrain_barriers = FALSE;
+ int i;
miPointerPtr pPointer;
- if (!pDev || !pDev->coreEvents)
- return NULL;
-
pPointer = MIPOINTER(pDev);
pScreen = pPointer->pScreen;
- if (!pScreen)
- return NULL; /* called before ready */
x = trunc(*screenx);
y = trunc(*screeny);
@@ -593,6 +591,25 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
x -= pScreen->x;
y -= pScreen->y;
+ should_constrain_barriers = (mode == Relative);
+
+ if (should_constrain_barriers) {
+ /* coordinates after clamped to a barrier */
+ int constrained_x, constrained_y;
+ int current_x, current_y; /* current position in per-screen coord */
+
+ current_x = MIPOINTER(pDev)->x - pScreen->y;
+ current_y = MIPOINTER(pDev)->y - pScreen->x;
+
+ input_constrain_cursor(pDev, pScreen,
+ current_x, current_y, x, y,
+ &constrained_x, &constrained_y,
+ nevents, events);
+
+ x = constrained_x;
+ y = constrained_y;
+ }
+
if (switch_screen) {
pScreenPriv = GetScreenPrivate(pScreen);
if (!pPointer->confined) {
@@ -624,6 +641,18 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
if (pPointer->x != x || pPointer->y != y || pPointer->pScreen != pScreen)
miPointerMoveNoEvent(pDev, pScreen, x, y);
+ /* check if we generated any barrier events and if so, update root x/y
+ * to the fully constrained coords */
+ if (should_constrain_barriers) {
+ for (i = 0; i < *nevents; i++) {
+ if (events[i].any.type == ET_BarrierHit ||
+ events[i].any.type == ET_BarrierLeave) {
+ events[i].barrier_event.root_x = x;
+ events[i].barrier_event.root_y = y;
+ }
+ }
+ }
+
/* Convert to desktop coordinates again */
x += pScreen->x;
y += pScreen->y;
@@ -681,17 +710,17 @@ miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
valuators[0] = x;
valuators[1] = y;
- if (!events) {
- events = InitEventList(GetMaximumEventsNum());
+ if (!mipointermove_events) {
+ mipointermove_events = InitEventList(GetMaximumEventsNum());
- if (!events) {
+ if (!mipointermove_events) {
FatalError("Could not allocate event store.\n");
return;
}
}
valuator_mask_set_range(&mask, 0, 2, valuators);
- nevents = GetPointerEvents(events, pDev, MotionNotify, 0,
+ nevents = GetPointerEvents(mipointermove_events, pDev, MotionNotify, 0,
POINTER_SCREEN | POINTER_ABSOLUTE |
POINTER_NORAW, &mask);
@@ -700,7 +729,7 @@ miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
darwinEvents_lock();
#endif
for (i = 0; i < nevents; i++)
- mieqEnqueue(pDev, &events[i]);
+ mieqEnqueue(pDev, &mipointermove_events[i]);
#ifdef XQUARTZ
darwinEvents_unlock();
#endif