2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* midispcur.c
|
|
|
|
*
|
|
|
|
* machine independent cursor display 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.
|
|
|
|
*/
|
|
|
|
|
2005-08-21 21:29:55 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
# include <X11/X.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
# include "misc.h"
|
|
|
|
# include "input.h"
|
|
|
|
# include "cursorstr.h"
|
|
|
|
# include "windowstr.h"
|
|
|
|
# include "regionstr.h"
|
|
|
|
# include "dixstruct.h"
|
|
|
|
# include "scrnintstr.h"
|
|
|
|
# include "servermd.h"
|
|
|
|
# include "mipointer.h"
|
|
|
|
# include "misprite.h"
|
|
|
|
# include "gcstruct.h"
|
2005-07-03 09:02:09 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
# include "picturestr.h"
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2009-07-06 03:04:47 +02:00
|
|
|
# include "inputstr.h"
|
2006-11-21 01:56:21 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* per-screen private data */
|
2010-04-27 02:22:21 +02:00
|
|
|
static DevPrivateKeyRec miDCScreenKeyRec;
|
|
|
|
#define miDCScreenKey (&miDCScreenKeyRec)
|
2010-09-17 02:11:44 +02:00
|
|
|
static DevScreenPrivateKeyRec miDCCursorBitsKeyRec;
|
|
|
|
#define miDCCursorBitsKey (&miDCCursorBitsKeyRec)
|
|
|
|
static DevScreenPrivateKeyRec miDCDeviceKeyRec;
|
|
|
|
#define miDCDeviceKey (&miDCDeviceKeyRec)
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
static Bool miDCCloseScreen(int index, ScreenPtr pScreen);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2010-05-01 04:38:48 +02:00
|
|
|
/* per device private data */
|
2003-11-14 16:54:54 +01:00
|
|
|
typedef struct {
|
|
|
|
GCPtr pSourceGC, pMaskGC;
|
|
|
|
GCPtr pSaveGC, pRestoreGC;
|
2010-05-25 03:41:54 +02:00
|
|
|
PixmapPtr pSave;
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
PicturePtr pRootPicture;
|
|
|
|
#endif
|
2006-11-21 01:56:21 +01:00
|
|
|
} miDCBufferRec, *miDCBufferPtr;
|
|
|
|
|
2010-05-01 07:05:27 +02:00
|
|
|
#define miGetDCDevice(dev, screen) \
|
2007-04-09 12:01:59 +02:00
|
|
|
((DevHasCursor(dev)) ? \
|
2010-09-17 02:11:44 +02:00
|
|
|
(miDCBufferPtr)dixLookupScreenPrivate(&dev->devPrivates, miDCDeviceKey, screen) : \
|
2011-02-18 02:57:06 +01:00
|
|
|
(miDCBufferPtr)dixLookupScreenPrivate(&GetMaster(dev, MASTER_POINTER)->devPrivates, miDCDeviceKey, screen))
|
2007-04-09 12:01:59 +02:00
|
|
|
|
2006-12-14 01:20:18 +01:00
|
|
|
/*
|
|
|
|
* The core pointer buffer will point to the index of the virtual core pointer
|
|
|
|
* in the pCursorBuffers array.
|
|
|
|
*/
|
2006-11-21 01:56:21 +01:00
|
|
|
typedef struct {
|
2010-05-01 04:38:48 +02:00
|
|
|
CloseScreenProcPtr CloseScreen;
|
2003-11-14 16:54:54 +01:00
|
|
|
} miDCScreenRec, *miDCScreenPtr;
|
|
|
|
|
2010-05-01 04:38:48 +02:00
|
|
|
#define miGetDCScreen(s) ((miDCScreenPtr)(dixLookupPrivate(&(s)->devPrivates, miDCScreenKey)))
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* per-cursor per-screen private data */
|
|
|
|
typedef struct {
|
|
|
|
PixmapPtr sourceBits; /* source bits */
|
|
|
|
PixmapPtr maskBits; /* mask bits */
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
PicturePtr pPicture;
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
} miDCCursorRec, *miDCCursorPtr;
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCScreenPtr pScreenPriv;
|
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0) ||
|
|
|
|
!dixRegisterScreenPrivateKey(&miDCCursorBitsKeyRec, pScreen, PRIVATE_CURSOR_BITS, 0) ||
|
|
|
|
!dixRegisterScreenPrivateKey(&miDCDeviceKeyRec, pScreen, PRIVATE_DEVICE, 0))
|
2010-04-27 02:22:21 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
pScreenPriv = malloc(sizeof (miDCScreenRec));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pScreenPriv)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
|
|
|
pScreen->CloseScreen = miDCCloseScreen;
|
2008-01-03 07:34:54 +01:00
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, pScreenPriv);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
if (!miSpriteInitialize (pScreen, screenFuncs))
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pScreenPriv);
|
2003-11-14 16:54:54 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCCloseScreen (int index, ScreenPtr pScreen)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCScreenPtr pScreenPriv;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miDCScreenKey);
|
2003-11-14 16:54:54 +01:00
|
|
|
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pScreenPriv);
|
2003-11-14 16:54:54 +01:00
|
|
|
return (*pScreen->CloseScreen) (index, pScreen);
|
|
|
|
}
|
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (pCursor->bits->refcnt <= 1)
|
2010-09-17 02:11:44 +02:00
|
|
|
dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, NULL);
|
2003-11-14 16:54:54 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
2010-05-24 18:15:32 +02:00
|
|
|
#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
static VisualPtr
|
|
|
|
miDCGetWindowVisual (WindowPtr pWin)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
VisualID vid = wVisual (pWin);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < pScreen->numVisuals; i++)
|
|
|
|
if (pScreen->visuals[i].vid == vid)
|
|
|
|
return &pScreen->visuals[i];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PicturePtr
|
|
|
|
miDCMakePicture (PicturePtr *ppPicture, DrawablePtr pDraw, WindowPtr pWin)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
PictFormatPtr pFormat;
|
|
|
|
XID subwindow_mode = IncludeInferiors;
|
|
|
|
PicturePtr pPicture;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
pVisual = miDCGetWindowVisual (pWin);
|
|
|
|
if (!pVisual)
|
|
|
|
return 0;
|
|
|
|
pFormat = PictureMatchVisual (pScreen, pDraw->depth, pVisual);
|
|
|
|
if (!pFormat)
|
|
|
|
return 0;
|
|
|
|
pPicture = CreatePicture (0, pDraw, pFormat,
|
|
|
|
CPSubwindowMode, &subwindow_mode,
|
|
|
|
serverClient, &error);
|
|
|
|
*ppPicture = pPicture;
|
|
|
|
return pPicture;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
static miDCCursorPtr
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCRealize (ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCCursorPtr pPriv;
|
|
|
|
GCPtr pGC;
|
2010-05-08 23:10:51 +02:00
|
|
|
ChangeGCVal gcvals;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
pPriv = malloc(sizeof (miDCCursorRec));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pPriv)
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
if (pCursor->bits->argb)
|
|
|
|
{
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
PictFormatPtr pFormat;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
|
|
|
|
if (!pFormat)
|
|
|
|
{
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pPriv->sourceBits = 0;
|
|
|
|
pPriv->maskBits = 0;
|
|
|
|
pPixmap = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width,
|
2007-10-31 22:15:35 +01:00
|
|
|
pCursor->bits->height, 32,
|
|
|
|
CREATE_PIXMAP_USAGE_SCRATCH);
|
2003-11-14 17:49:22 +01:00
|
|
|
if (!pPixmap)
|
|
|
|
{
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
pGC = GetScratchGC (32, pScreen);
|
|
|
|
if (!pGC)
|
|
|
|
{
|
|
|
|
(*pScreen->DestroyPixmap) (pPixmap);
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
ValidateGC (&pPixmap->drawable, pGC);
|
|
|
|
(*pGC->ops->PutImage) (&pPixmap->drawable, pGC, 32,
|
|
|
|
0, 0, pCursor->bits->width,
|
|
|
|
pCursor->bits->height,
|
|
|
|
0, ZPixmap, (char *) pCursor->bits->argb);
|
|
|
|
FreeScratchGC (pGC);
|
|
|
|
pPriv->pPicture = CreatePicture (0, &pPixmap->drawable,
|
|
|
|
pFormat, 0, 0, serverClient, &error);
|
|
|
|
(*pScreen->DestroyPixmap) (pPixmap);
|
|
|
|
if (!pPriv->pPicture)
|
|
|
|
{
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2010-09-17 02:11:44 +02:00
|
|
|
dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, pPriv);
|
2003-11-14 17:49:22 +01:00
|
|
|
return pPriv;
|
|
|
|
}
|
|
|
|
pPriv->pPicture = 0;
|
|
|
|
#endif
|
2007-10-31 22:15:35 +01:00
|
|
|
pPriv->sourceBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pPriv->sourceBits)
|
|
|
|
{
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2007-10-31 22:15:35 +01:00
|
|
|
pPriv->maskBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pPriv->maskBits)
|
|
|
|
{
|
|
|
|
(*pScreen->DestroyPixmap) (pPriv->sourceBits);
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2010-09-17 02:11:44 +02:00
|
|
|
dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, pPriv);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/* create the two sets of bits, clipping as appropriate */
|
|
|
|
|
|
|
|
pGC = GetScratchGC (1, pScreen);
|
|
|
|
if (!pGC)
|
|
|
|
{
|
|
|
|
(void) miDCUnrealizeCursor (pScreen, pCursor);
|
2009-01-22 08:11:16 +01:00
|
|
|
return NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ValidateGC ((DrawablePtr)pPriv->sourceBits, pGC);
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr)pPriv->sourceBits, pGC, 1,
|
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
0, XYPixmap, (char *)pCursor->bits->source);
|
2010-05-08 23:10:51 +02:00
|
|
|
gcvals.val = GXand;
|
2010-05-08 04:38:05 +02:00
|
|
|
ChangeGC (NullClient, pGC, GCFunction, &gcvals);
|
2003-11-14 16:54:54 +01:00
|
|
|
ValidateGC ((DrawablePtr)pPriv->sourceBits, pGC);
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr)pPriv->sourceBits, pGC, 1,
|
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
0, XYPixmap, (char *)pCursor->bits->mask);
|
|
|
|
|
|
|
|
/* mask bits -- pCursor->mask & ~pCursor->source */
|
2010-05-08 23:10:51 +02:00
|
|
|
gcvals.val = GXcopy;
|
2010-05-08 04:38:05 +02:00
|
|
|
ChangeGC (NullClient, pGC, GCFunction, &gcvals);
|
2003-11-14 16:54:54 +01:00
|
|
|
ValidateGC ((DrawablePtr)pPriv->maskBits, pGC);
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr)pPriv->maskBits, pGC, 1,
|
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
0, XYPixmap, (char *)pCursor->bits->mask);
|
2010-05-08 23:10:51 +02:00
|
|
|
gcvals.val = GXandInverted;
|
2010-05-08 04:38:05 +02:00
|
|
|
ChangeGC (NullClient, pGC, GCFunction, &gcvals);
|
2003-11-14 16:54:54 +01:00
|
|
|
ValidateGC ((DrawablePtr)pPriv->maskBits, pGC);
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr)pPriv->maskBits, pGC, 1,
|
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
0, XYPixmap, (char *)pCursor->bits->source);
|
|
|
|
FreeScratchGC (pGC);
|
|
|
|
return pPriv;
|
|
|
|
}
|
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCCursorPtr pPriv;
|
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
pPriv = (miDCCursorPtr)dixLookupScreenPrivate(&pCursor->bits->devPrivates,
|
|
|
|
miDCCursorBitsKey, pScreen);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pPriv && (pCursor->bits->refcnt <= 1))
|
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
if (pPriv->sourceBits)
|
|
|
|
(*pScreen->DestroyPixmap) (pPriv->sourceBits);
|
|
|
|
if (pPriv->maskBits)
|
|
|
|
(*pScreen->DestroyPixmap) (pPriv->maskBits);
|
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
if (pPriv->pPicture)
|
|
|
|
FreePicture (pPriv->pPicture, 0);
|
|
|
|
#endif
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pPriv);
|
2010-09-17 02:11:44 +02:00
|
|
|
dixSetScreenPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey, pScreen, NULL);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-14 17:49:22 +01:00
|
|
|
miDCPutBits (
|
|
|
|
DrawablePtr pDrawable,
|
|
|
|
miDCCursorPtr pPriv,
|
|
|
|
GCPtr sourceGC,
|
|
|
|
GCPtr maskGC,
|
2003-11-25 20:29:01 +01:00
|
|
|
int x_org,
|
|
|
|
int y_org,
|
2003-11-14 17:49:22 +01:00
|
|
|
unsigned w,
|
|
|
|
unsigned h,
|
|
|
|
unsigned long source,
|
|
|
|
unsigned long mask)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-05-08 23:10:51 +02:00
|
|
|
ChangeGCVal gcval;
|
2003-11-25 20:29:01 +01:00
|
|
|
int x, y;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
if (sourceGC->fgPixel != source)
|
|
|
|
{
|
2010-05-08 23:10:51 +02:00
|
|
|
gcval.val = source;
|
2010-05-08 04:38:05 +02:00
|
|
|
ChangeGC (NullClient, sourceGC, GCForeground, &gcval);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
if (sourceGC->serialNumber != pDrawable->serialNumber)
|
|
|
|
ValidateGC (pDrawable, sourceGC);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
if(sourceGC->miTranslate)
|
|
|
|
{
|
|
|
|
x = pDrawable->x + x_org;
|
|
|
|
y = pDrawable->y + y_org;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = x_org;
|
|
|
|
y = y_org;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
(*sourceGC->ops->PushPixels) (sourceGC, pPriv->sourceBits, pDrawable, w, h, x, y);
|
|
|
|
if (maskGC->fgPixel != mask)
|
|
|
|
{
|
2010-05-08 23:10:51 +02:00
|
|
|
gcval.val = mask;
|
2010-05-08 04:38:05 +02:00
|
|
|
ChangeGC (NullClient, maskGC, GCForeground, &gcval);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
if (maskGC->serialNumber != pDrawable->serialNumber)
|
|
|
|
ValidateGC (pDrawable, maskGC);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
if(maskGC->miTranslate)
|
|
|
|
{
|
|
|
|
x = pDrawable->x + x_org;
|
|
|
|
y = pDrawable->y + y_org;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = x_org;
|
|
|
|
y = y_org;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
(*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GCPtr
|
2010-04-22 01:46:17 +02:00
|
|
|
miDCMakeGC(WindowPtr pWin)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
GCPtr pGC;
|
|
|
|
int status;
|
|
|
|
XID gcvals[2];
|
|
|
|
|
|
|
|
gcvals[0] = IncludeInferiors;
|
|
|
|
gcvals[1] = FALSE;
|
|
|
|
pGC = CreateGC((DrawablePtr)pWin,
|
2007-08-14 19:09:38 +02:00
|
|
|
GCSubwindowMode|GCGraphicsExposures, gcvals, &status,
|
|
|
|
(XID)0, serverClient);
|
2003-11-14 16:54:54 +01:00
|
|
|
return pGC;
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
|
|
|
|
int x, int y, unsigned long source, unsigned long mask)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCScreenPtr pScreenPriv;
|
|
|
|
miDCCursorPtr pPriv;
|
2006-11-21 04:30:46 +01:00
|
|
|
miDCBufferPtr pBuffer;
|
2003-11-14 16:54:54 +01:00
|
|
|
WindowPtr pWin;
|
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
pPriv = (miDCCursorPtr)dixLookupScreenPrivate(&pCursor->bits->devPrivates,
|
|
|
|
miDCCursorBitsKey, pScreen);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pPriv)
|
|
|
|
{
|
|
|
|
pPriv = miDCRealize(pScreen, pCursor);
|
|
|
|
if (!pPriv)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-08-28 15:28:25 +02:00
|
|
|
pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miDCScreenKey);
|
2010-05-22 09:26:28 +02:00
|
|
|
pWin = pScreen->root;
|
2010-05-01 07:05:27 +02:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2006-11-21 04:30:46 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
if (pPriv->pPicture)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-05-24 18:15:32 +02:00
|
|
|
if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
|
|
|
|
return FALSE;
|
2003-11-14 17:49:22 +01:00
|
|
|
CompositePicture (PictOpOver,
|
|
|
|
pPriv->pPicture,
|
|
|
|
NULL,
|
2006-11-21 04:30:46 +01:00
|
|
|
pBuffer->pRootPicture,
|
2003-11-14 17:49:22 +01:00
|
|
|
0, 0, 0, 0,
|
|
|
|
x, y,
|
|
|
|
pCursor->bits->width,
|
|
|
|
pCursor->bits->height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
miDCPutBits ((DrawablePtr)pWin, pPriv,
|
2006-11-21 04:30:46 +01:00
|
|
|
pBuffer->pSourceGC, pBuffer->pMaskGC,
|
2003-11-14 17:49:22 +01:00
|
|
|
x, y, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
source, mask);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
int x, int y, int w, int h)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCScreenPtr pScreenPriv;
|
2006-11-21 04:30:46 +01:00
|
|
|
miDCBufferPtr pBuffer;
|
2003-11-14 16:54:54 +01:00
|
|
|
PixmapPtr pSave;
|
|
|
|
WindowPtr pWin;
|
|
|
|
GCPtr pGC;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miDCScreenKey);
|
2010-05-01 07:05:27 +02:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2006-12-14 01:20:18 +01:00
|
|
|
|
2006-11-21 04:30:46 +01:00
|
|
|
pSave = pBuffer->pSave;
|
2010-05-22 09:26:28 +02:00
|
|
|
pWin = pScreen->root;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
|
|
|
|
{
|
|
|
|
if (pSave)
|
|
|
|
(*pScreen->DestroyPixmap) (pSave);
|
2006-11-21 04:30:46 +01:00
|
|
|
pBuffer->pSave = pSave =
|
2007-10-31 22:15:35 +01:00
|
|
|
(*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth, 0);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pSave)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-04-22 01:46:17 +02:00
|
|
|
|
2006-11-21 04:30:46 +01:00
|
|
|
pGC = pBuffer->pSaveGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pSave->drawable.serialNumber != pGC->serialNumber)
|
|
|
|
ValidateGC ((DrawablePtr) pSave, pGC);
|
|
|
|
(*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
|
|
|
|
x, y, w, h, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
int x, int y, int w, int h)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
miDCScreenPtr pScreenPriv;
|
2006-11-21 04:30:46 +01:00
|
|
|
miDCBufferPtr pBuffer;
|
2003-11-14 16:54:54 +01:00
|
|
|
PixmapPtr pSave;
|
|
|
|
WindowPtr pWin;
|
|
|
|
GCPtr pGC;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miDCScreenKey);
|
2010-05-01 07:05:27 +02:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2006-11-21 04:30:46 +01:00
|
|
|
pSave = pBuffer->pSave;
|
2008-01-03 07:34:54 +01:00
|
|
|
|
2010-05-22 09:26:28 +02:00
|
|
|
pWin = pScreen->root;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pSave)
|
|
|
|
return FALSE;
|
2010-04-22 01:46:17 +02:00
|
|
|
|
2006-11-21 04:30:46 +01:00
|
|
|
pGC = pBuffer->pRestoreGC;
|
2003-11-14 16:54:54 +01:00
|
|
|
if (pWin->drawable.serialNumber != pGC->serialNumber)
|
|
|
|
ValidateGC ((DrawablePtr) pWin, pGC);
|
|
|
|
(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
|
|
|
|
0, 0, w, h, x, y);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
Bool
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
|
2007-04-09 12:01:59 +02:00
|
|
|
{
|
2010-04-22 01:46:17 +02:00
|
|
|
miDCBufferPtr pBuffer;
|
|
|
|
WindowPtr pWin;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!DevHasCursor(pDev))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++)
|
|
|
|
{
|
|
|
|
pScreen = screenInfo.screens[i];
|
|
|
|
|
2010-05-19 19:44:33 +02:00
|
|
|
pBuffer = calloc(1, sizeof(miDCBufferRec));
|
2010-04-22 01:46:17 +02:00
|
|
|
if (!pBuffer)
|
|
|
|
goto failure;
|
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, pScreen, pBuffer);
|
2010-05-22 09:26:28 +02:00
|
|
|
pWin = pScreen->root;
|
2010-04-22 01:46:17 +02:00
|
|
|
|
|
|
|
pBuffer->pSourceGC = miDCMakeGC(pWin);
|
|
|
|
if (!pBuffer->pSourceGC)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
pBuffer->pMaskGC = miDCMakeGC(pWin);
|
|
|
|
if (!pBuffer->pMaskGC)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
pBuffer->pSaveGC = miDCMakeGC(pWin);
|
|
|
|
if (!pBuffer->pSaveGC)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
pBuffer->pRestoreGC = miDCMakeGC(pWin);
|
|
|
|
if (!pBuffer->pRestoreGC)
|
|
|
|
goto failure;
|
|
|
|
|
2007-04-09 12:01:59 +02:00
|
|
|
#ifdef ARGB_CURSOR
|
2010-05-24 18:15:32 +02:00
|
|
|
pBuffer->pRootPicture = NULL;
|
2007-04-09 12:01:59 +02:00
|
|
|
#endif
|
2010-04-22 01:46:17 +02:00
|
|
|
|
2010-05-25 03:41:54 +02:00
|
|
|
/* (re)allocated lazily depending on the cursor size */
|
|
|
|
pBuffer->pSave = NULL;
|
2010-04-22 01:46:17 +02:00
|
|
|
}
|
2007-04-09 12:01:59 +02:00
|
|
|
|
|
|
|
return TRUE;
|
2010-04-22 01:46:17 +02:00
|
|
|
|
|
|
|
failure:
|
|
|
|
|
|
|
|
miDCDeviceCleanup(pDev, pScreen);
|
|
|
|
|
|
|
|
return FALSE;
|
2007-04-09 12:01:59 +02:00
|
|
|
}
|
|
|
|
|
2010-05-19 01:48:08 +02:00
|
|
|
void
|
2008-05-28 04:57:07 +02:00
|
|
|
miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
|
2007-04-09 12:01:59 +02:00
|
|
|
{
|
|
|
|
miDCBufferPtr pBuffer;
|
2010-04-22 01:46:17 +02:00
|
|
|
int i;
|
2007-04-09 12:01:59 +02:00
|
|
|
|
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
2010-04-22 01:46:17 +02:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++)
|
|
|
|
{
|
|
|
|
pScreen = screenInfo.screens[i];
|
|
|
|
|
2010-05-01 07:05:27 +02:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2010-04-22 01:46:17 +02:00
|
|
|
|
|
|
|
if (pBuffer)
|
|
|
|
{
|
|
|
|
if (pBuffer->pSourceGC) FreeGC(pBuffer->pSourceGC, (GContext) 0);
|
|
|
|
if (pBuffer->pMaskGC) FreeGC(pBuffer->pMaskGC, (GContext) 0);
|
|
|
|
if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0);
|
|
|
|
if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0);
|
|
|
|
|
2010-05-27 20:50:52 +02:00
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
/* If a pRootPicture was allocated for a root window, it
|
|
|
|
* is freed when that root window is destroyed, so don't
|
|
|
|
* free it again here. */
|
|
|
|
#endif
|
|
|
|
|
2010-04-22 01:46:17 +02:00
|
|
|
if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave);
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pBuffer);
|
2010-09-17 02:11:44 +02:00
|
|
|
dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, pScreen, NULL);
|
2010-04-22 01:46:17 +02:00
|
|
|
}
|
|
|
|
}
|
2007-04-09 12:01:59 +02:00
|
|
|
}
|
|
|
|
}
|