xserver-multidpi/mi/misprite.c

869 lines
26 KiB
C
Raw Normal View History

2003-11-14 16:54:54 +01:00
/*
* misprite.c
*
* machine independent software sprite routines
*/
/*
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.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "pixmapstr.h"
#include "input.h"
#include "mi.h"
#include "cursorstr.h"
#include <X11/fonts/font.h>
#include "scrnintstr.h"
#include "colormapst.h"
#include "windowstr.h"
#include "gcstruct.h"
#include "mipointer.h"
#include "misprite.h"
#include "dixfontstr.h"
#include <X11/fonts/fontstruct.h>
#include "inputstr.h"
#include "damage.h"
typedef struct {
CursorPtr pCursor;
int x; /* cursor hotspot */
int y;
BoxRec saved; /* saved area from the screen */
Bool isUp; /* cursor in frame buffer */
Bool shouldBeUp; /* cursor should be displayed */
Bool checkPixels; /* check colormap collision */
ScreenPtr pScreen;
} miCursorInfoRec, *miCursorInfoPtr;
/*
* per screen information
*/
typedef struct {
/* screen procedures */
CloseScreenProcPtr CloseScreen;
SourceValidateProcPtr SourceValidate;
/* window procedures */
CopyWindowProcPtr CopyWindow;
/* colormap procedures */
InstallColormapProcPtr InstallColormap;
StoreColorsProcPtr StoreColors;
/* os layer procedures */
ScreenBlockHandlerProcPtr BlockHandler;
xColorItem colors[2];
ColormapPtr pInstalledMap;
ColormapPtr pColormap;
VisualPtr pVisual;
DamagePtr pDamage; /* damage tracking structure */
Bool damageRegistered;
int numberOfCursors;
} miSpriteScreenRec, *miSpriteScreenPtr;
#define SOURCE_COLOR 0
#define MASK_COLOR 1
/*
* Overlap BoxPtr and Box elements
*/
#define BOX_OVERLAP(pCbox,X1,Y1,X2,Y2) \
(((pCbox)->x1 <= (X2)) && ((X1) <= (pCbox)->x2) && \
((pCbox)->y1 <= (Y2)) && ((Y1) <= (pCbox)->y2))
/*
* Overlap BoxPtr, origins, and rectangle
*/
#define ORG_OVERLAP(pCbox,xorg,yorg,x,y,w,h) \
BOX_OVERLAP((pCbox),(x)+(xorg),(y)+(yorg),(x)+(xorg)+(w),(y)+(yorg)+(h))
/*
* Overlap BoxPtr, origins and RectPtr
*/
#define ORGRECT_OVERLAP(pCbox,xorg,yorg,pRect) \
ORG_OVERLAP((pCbox),(xorg),(yorg),(pRect)->x,(pRect)->y, \
(int)((pRect)->width), (int)((pRect)->height))
/*
* Overlap BoxPtr and horizontal span
*/
#define SPN_OVERLAP(pCbox,y,x,w) BOX_OVERLAP((pCbox),(x),(y),(x)+(w),(y))
#define LINE_SORT(x1,y1,x2,y2) \
{ int _t; \
if (x1 > x2) { _t = x1; x1 = x2; x2 = _t; } \
if (y1 > y2) { _t = y1; y1 = y2; y2 = _t; } }
#define LINE_OVERLAP(pCbox,x1,y1,x2,y2,lw2) \
BOX_OVERLAP((pCbox), (x1)-(lw2), (y1)-(lw2), (x2)+(lw2), (y2)+(lw2))
#define SPRITE_DEBUG_ENABLE 0
#if SPRITE_DEBUG_ENABLE
#define SPRITE_DEBUG(x) ErrorF x
#else
#define SPRITE_DEBUG(x)
#endif
2003-11-14 16:54:54 +01:00
static DevPrivateKeyRec miSpriteScreenKeyRec;
static DevPrivateKeyRec miSpriteDevPrivatesKeyRec;
static miSpriteScreenPtr
GetSpriteScreen(ScreenPtr pScreen)
{
return dixLookupPrivate(&pScreen->devPrivates, &miSpriteScreenKeyRec);
}
static miCursorInfoPtr
GetSprite(DeviceIntPtr dev)
{
if (IsFloating(dev))
return dixLookupPrivate(&dev->devPrivates, &miSpriteDevPrivatesKeyRec);
return dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates,
&miSpriteDevPrivatesKeyRec);
}
static void
miSpriteDisableDamage(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
{
if (pScreenPriv->damageRegistered) {
DamageUnregister(pScreenPriv->pDamage);
pScreenPriv->damageRegistered = 0;
}
}
static void
miSpriteEnableDamage(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
{
if (!pScreenPriv->damageRegistered) {
pScreenPriv->damageRegistered = 1;
DamageRegister(&(pScreen->GetScreenPixmap(pScreen)->drawable),
pScreenPriv->pDamage);
}
}
static void
miSpriteIsUp(miCursorInfoPtr pDevCursor)
{
pDevCursor->isUp = TRUE;
}
static void
miSpriteIsDown(miCursorInfoPtr pDevCursor)
{
pDevCursor->isUp = FALSE;
}
2003-11-14 16:54:54 +01:00
/*
* screen wrappers
*/
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
static Bool miSpriteCloseScreen(ScreenPtr pScreen);
static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y,
int width, int height,
unsigned int subWindowMode);
static void miSpriteCopyWindow(WindowPtr pWindow,
DDXPointRec ptOldOrg, RegionPtr prgnSrc);
static void miSpriteBlockHandler(ScreenPtr pScreen, void *timeout);
static void miSpriteInstallColormap(ColormapPtr pMap);
static void miSpriteStoreColors(ColormapPtr pMap, int ndef, xColorItem * pdef);
static void miSpriteComputeSaved(DeviceIntPtr pDev, ScreenPtr pScreen);
static Bool miSpriteDeviceCursorInitialize(DeviceIntPtr pDev,
ScreenPtr pScreen);
static void miSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
#define SCREEN_PROLOGUE(pPriv, pScreen, field) ((pScreen)->field = \
(pPriv)->field)
#define SCREEN_EPILOGUE(pPriv, pScreen, field)\
((pPriv)->field = (pScreen)->field, (pScreen)->field = miSprite##field)
2003-11-14 16:54:54 +01:00
/*
* pointer-sprite method table
*/
static Bool miSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
CursorPtr pCursor);
static Bool miSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
CursorPtr pCursor);
static void miSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
CursorPtr pCursor, int x, int y);
static void miSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
int x, int y);
2003-11-14 16:54:54 +01:00
miPointerSpriteFuncRec miSpritePointerFuncs = {
2003-11-14 16:54:54 +01:00
miSpriteRealizeCursor,
miSpriteUnrealizeCursor,
miSpriteSetCursor,
miSpriteMoveCursor,
miSpriteDeviceCursorInitialize,
miSpriteDeviceCursorCleanup,
2003-11-14 16:54:54 +01:00
};
/*
* other misc functions
*/
static void miSpriteRemoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen);
static void miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen);
static void miSpriteRestoreCursor(DeviceIntPtr pDev, ScreenPtr pScreen);
2003-11-14 16:54:54 +01:00
static void
miSpriteRegisterBlockHandler(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
{
if (!pScreenPriv->BlockHandler) {
pScreenPriv->BlockHandler = pScreen->BlockHandler;
pScreen->BlockHandler = miSpriteBlockHandler;
}
}
static void
miSpriteReportDamage(DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
ScreenPtr pScreen = closure;
miCursorInfoPtr pCursorInfo;
DeviceIntPtr pDev;
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
if (pCursorInfo->isUp &&
pCursorInfo->pScreen == pScreen &&
RegionContainsRect(pRegion, &pCursorInfo->saved) != rgnOUT) {
SPRITE_DEBUG(("Damage remove\n"));
miSpriteRemoveCursor(pDev, pScreen);
}
}
}
}
2003-11-14 16:54:54 +01:00
/*
* miSpriteInitialize -- called from device-dependent screen
* initialization proc after all of the function pointers have
* been stored in the screen structure.
*/
Bool
miSpriteInitialize(ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs)
2003-11-14 16:54:54 +01:00
{
miSpriteScreenPtr pScreenPriv;
VisualPtr pVisual;
if (!DamageSetup(pScreen))
return FALSE;
if (!dixRegisterPrivateKey(&miSpriteScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey
(&miSpriteDevPrivatesKeyRec, PRIVATE_DEVICE, sizeof(miCursorInfoRec)))
return FALSE;
pScreenPriv = malloc(sizeof(miSpriteScreenRec));
if (!pScreenPriv)
return FALSE;
pScreenPriv->pDamage = DamageCreate(miSpriteReportDamage,
NULL,
DamageReportRawRegion,
TRUE, pScreen, pScreen);
if (!miPointerInitialize(pScreen, &miSpritePointerFuncs, screenFuncs, TRUE)) {
free(pScreenPriv);
return FALSE;
2003-11-14 16:54:54 +01:00
}
for (pVisual = pScreen->visuals;
pVisual->vid != pScreen->rootVisual; pVisual++);
pScreenPriv->pVisual = pVisual;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->SourceValidate = pScreen->SourceValidate;
pScreenPriv->CopyWindow = pScreen->CopyWindow;
pScreenPriv->InstallColormap = pScreen->InstallColormap;
pScreenPriv->StoreColors = pScreen->StoreColors;
pScreenPriv->BlockHandler = NULL;
pScreenPriv->pInstalledMap = NULL;
pScreenPriv->pColormap = NULL;
pScreenPriv->colors[SOURCE_COLOR].red = 0;
pScreenPriv->colors[SOURCE_COLOR].green = 0;
pScreenPriv->colors[SOURCE_COLOR].blue = 0;
pScreenPriv->colors[MASK_COLOR].red = 0;
pScreenPriv->colors[MASK_COLOR].green = 0;
pScreenPriv->colors[MASK_COLOR].blue = 0;
pScreenPriv->damageRegistered = 0;
pScreenPriv->numberOfCursors = 0;
dixSetPrivate(&pScreen->devPrivates, &miSpriteScreenKeyRec, pScreenPriv);
2003-11-14 16:54:54 +01:00
pScreen->CloseScreen = miSpriteCloseScreen;
pScreen->SourceValidate = miSpriteSourceValidate;
2003-11-14 16:54:54 +01:00
pScreen->CopyWindow = miSpriteCopyWindow;
pScreen->InstallColormap = miSpriteInstallColormap;
pScreen->StoreColors = miSpriteStoreColors;
2003-11-14 16:54:54 +01:00
return TRUE;
}
/*
* Screen wrappers
*/
/*
* CloseScreen wrapper -- unwrap everything, free the private data
* and call the wrapped function
*/
static Bool
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
miSpriteCloseScreen(ScreenPtr pScreen)
2003-11-14 16:54:54 +01:00
{
miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen);
2003-11-14 16:54:54 +01:00
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->SourceValidate = pScreenPriv->SourceValidate;
pScreen->InstallColormap = pScreenPriv->InstallColormap;
pScreen->StoreColors = pScreenPriv->StoreColors;
DamageDestroy(pScreenPriv->pDamage);
free(pScreenPriv);
2003-11-14 16:54:54 +01:00
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
return (*pScreen->CloseScreen) (pScreen);
2003-11-14 16:54:54 +01:00
}
static void
miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, int width,
int height, unsigned int subWindowMode)
2003-11-14 16:54:54 +01:00
{
ScreenPtr pScreen = pDrawable->pScreen;
DeviceIntPtr pDev;
miCursorInfoPtr pCursorInfo;
miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen);
SCREEN_PROLOGUE(pPriv, pScreen, SourceValidate);
if (pDrawable->type == DRAWABLE_WINDOW) {
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen &&
ORG_OVERLAP(&pCursorInfo->saved, pDrawable->x, pDrawable->y,
x, y, width, height)) {
SPRITE_DEBUG(("SourceValidate remove\n"));
miSpriteRemoveCursor(pDev, pScreen);
}
}
}
2003-11-14 16:54:54 +01:00
}
(*pScreen->SourceValidate) (pDrawable, x, y, width, height,
subWindowMode);
2003-11-14 16:54:54 +01:00
SCREEN_EPILOGUE(pPriv, pScreen, SourceValidate);
2003-11-14 16:54:54 +01:00
}
static void
miSpriteCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
2003-11-14 16:54:54 +01:00
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DeviceIntPtr pDev;
miCursorInfoPtr pCursorInfo;
miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen);
SCREEN_PROLOGUE(pPriv, pScreen, CopyWindow);
2003-11-14 16:54:54 +01:00
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
/*
* Damage will take care of destination check
*/
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen &&
RegionContainsRect(prgnSrc, &pCursorInfo->saved) != rgnOUT) {
SPRITE_DEBUG(("CopyWindow remove\n"));
miSpriteRemoveCursor(pDev, pScreen);
}
}
}
2003-11-14 16:54:54 +01:00
(*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
SCREEN_EPILOGUE(pPriv, pScreen, CopyWindow);
2003-11-14 16:54:54 +01:00
}
static void
miSpriteBlockHandler(ScreenPtr pScreen, void *timeout)
2003-11-14 16:54:54 +01:00
{
miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen);
DeviceIntPtr pDev;
miCursorInfoPtr pCursorInfo;
Bool WorkToDo = FALSE;
SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
if (pCursorInfo && !pCursorInfo->isUp
&& pCursorInfo->pScreen == pScreen && pCursorInfo->shouldBeUp) {
SPRITE_DEBUG(("BlockHandler save"));
miSpriteSaveUnderCursor(pDev, pScreen);
2007-01-29 06:40:03 +01:00
}
}
}
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
if (pCursorInfo && !pCursorInfo->isUp &&
pCursorInfo->pScreen == pScreen && pCursorInfo->shouldBeUp) {
SPRITE_DEBUG(("BlockHandler restore\n"));
miSpriteRestoreCursor(pDev, pScreen);
if (!pCursorInfo->isUp)
WorkToDo = TRUE;
}
}
}
(*pScreen->BlockHandler) (pScreen, timeout);
if (WorkToDo)
SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
else
pPriv->BlockHandler = NULL;
2003-11-14 16:54:54 +01:00
}
static void
miSpriteInstallColormap(ColormapPtr pMap)
2003-11-14 16:54:54 +01:00
{
ScreenPtr pScreen = pMap->pScreen;
miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen);
2003-11-14 16:54:54 +01:00
SCREEN_PROLOGUE(pPriv, pScreen, InstallColormap);
2003-11-14 16:54:54 +01:00
(*pScreen->InstallColormap) (pMap);
SCREEN_EPILOGUE(pPriv, pScreen, InstallColormap);
2003-11-14 16:54:54 +01:00
/* InstallColormap can be called before devices are initialized. */
pPriv->pInstalledMap = pMap;
if (pPriv->pColormap != pMap) {
DeviceIntPtr pDev;
miCursorInfoPtr pCursorInfo;
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
pCursorInfo->checkPixels = TRUE;
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen)
miSpriteRemoveCursor(pDev, pScreen);
}
}
}
2003-11-14 16:54:54 +01:00
}
static void
miSpriteStoreColors(ColormapPtr pMap, int ndef, xColorItem * pdef)
2003-11-14 16:54:54 +01:00
{
ScreenPtr pScreen = pMap->pScreen;
miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen);
int i;
int updated;
VisualPtr pVisual;
DeviceIntPtr pDev;
miCursorInfoPtr pCursorInfo;
2003-11-14 16:54:54 +01:00
SCREEN_PROLOGUE(pPriv, pScreen, StoreColors);
2003-11-14 16:54:54 +01:00
(*pScreen->StoreColors) (pMap, ndef, pdef);
SCREEN_EPILOGUE(pPriv, pScreen, StoreColors);
2003-11-14 16:54:54 +01:00
if (pPriv->pColormap == pMap) {
updated = 0;
pVisual = pMap->pVisual;
if (pVisual->class == DirectColor) {
/* Direct color - match on any of the subfields */
2003-11-14 17:49:22 +01:00
#define MaskMatch(a,b,mask) (((a) & (pVisual->mask)) == ((b) & (pVisual->mask)))
2003-11-14 16:54:54 +01:00
#define UpdateDAC(dev, plane,dac,mask) {\
if (MaskMatch (dev->colors[plane].pixel,pdef[i].pixel,mask)) {\
dev->colors[plane].dac = pdef[i].dac; \
2003-11-14 16:54:54 +01:00
updated = 1; \
} \
}
#define CheckDirect(dev, plane) \
UpdateDAC(dev, plane,red,redMask) \
UpdateDAC(dev, plane,green,greenMask) \
UpdateDAC(dev, plane,blue,blueMask)
2003-11-14 16:54:54 +01:00
for (i = 0; i < ndef; i++) {
CheckDirect(pPriv, SOURCE_COLOR)
CheckDirect(pPriv, MASK_COLOR)
}
}
else {
/* PseudoColor/GrayScale - match on exact pixel */
for (i = 0; i < ndef; i++) {
if (pdef[i].pixel == pPriv->colors[SOURCE_COLOR].pixel) {
pPriv->colors[SOURCE_COLOR] = pdef[i];
if (++updated == 2)
break;
}
if (pdef[i].pixel == pPriv->colors[MASK_COLOR].pixel) {
pPriv->colors[MASK_COLOR] = pdef[i];
if (++updated == 2)
break;
}
}
}
if (updated) {
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (DevHasCursor(pDev)) {
pCursorInfo = GetSprite(pDev);
pCursorInfo->checkPixels = TRUE;
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen)
miSpriteRemoveCursor(pDev, pScreen);
}
}
}
}
2003-11-14 16:54:54 +01:00
}
static void
miSpriteFindColors(miCursorInfoPtr pDevCursor, ScreenPtr pScreen)
2003-11-14 16:54:54 +01:00
{
miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen);
CursorPtr pCursor;
xColorItem *sourceColor, *maskColor;
2003-11-14 16:54:54 +01:00
pCursor = pDevCursor->pCursor;
sourceColor = &pScreenPriv->colors[SOURCE_COLOR];
maskColor = &pScreenPriv->colors[MASK_COLOR];
if (pScreenPriv->pColormap != pScreenPriv->pInstalledMap ||
!(pCursor->foreRed == sourceColor->red &&
pCursor->foreGreen == sourceColor->green &&
2003-11-14 16:54:54 +01:00
pCursor->foreBlue == sourceColor->blue &&
pCursor->backRed == maskColor->red &&
pCursor->backGreen == maskColor->green &&
pCursor->backBlue == maskColor->blue)) {
pScreenPriv->pColormap = pScreenPriv->pInstalledMap;
sourceColor->red = pCursor->foreRed;
sourceColor->green = pCursor->foreGreen;
sourceColor->blue = pCursor->foreBlue;
FakeAllocColor(pScreenPriv->pColormap, sourceColor);
maskColor->red = pCursor->backRed;
maskColor->green = pCursor->backGreen;
maskColor->blue = pCursor->backBlue;
FakeAllocColor(pScreenPriv->pColormap, maskColor);
/* "free" the pixels right away, don't let this confuse you */
FakeFreeColor(pScreenPriv->pColormap, sourceColor->pixel);
FakeFreeColor(pScreenPriv->pColormap, maskColor->pixel);
2003-11-14 16:54:54 +01:00
}
pDevCursor->checkPixels = FALSE;
2003-11-14 16:54:54 +01:00
}
/*
* miPointer interface routines
2003-11-14 16:54:54 +01:00
*/
#define SPRITE_PAD 8
2003-11-14 16:54:54 +01:00
static Bool
miSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
2003-11-14 16:54:54 +01:00
{
miCursorInfoPtr pCursorInfo;
2003-11-14 16:54:54 +01:00
if (IsFloating(pDev))
return FALSE;
pCursorInfo = GetSprite(pDev);
if (pCursor == pCursorInfo->pCursor)
pCursorInfo->checkPixels = TRUE;
return miDCRealizeCursor(pScreen, pCursor);
2003-11-14 16:54:54 +01:00
}
static Bool
2008-05-28 04:57:07 +02:00
miSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
2003-11-14 16:54:54 +01:00
{
return miDCUnrealizeCursor(pScreen, pCursor);
2003-11-14 16:54:54 +01:00
}
static void
miSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
CursorPtr pCursor, int x, int y)
2003-11-14 16:54:54 +01:00
{
miCursorInfoPtr pPointer;
miSpriteScreenPtr pScreenPriv;
2003-11-14 16:54:54 +01:00
if (IsFloating(pDev))
return;
pPointer = GetSprite(pDev);
pScreenPriv = GetSpriteScreen(pScreen);
if (!pCursor) {
if (pPointer->shouldBeUp)
--pScreenPriv->numberOfCursors;
pPointer->shouldBeUp = FALSE;
if (pPointer->isUp)
miSpriteRemoveCursor(pDev, pScreen);
if (pScreenPriv->numberOfCursors == 0)
miSpriteDisableDamage(pScreen, pScreenPriv);
pPointer->pCursor = 0;
return;
2003-11-14 16:54:54 +01:00
}
if (!pPointer->shouldBeUp)
pScreenPriv->numberOfCursors++;
pPointer->shouldBeUp = TRUE;
if (!pPointer->isUp)
miSpriteRegisterBlockHandler(pScreen, pScreenPriv);
if (pPointer->x == x &&
pPointer->y == y &&
pPointer->pCursor == pCursor && !pPointer->checkPixels) {
return;
2003-11-14 16:54:54 +01:00
}
pPointer->x = x;
pPointer->y = y;
if (pPointer->checkPixels || pPointer->pCursor != pCursor) {
pPointer->pCursor = pCursor;
miSpriteFindColors(pPointer, pScreen);
}
if (pPointer->isUp) {
/* TODO: reimplement flicker-free MoveCursor */
SPRITE_DEBUG(("SetCursor remove %d\n", pDev->id));
miSpriteRemoveCursor(pDev, pScreen);
2003-11-14 16:54:54 +01:00
}
if (!pPointer->isUp && pPointer->pCursor) {
SPRITE_DEBUG(("SetCursor restore %d\n", pDev->id));
2007-01-29 06:40:03 +01:00
miSpriteSaveUnderCursor(pDev, pScreen);
miSpriteRestoreCursor(pDev, pScreen);
}
2003-11-14 16:54:54 +01:00
}
static void
miSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
2003-11-14 16:54:54 +01:00
{
CursorPtr pCursor;
2003-11-14 16:54:54 +01:00
if (IsFloating(pDev))
return;
pCursor = GetSprite(pDev)->pCursor;
miSpriteSetCursor(pDev, pScreen, pCursor, x, y);
}
static Bool
2008-05-28 04:57:07 +02:00
miSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
int ret = miDCDeviceInitialize(pDev, pScreen);
if (ret) {
miCursorInfoPtr pCursorInfo;
pCursorInfo =
dixLookupPrivate(&pDev->devPrivates, &miSpriteDevPrivatesKeyRec);
pCursorInfo->pCursor = NULL;
pCursorInfo->x = 0;
pCursorInfo->y = 0;
pCursorInfo->isUp = FALSE;
pCursorInfo->shouldBeUp = FALSE;
pCursorInfo->checkPixels = TRUE;
pCursorInfo->pScreen = FALSE;
}
return ret;
}
static void
2008-05-28 04:57:07 +02:00
miSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
{
miCursorInfoPtr pCursorInfo =
dixLookupPrivate(&pDev->devPrivates, &miSpriteDevPrivatesKeyRec);
if (DevHasCursor(pDev))
miDCDeviceCleanup(pDev, pScreen);
memset(pCursorInfo, 0, sizeof(miCursorInfoRec));
}
2003-11-14 16:54:54 +01:00
/*
* undraw/draw cursor
*/
static void
miSpriteRemoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
2003-11-14 16:54:54 +01:00
{
miSpriteScreenPtr pScreenPriv;
miCursorInfoPtr pCursorInfo;
2003-11-14 16:54:54 +01:00
if (IsFloating(pDev))
return;
DamageDrawInternal(pScreen, TRUE);
pScreenPriv = GetSpriteScreen(pScreen);
pCursorInfo = GetSprite(pDev);
miSpriteIsDown(pCursorInfo);
miSpriteRegisterBlockHandler(pScreen, pScreenPriv);
2007-01-29 06:40:03 +01:00
miSpriteDisableDamage(pScreen, pScreenPriv);
if (!miDCRestoreUnderCursor(pDev,
pScreen,
pCursorInfo->saved.x1,
pCursorInfo->saved.y1,
pCursorInfo->saved.x2 -
pCursorInfo->saved.x1,
pCursorInfo->saved.y2 -
pCursorInfo->saved.y1)) {
miSpriteIsUp(pCursorInfo);
2003-11-14 16:54:54 +01:00
}
2007-01-29 06:40:03 +01:00
miSpriteEnableDamage(pScreen, pScreenPriv);
DamageDrawInternal(pScreen, FALSE);
2003-11-14 16:54:54 +01:00
}
/*
2007-01-29 06:40:03 +01:00
* Called from the block handler, saves area under cursor
2003-11-14 16:54:54 +01:00
* before waiting for something to do.
*/
2008-05-28 04:57:07 +02:00
static void
miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
2003-11-14 16:54:54 +01:00
{
miSpriteScreenPtr pScreenPriv;
miCursorInfoPtr pCursorInfo;
2003-11-14 16:54:54 +01:00
if (IsFloating(pDev))
return;
DamageDrawInternal(pScreen, TRUE);
pScreenPriv = GetSpriteScreen(pScreen);
pCursorInfo = GetSprite(pDev);
miSpriteComputeSaved(pDev, pScreen);
2007-01-29 06:40:03 +01:00
miSpriteDisableDamage(pScreen, pScreenPriv);
miDCSaveUnderCursor(pDev,
pScreen,
pCursorInfo->saved.x1,
pCursorInfo->saved.y1,
pCursorInfo->saved.x2 -
pCursorInfo->saved.x1,
pCursorInfo->saved.y2 - pCursorInfo->saved.y1);
2007-01-29 06:40:03 +01:00
SPRITE_DEBUG(("SaveUnderCursor %d\n", pDev->id));
miSpriteEnableDamage(pScreen, pScreenPriv);
DamageDrawInternal(pScreen, FALSE);
2007-01-29 06:40:03 +01:00
}
/*
* Called from the block handler, restores the cursor
* before waiting for something to do.
*/
static void
miSpriteRestoreCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
2007-01-29 06:40:03 +01:00
{
miSpriteScreenPtr pScreenPriv;
int x, y;
CursorPtr pCursor;
miCursorInfoPtr pCursorInfo;
if (IsFloating(pDev))
return;
2007-01-29 06:40:03 +01:00
DamageDrawInternal(pScreen, TRUE);
pScreenPriv = GetSpriteScreen(pScreen);
pCursorInfo = GetSprite(pDev);
2007-01-29 06:40:03 +01:00
miSpriteComputeSaved(pDev, pScreen);
2007-01-29 06:40:03 +01:00
pCursor = pCursorInfo->pCursor;
x = pCursorInfo->x - (int) pCursor->bits->xhot;
y = pCursorInfo->y - (int) pCursor->bits->yhot;
2007-01-29 06:40:03 +01:00
miSpriteDisableDamage(pScreen, pScreenPriv);
SPRITE_DEBUG(("RestoreCursor %d\n", pDev->id));
if (pCursorInfo->checkPixels)
miSpriteFindColors(pCursorInfo, pScreen);
if (miDCPutUpCursor(pDev, pScreen,
pCursor, x, y,
pScreenPriv->colors[SOURCE_COLOR].pixel,
pScreenPriv->colors[MASK_COLOR].pixel)) {
miSpriteIsUp(pCursorInfo);
pCursorInfo->pScreen = pScreen;
2003-11-14 16:54:54 +01:00
}
2007-01-29 06:40:03 +01:00
miSpriteEnableDamage(pScreen, pScreenPriv);
DamageDrawInternal(pScreen, FALSE);
2003-11-14 16:54:54 +01:00
}
/*
* compute the desired area of the screen to save
*/
static void
miSpriteComputeSaved(DeviceIntPtr pDev, ScreenPtr pScreen)
2003-11-14 16:54:54 +01:00
{
int x, y, w, h;
int wpad, hpad;
CursorPtr pCursor;
miCursorInfoPtr pCursorInfo;
2003-11-14 16:54:54 +01:00
if (IsFloating(pDev))
return;
pCursorInfo = GetSprite(pDev);
pCursor = pCursorInfo->pCursor;
x = pCursorInfo->x - (int) pCursor->bits->xhot;
y = pCursorInfo->y - (int) pCursor->bits->yhot;
2003-11-14 16:54:54 +01:00
w = pCursor->bits->width;
h = pCursor->bits->height;
wpad = SPRITE_PAD;
hpad = SPRITE_PAD;
pCursorInfo->saved.x1 = x - wpad;
pCursorInfo->saved.y1 = y - hpad;
pCursorInfo->saved.x2 = pCursorInfo->saved.x1 + w + wpad * 2;
pCursorInfo->saved.y2 = pCursorInfo->saved.y1 + h + hpad * 2;
2003-11-14 16:54:54 +01:00
}