2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1989, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
*/
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* This file contains functions to move the pointer on the screen and/or
|
|
|
|
* restrict its movement. These functions are divided into two sets:
|
|
|
|
* Screen-specific functions that are used as function pointers from other
|
|
|
|
* parts of the server (and end up heavily wrapped by e.g. animcur and
|
|
|
|
* xfixes):
|
|
|
|
* miPointerConstrainCursor
|
|
|
|
* miPointerCursorLimits
|
|
|
|
* miPointerDisplayCursor
|
|
|
|
* miPointerRealizeCursor
|
|
|
|
* miPointerUnrealizeCursor
|
|
|
|
* miPointerSetCursorPosition
|
|
|
|
* miRecolorCursor
|
|
|
|
* miPointerDeviceInitialize
|
|
|
|
* miPointerDeviceCleanup
|
|
|
|
* If wrapped, these are the last element in the wrapping chain. They may
|
|
|
|
* call into sprite-specific code through further function pointers though.
|
|
|
|
*
|
|
|
|
* The second type of functions are those that are directly called by the
|
|
|
|
* DIX, DDX and some drivers.
|
|
|
|
*/
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xmd.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "mi.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "mipointrst.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include "inpututils.h"
|
|
|
|
#include "eventstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
DevPrivateKeyRec miPointerScreenKeyRec;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#define GetScreenPrivate(s) ((miPointerScreenPtr) \
|
|
|
|
dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
|
2006-11-26 11:13:41 -07:00
|
|
|
#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s)
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
DevPrivateKeyRec miPointerPrivKeyRec;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
#define MIPOINTER(dev) \
|
2011-11-05 07:32:40 -06:00
|
|
|
(IsFloating(dev) ? \
|
2009-09-06 13:44:18 -06:00
|
|
|
(miPointerPtr)dixLookupPrivate(&(dev)->devPrivates, miPointerPrivKey): \
|
2010-07-27 13:02:24 -06:00
|
|
|
(miPointerPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miPointerPrivKey))
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool miPointerRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2009-09-06 13:44:18 -06:00
|
|
|
CursorPtr pCursor);
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool miPointerUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2009-09-06 13:44:18 -06:00
|
|
|
CursorPtr pCursor);
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool miPointerDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2009-09-06 13:44:18 -06:00
|
|
|
CursorPtr pCursor);
|
|
|
|
static void miPointerConstrainCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
BoxPtr pBox);
|
2009-09-06 13:44:18 -06:00
|
|
|
static void miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
CursorPtr pCursor, BoxPtr pHotBox,
|
2009-09-06 13:44:18 -06:00
|
|
|
BoxPtr pTopLeftBox);
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
int x, int y, Bool generateEvent);
|
2006-11-26 11:13:41 -07:00
|
|
|
static Bool miPointerCloseScreen(int index, ScreenPtr pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
static void miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
|
2009-09-06 13:44:18 -06:00
|
|
|
static Bool miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
static void miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
|
|
|
|
static void miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x,
|
|
|
|
int y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static InternalEvent *events; /* for WarpPointer MotionNotifies */
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerInitialize(ScreenPtr pScreen,
|
|
|
|
miPointerSpriteFuncPtr spriteFuncs,
|
|
|
|
miPointerScreenFuncPtr screenFuncs, Bool waitForUpdate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerScreenPtr pScreenPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreenPriv = malloc(sizeof(miPointerScreenRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pScreenPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->spriteFuncs = spriteFuncs;
|
|
|
|
pScreenPriv->screenFuncs = screenFuncs;
|
|
|
|
/*
|
|
|
|
* check for uninitialized methods
|
|
|
|
*/
|
|
|
|
if (!screenFuncs->EnqueueEvent)
|
2012-06-10 07:21:05 -06:00
|
|
|
screenFuncs->EnqueueEvent = mieqEnqueue;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!screenFuncs->NewEventScreen)
|
2012-06-10 07:21:05 -06:00
|
|
|
screenFuncs->NewEventScreen = mieqSwitchScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->waitForUpdate = waitForUpdate;
|
|
|
|
pScreenPriv->showTransparent = FALSE;
|
|
|
|
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
|
|
|
pScreen->CloseScreen = miPointerCloseScreen;
|
2008-11-02 08:26:08 -07:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, miPointerScreenKey, pScreenPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* set up screen cursor method table
|
|
|
|
*/
|
|
|
|
pScreen->ConstrainCursor = miPointerConstrainCursor;
|
|
|
|
pScreen->CursorLimits = miPointerCursorLimits;
|
|
|
|
pScreen->DisplayCursor = miPointerDisplayCursor;
|
|
|
|
pScreen->RealizeCursor = miPointerRealizeCursor;
|
|
|
|
pScreen->UnrealizeCursor = miPointerUnrealizeCursor;
|
|
|
|
pScreen->SetCursorPosition = miPointerSetCursorPosition;
|
|
|
|
pScreen->RecolorCursor = miRecolorCursor;
|
2009-09-06 13:44:18 -06:00
|
|
|
pScreen->DeviceCursorInitialize = miPointerDeviceInitialize;
|
|
|
|
pScreen->DeviceCursorCleanup = miPointerDeviceCleanup;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
events = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Destroy screen-specific information.
|
|
|
|
*
|
|
|
|
* @param index Screen index of the screen in screenInfo.screens[]
|
|
|
|
* @param pScreen The actual screen pointer
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerCloseScreen(int index, ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
|
|
|
|
|
|
|
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
2010-12-05 08:36:02 -07:00
|
|
|
free((pointer) pScreenPriv);
|
2009-09-06 13:44:18 -06:00
|
|
|
FreeEventList(events, GetMaximumEventsNum());
|
2007-11-24 10:55:21 -07:00
|
|
|
events = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*pScreen->CloseScreen) (index, pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DIX/DDX interface routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
2009-09-06 13:44:18 -06:00
|
|
|
return (*pScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCursor);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerUnrealizeCursor(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen, CursorPtr pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*pScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen,
|
|
|
|
pCursor);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerPtr pPointer;
|
|
|
|
|
|
|
|
/* return for keyboards */
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!IsPointerDevice(pDev))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
pPointer = MIPOINTER(pDev);
|
|
|
|
|
|
|
|
pPointer->pCursor = pCursor;
|
|
|
|
pPointer->pScreen = pScreen;
|
|
|
|
miPointerUpdateSprite(pDev);
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Set up the constraints for the given device. This function does not
|
|
|
|
* actually constrain the cursor but merely copies the given box to the
|
|
|
|
* internal constraint storage.
|
|
|
|
*
|
|
|
|
* @param pDev The device to constrain to the box
|
|
|
|
* @param pBox The rectangle to constrain the cursor to
|
|
|
|
* @param pScreen Used for copying screen confinement
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerConstrainCursor(DeviceIntPtr pDev, ScreenPtr pScreen, BoxPtr pBox)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerPtr pPointer;
|
|
|
|
|
|
|
|
pPointer = MIPOINTER(pDev);
|
|
|
|
|
|
|
|
pPointer->limits = *pBox;
|
|
|
|
pPointer->confined = PointerConfinedToScreen(pDev);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Should calculate the box for the given cursor, based on screen and the
|
|
|
|
* confinement given. But we assume that whatever box is passed in is valid
|
|
|
|
* anyway.
|
|
|
|
*
|
|
|
|
* @param pDev The device to calculate the cursor limits for
|
|
|
|
* @param pScreen The screen the confinement happens on
|
|
|
|
* @param pCursor The screen the confinement happens on
|
|
|
|
* @param pHotBox The confinement box for the cursor
|
|
|
|
* @param[out] pTopLeftBox The new confinement box, always *pHotBox.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
|
|
|
|
BoxPtr pHotBox, BoxPtr pTopLeftBox)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
*pTopLeftBox = *pHotBox;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Set the device's cursor position to the x/y position on the given screen.
|
|
|
|
* Generates and event if required.
|
|
|
|
*
|
|
|
|
* This function is called from:
|
|
|
|
* - sprite init code to place onto initial position
|
|
|
|
* - the various WarpPointer implementations (core, XI, Xinerama, dmx,…)
|
|
|
|
* - during the cursor update path in CheckMotion
|
|
|
|
* - in the Xinerama part of NewCurrentScreen
|
|
|
|
* - when a RandR/RandR1.2 mode was applied (it may have moved the pointer, so
|
|
|
|
* it's set back to the original pos)
|
|
|
|
*
|
|
|
|
* @param pDev The device to move
|
|
|
|
* @param pScreen The screen the device is on
|
|
|
|
* @param x The x coordinate in per-screen coordinates
|
|
|
|
* @param y The y coordinate in per-screen coordinates
|
|
|
|
* @param generateEvent True if the pointer movement should generate an
|
|
|
|
* event.
|
|
|
|
*
|
|
|
|
* @return TRUE in all cases
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
static Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
int x, int y, Bool generateEvent)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
SetupScreen(pScreen);
|
2011-11-05 07:32:40 -06:00
|
|
|
miPointerPtr pPointer = MIPOINTER(pDev);
|
|
|
|
|
|
|
|
pPointer->generateEvent = generateEvent;
|
|
|
|
|
|
|
|
if (pScreen->ConstrainCursorHarder)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->ConstrainCursorHarder(pDev, pScreen, Absolute, &x, &y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* device dependent - must pend signal and call miPointerWarpCursor */
|
2009-09-06 13:44:18 -06:00
|
|
|
(*pScreenPriv->screenFuncs->WarpCursor) (pDev, pScreen, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!generateEvent)
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerUpdateSprite(pDev);
|
2009-09-06 13:44:18 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Set up sprite information for the device.
|
|
|
|
* This function will be called once for each device after it is initialized
|
|
|
|
* in the DIX.
|
|
|
|
*
|
|
|
|
* @param pDev The newly created device
|
|
|
|
* @param pScreen The initial sprite scree.
|
2009-09-06 13:44:18 -06:00
|
|
|
*/
|
|
|
|
static Bool
|
|
|
|
miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
miPointerPtr pPointer;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
SetupScreen(pScreen);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pPointer = malloc(sizeof(miPointerRec));
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!pPointer)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pPointer->pScreen = NULL;
|
|
|
|
pPointer->pSpriteScreen = NULL;
|
|
|
|
pPointer->pCursor = NULL;
|
|
|
|
pPointer->pSpriteCursor = NULL;
|
|
|
|
pPointer->limits.x1 = 0;
|
|
|
|
pPointer->limits.x2 = 32767;
|
|
|
|
pPointer->limits.y1 = 0;
|
|
|
|
pPointer->limits.y2 = 32767;
|
|
|
|
pPointer->confined = FALSE;
|
|
|
|
pPointer->x = 0;
|
|
|
|
pPointer->y = 0;
|
2011-11-05 07:32:40 -06:00
|
|
|
pPointer->generateEvent = FALSE;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!((*pScreenPriv->spriteFuncs->DeviceCursorInitialize) (pDev, pScreen))) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pPointer);
|
2009-09-06 13:44:18 -06:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dixSetPrivate(&pDev->devPrivates, miPointerPrivKey, pPointer);
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Clean up after device.
|
|
|
|
* This function will be called once before the device is freed in the DIX
|
|
|
|
*
|
|
|
|
* @param pDev The device to be removed from the server
|
|
|
|
* @param pScreen Current screen of the device
|
2009-09-06 13:44:18 -06:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!IsMaster(pDev) && !IsFloating(pDev))
|
2009-09-06 13:44:18 -06:00
|
|
|
return;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreenPriv->spriteFuncs->DeviceCursorCleanup) (pDev, pScreen);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(dixLookupPrivate(&pDev->devPrivates, miPointerPrivKey));
|
2009-09-06 13:44:18 -06:00
|
|
|
dixSetPrivate(&pDev->devPrivates, miPointerPrivKey, NULL);
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Warp the pointer to the given position on the given screen. May generate
|
|
|
|
* an event, depending on whether we're coming from miPointerSetPosition.
|
|
|
|
*
|
|
|
|
* Once signals are ignored, the WarpCursor function can call this
|
|
|
|
*
|
|
|
|
* @param pDev The device to warp
|
|
|
|
* @param pScreen Screen to warp on
|
|
|
|
* @param x The x coordinate in per-screen coordinates
|
|
|
|
* @param y The y coordinate in per-screen coordinates
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerPtr pPointer;
|
2008-11-02 08:26:08 -07:00
|
|
|
BOOL changedScreen = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
SetupScreen(pScreen);
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer = MIPOINTER(pDev);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pPointer->pScreen != pScreen) {
|
|
|
|
(*pScreenPriv->screenFuncs->NewEventScreen) (pDev, pScreen, TRUE);
|
2008-11-02 08:26:08 -07:00
|
|
|
changedScreen = TRUE;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (pPointer->generateEvent)
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerMove(pDev, pScreen, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2010-12-05 08:36:02 -07:00
|
|
|
miPointerMoveNoEvent(pDev, pScreen, x, y);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/* Don't call USFS if we use Xinerama, otherwise the root window is
|
|
|
|
* updated to the second screen, and we never receive any events.
|
|
|
|
* (FDO bug #18668) */
|
|
|
|
if (changedScreen
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
&& noPanoramiXExtension
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
)
|
|
|
|
UpdateSpriteForScreen(pDev, pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Syncronize the sprite with the cursor.
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2011-11-05 07:32:40 -06:00
|
|
|
* @param pDev The device to sync
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
2007-11-24 10:55:21 -07:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerUpdateSprite(DeviceIntPtr pDev)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
miPointerScreenPtr pScreenPriv;
|
|
|
|
CursorPtr pCursor;
|
|
|
|
int x, y, devx, devy;
|
|
|
|
miPointerPtr pPointer;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!pDev || !pDev->coreEvents)
|
2007-11-24 10:55:21 -07:00
|
|
|
return;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer = MIPOINTER(pDev);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!pPointer)
|
|
|
|
return;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pScreen = pPointer->pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!pScreen)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
x = pPointer->x;
|
|
|
|
y = pPointer->y;
|
|
|
|
devx = pPointer->devx;
|
|
|
|
devy = pPointer->devy;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreenPriv = GetScreenPrivate(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* if the cursor has switched screens, disable the sprite
|
|
|
|
* on the old screen
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScreen != pPointer->pSpriteScreen) {
|
|
|
|
if (pPointer->pSpriteScreen) {
|
|
|
|
miPointerScreenPtr pOldPriv;
|
|
|
|
|
|
|
|
pOldPriv = GetScreenPrivate(pPointer->pSpriteScreen);
|
|
|
|
if (pPointer->pCursor) {
|
|
|
|
(*pOldPriv->spriteFuncs->SetCursor)
|
|
|
|
(pDev, pPointer->pSpriteScreen, NullCursor, 0, 0);
|
|
|
|
}
|
|
|
|
(*pOldPriv->screenFuncs->CrossScreen) (pPointer->pSpriteScreen,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
(*pScreenPriv->screenFuncs->CrossScreen) (pScreen, TRUE);
|
|
|
|
(*pScreenPriv->spriteFuncs->SetCursor)
|
|
|
|
(pDev, pScreen, pPointer->pCursor, x, y);
|
|
|
|
pPointer->devx = x;
|
|
|
|
pPointer->devy = y;
|
|
|
|
pPointer->pSpriteCursor = pPointer->pCursor;
|
|
|
|
pPointer->pSpriteScreen = pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* if the cursor has changed, display the new one
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (pPointer->pCursor != pPointer->pSpriteCursor) {
|
|
|
|
pCursor = pPointer->pCursor;
|
|
|
|
if (!pCursor ||
|
|
|
|
(pCursor->bits->emptyMask && !pScreenPriv->showTransparent))
|
|
|
|
pCursor = NullCursor;
|
|
|
|
(*pScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen, pCursor, x, y);
|
|
|
|
|
|
|
|
pPointer->devx = x;
|
|
|
|
pPointer->devy = y;
|
|
|
|
pPointer->pSpriteCursor = pPointer->pCursor;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (x != devx || y != devy) {
|
|
|
|
pPointer->devx = x;
|
|
|
|
pPointer->devy = y;
|
|
|
|
if (pPointer->pCursor && !pPointer->pCursor->bits->emptyMask)
|
|
|
|
(*pScreenPriv->spriteFuncs->MoveCursor) (pDev, pScreen, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Set the device to the coordinates on the given screen.
|
|
|
|
*
|
|
|
|
* @param pDev The device to move
|
|
|
|
* @param screen_no Index of the screen to move to
|
|
|
|
* @param x The x coordinate in per-screen coordinates
|
|
|
|
* @param y The y coordinate in per-screen coordinates
|
|
|
|
*/
|
2007-11-24 10:55:21 -07:00
|
|
|
void
|
|
|
|
miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerScreenPtr pScreenPriv;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
miPointerPtr pPointer;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPointer = MIPOINTER(pDev);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen = screenInfo.screens[screen_no];
|
|
|
|
pScreenPriv = GetScreenPrivate(pScreen);
|
|
|
|
(*pScreenPriv->screenFuncs->NewEventScreen) (pDev, pScreen, FALSE);
|
|
|
|
NewCurrentScreen(pDev, pScreen, x, y);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPointer->limits.x2 = pScreen->width;
|
|
|
|
pPointer->limits.y2 = pScreen->height;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* @return The current screen of the VCP
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
ScreenPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerCurrentScreen(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
return miPointerGetScreen(inputInfo.pointer);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* @return The current screen of the given device or NULL.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
ScreenPtr
|
2007-11-24 10:55:21 -07:00
|
|
|
miPointerGetScreen(DeviceIntPtr pDev)
|
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerPtr pPointer = MIPOINTER(pDev);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
return (pPointer) ? pPointer->pScreen : NULL;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
/* Controls whether the cursor image should be updated immediately when
|
|
|
|
moved (FALSE) or if something else will be responsible for updating
|
|
|
|
it later (TRUE). Returns current setting.
|
|
|
|
Caller is responsible for calling OsBlockSignal first.
|
|
|
|
*/
|
|
|
|
Bool
|
|
|
|
miPointerSetWaitForUpdate(ScreenPtr pScreen, Bool wait)
|
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
|
|
|
Bool prevWait = pScreenPriv->waitForUpdate;
|
|
|
|
|
|
|
|
pScreenPriv->waitForUpdate = wait;
|
|
|
|
return prevWait;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/* Move the pointer on the current screen, and update the sprite. */
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miPointerPtr pPointer;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
SetupScreen(pScreen);
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer = MIPOINTER(pDev);
|
|
|
|
|
|
|
|
/* Hack: We mustn't call into ->MoveCursor for anything but the
|
|
|
|
* VCP, as this may cause a non-HW rendered cursor to be rendered during
|
|
|
|
* SIGIO. This again leads to allocs during SIGIO which leads to SIGABRT.
|
|
|
|
*/
|
2011-11-05 07:32:40 -06:00
|
|
|
if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer
|
2012-06-10 07:21:05 -06:00
|
|
|
&&!pScreenPriv->waitForUpdate && pScreen == pPointer->pSpriteScreen) {
|
|
|
|
pPointer->devx = x;
|
|
|
|
pPointer->devy = y;
|
|
|
|
if (pPointer->pCursor && !pPointer->pCursor->bits->emptyMask)
|
|
|
|
(*pScreenPriv->spriteFuncs->MoveCursor) (pDev, pScreen, x, y);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer->x = x;
|
|
|
|
pPointer->y = y;
|
|
|
|
pPointer->pScreen = pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Set the devices' cursor position to the given x/y position.
|
|
|
|
*
|
|
|
|
* This function is called during the pointer update path in
|
|
|
|
* GetPointerEvents and friends (and the same in the xwin DDX).
|
|
|
|
*
|
|
|
|
* The coordinates provided are always absolute. The parameter mode whether
|
|
|
|
* it was relative or absolute movement that landed us at those coordinates.
|
|
|
|
*
|
|
|
|
* @param pDev The device to move
|
|
|
|
* @param mode Movement mode (Absolute or Relative)
|
2012-06-10 07:21:05 -06:00
|
|
|
* @param[in,out] screenx The x coordinate in desktop coordinates
|
|
|
|
* @param[in,out] screeny The y coordinate in desktop coordinates
|
2011-11-05 07:32:40 -06:00
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr
|
|
|
|
miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
|
|
|
|
double *screeny)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerScreenPtr pScreenPriv;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
ScreenPtr newScreen;
|
|
|
|
int x, y;
|
|
|
|
Bool switch_screen = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerPtr pPointer;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!pDev || !pDev->coreEvents)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer = MIPOINTER(pDev);
|
|
|
|
pScreen = pPointer->pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pScreen)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL; /* called before ready */
|
|
|
|
|
|
|
|
x = trunc(*screenx);
|
|
|
|
y = trunc(*screeny);
|
|
|
|
|
|
|
|
switch_screen = !point_on_screen(pScreen, x, y);
|
|
|
|
|
|
|
|
/* Switch to per-screen coordinates for CursorOffScreen and
|
|
|
|
* Pointer->limits */
|
|
|
|
x -= pScreen->x;
|
|
|
|
y -= pScreen->y;
|
|
|
|
|
|
|
|
if (switch_screen) {
|
|
|
|
pScreenPriv = GetScreenPrivate(pScreen);
|
|
|
|
if (!pPointer->confined) {
|
|
|
|
newScreen = pScreen;
|
|
|
|
(*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y);
|
|
|
|
if (newScreen != pScreen) {
|
|
|
|
pScreen = newScreen;
|
|
|
|
(*pScreenPriv->screenFuncs->NewEventScreen) (pDev, pScreen,
|
|
|
|
FALSE);
|
|
|
|
/* Smash the confine to the new screen */
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer->limits.x2 = pScreen->width;
|
|
|
|
pPointer->limits.y2 = pScreen->height;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
/* Constrain the sprite to the current limits. */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (x < pPointer->limits.x1)
|
|
|
|
x = pPointer->limits.x1;
|
|
|
|
if (x >= pPointer->limits.x2)
|
|
|
|
x = pPointer->limits.x2 - 1;
|
|
|
|
if (y < pPointer->limits.y1)
|
|
|
|
y = pPointer->limits.y1;
|
|
|
|
if (y >= pPointer->limits.y2)
|
|
|
|
y = pPointer->limits.y2 - 1;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (pScreen->ConstrainCursorHarder)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->ConstrainCursorHarder(pDev, pScreen, mode, &x, &y);
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pPointer->x != x || pPointer->y != y || pPointer->pScreen != pScreen)
|
|
|
|
miPointerMoveNoEvent(pDev, pScreen, x, y);
|
|
|
|
|
|
|
|
/* Convert to desktop coordinates again */
|
|
|
|
x += pScreen->x;
|
|
|
|
y += pScreen->y;
|
|
|
|
|
|
|
|
/* In the event we actually change screen or we get confined, we just
|
|
|
|
* drop the float component on the floor
|
|
|
|
* FIXME: only drop remainder for ConstrainCursorHarder, not for screen
|
|
|
|
* crossings */
|
|
|
|
if (x != trunc(*screenx))
|
|
|
|
*screenx = x;
|
|
|
|
if (y != trunc(*screeny))
|
|
|
|
*screeny = y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Get the current position of the device in desktop coordinates.
|
|
|
|
*
|
|
|
|
* @param x Return value for the current x coordinate in desktop coordiates.
|
|
|
|
* @param y Return value for the current y coordinate in desktop coordiates.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
*x = MIPOINTER(pDev)->x;
|
|
|
|
*y = MIPOINTER(pDev)->y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#ifdef XQUARTZ
|
|
|
|
#include <pthread.h>
|
|
|
|
void darwinEvents_lock(void);
|
|
|
|
void darwinEvents_unlock(void);
|
|
|
|
#endif
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* Move the device's pointer to the x/y coordinates on the given screen.
|
|
|
|
* This function generates and enqueues pointer events.
|
|
|
|
*
|
|
|
|
* @param pDev The device to move
|
|
|
|
* @param pScreen The screen the device is on
|
|
|
|
* @param x The x coordinate in per-screen coordinates
|
|
|
|
* @param y The y coordinate in per-screen coordinates
|
|
|
|
*/
|
2007-11-24 10:55:21 -07:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int i, nevents;
|
|
|
|
int valuators[2];
|
2011-11-05 07:32:40 -06:00
|
|
|
ValuatorMask mask;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
miPointerMoveNoEvent(pDev, pScreen, x, y);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
/* generate motion notify */
|
|
|
|
valuators[0] = x;
|
|
|
|
valuators[1] = y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!events) {
|
2009-09-06 13:44:18 -06:00
|
|
|
events = InitEventList(GetMaximumEventsNum());
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!events) {
|
2007-11-24 10:55:21 -07:00
|
|
|
FatalError("Could not allocate event store.\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
valuator_mask_set_range(&mask, 0, 2, valuators);
|
|
|
|
nevents = GetPointerEvents(events, pDev, MotionNotify, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
POINTER_SCREEN | POINTER_ABSOLUTE |
|
|
|
|
POINTER_NORAW, &mask);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
OsBlockSignals();
|
|
|
|
#ifdef XQUARTZ
|
|
|
|
darwinEvents_lock();
|
|
|
|
#endif
|
2007-11-24 10:55:21 -07:00
|
|
|
for (i = 0; i < nevents; i++)
|
2011-11-05 07:32:40 -06:00
|
|
|
mieqEnqueue(pDev, &events[i]);
|
2009-09-06 13:44:18 -06:00
|
|
|
#ifdef XQUARTZ
|
|
|
|
darwinEvents_unlock();
|
|
|
|
#endif
|
|
|
|
OsReleaseSignals();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|