2003-11-14 15:54:54 +00: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 19:29:55 +00:00
|
|
|
#include <dix-config.h>
|
|
|
|
|
|
2005-04-20 12:25:48 +00:00
|
|
|
#include <X11/X.h>
|
2024-03-05 19:35:42 +01:00
|
|
|
|
2024-02-08 20:12:35 +01:00
|
|
|
#include "dix/dix_priv.h"
|
2024-03-05 19:35:42 +01:00
|
|
|
#include "dix/gc_priv.h"
|
2025-04-28 13:00:41 +02:00
|
|
|
#include "dix/screen_hooks_priv.h"
|
2025-08-11 09:53:01 +02:00
|
|
|
#include "dix/screenint_priv.h"
|
2024-03-05 19:35:42 +01:00
|
|
|
|
2003-11-14 15:54:54 +00: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"
|
2003-11-14 16:49:22 +00:00
|
|
|
#include "picturestr.h"
|
2009-07-06 11:04:47 +10:00
|
|
|
#include "inputstr.h"
|
2006-11-21 11:26:21 +10:30
|
|
|
|
2003-11-14 15:54:54 +00:00
|
|
|
/* per-screen private data */
|
2010-04-26 17:22:21 -07:00
|
|
|
static DevPrivateKeyRec miDCScreenKeyRec;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
#define miDCScreenKey (&miDCScreenKeyRec)
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
static DevScreenPrivateKeyRec miDCDeviceKeyRec;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
#define miDCDeviceKey (&miDCDeviceKeyRec)
|
2003-11-14 15:54:54 +00:00
|
|
|
|
2025-04-28 13:00:41 +02:00
|
|
|
static void miDCCloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused);
|
2003-11-14 15:54:54 +00:00
|
|
|
|
2010-04-30 19:38:48 -07:00
|
|
|
/* per device private data */
|
2003-11-14 15:54:54 +00:00
|
|
|
typedef struct {
|
|
|
|
|
GCPtr pSourceGC, pMaskGC;
|
|
|
|
|
GCPtr pSaveGC, pRestoreGC;
|
2010-05-24 18:41:54 -07:00
|
|
|
PixmapPtr pSave;
|
2003-11-14 16:49:22 +00:00
|
|
|
PicturePtr pRootPicture;
|
2006-11-21 11:26:21 +10:30
|
|
|
} miDCBufferRec, *miDCBufferPtr;
|
|
|
|
|
|
2010-04-30 22:05:27 -07:00
|
|
|
#define miGetDCDevice(dev, screen) \
|
2007-04-09 19:31:59 +09:30
|
|
|
((DevHasCursor(dev)) ? \
|
2010-09-17 02:11:44 +02:00
|
|
|
(miDCBufferPtr)dixLookupScreenPrivate(&dev->devPrivates, miDCDeviceKey, screen) : \
|
2011-02-18 11:57:06 +10:00
|
|
|
(miDCBufferPtr)dixLookupScreenPrivate(&GetMaster(dev, MASTER_POINTER)->devPrivates, miDCDeviceKey, screen))
|
2007-04-09 19:31:59 +09:30
|
|
|
|
2006-12-14 10:50:18 +10:30
|
|
|
/*
|
2013-12-15 01:05:51 -08:00
|
|
|
* The core pointer buffer will point to the index of the virtual pointer
|
2006-12-14 10:50:18 +10:30
|
|
|
* in the pCursorBuffers array.
|
|
|
|
|
*/
|
2006-11-21 11:26:21 +10:30
|
|
|
typedef struct {
|
2003-11-14 15:54:54 +00:00
|
|
|
PixmapPtr sourceBits; /* source bits */
|
|
|
|
|
PixmapPtr maskBits; /* mask bits */
|
2003-11-14 16:49:22 +00:00
|
|
|
PicturePtr pPicture;
|
2012-07-05 11:15:18 -07:00
|
|
|
CursorPtr pCursor;
|
|
|
|
|
} miDCScreenRec, *miDCScreenPtr;
|
|
|
|
|
|
|
|
|
|
#define miGetDCScreen(s) ((miDCScreenPtr)(dixLookupPrivate(&(s)->devPrivates, miDCScreenKey)))
|
2003-11-14 15:54:54 +00:00
|
|
|
|
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 05:43:34 -02:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCInitialize(ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
|
|
|
|
miDCScreenPtr pScreenPriv;
|
|
|
|
|
|
2010-09-17 02:11:44 +02:00
|
|
|
if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0) ||
|
|
|
|
|
!dixRegisterScreenPrivateKey(&miDCDeviceKeyRec, pScreen, PRIVATE_DEVICE,
|
|
|
|
|
0))
|
2010-04-26 17:22:21 -07:00
|
|
|
return FALSE;
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
pScreenPriv = calloc(1, sizeof(miDCScreenRec));
|
2003-11-14 15:54:54 +00:00
|
|
|
if (!pScreenPriv)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2025-07-18 09:51:34 +03:00
|
|
|
dixScreenHookPostClose(pScreen, miDCCloseScreen);
|
2007-08-28 09:28:25 -04:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, pScreenPriv);
|
2003-11-14 15:54:54 +00:00
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
if (!miSpriteInitialize(pScreen, screenFuncs)) {
|
2013-12-15 01:05:51 -08:00
|
|
|
free((void *) pScreenPriv);
|
2003-11-14 15:54:54 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
static void
|
|
|
|
|
miDCSwitchScreenCursor(ScreenPtr pScreen, CursorPtr pCursor, PixmapPtr sourceBits, PixmapPtr maskBits, PicturePtr pPicture)
|
|
|
|
|
{
|
|
|
|
|
miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey);
|
2025-04-28 13:00:41 +02:00
|
|
|
if (!pScreenPriv)
|
|
|
|
|
return;
|
2012-07-05 11:15:18 -07:00
|
|
|
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(pScreenPriv->sourceBits, 0);
|
2012-07-05 11:15:18 -07:00
|
|
|
pScreenPriv->sourceBits = sourceBits;
|
|
|
|
|
|
|
|
|
|
if (pScreenPriv->maskBits)
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(pScreenPriv->maskBits, 0);
|
2012-07-05 11:15:18 -07:00
|
|
|
pScreenPriv->maskBits = maskBits;
|
|
|
|
|
|
|
|
|
|
if (pScreenPriv->pPicture)
|
|
|
|
|
FreePicture(pScreenPriv->pPicture, 0);
|
|
|
|
|
pScreenPriv->pPicture = pPicture;
|
|
|
|
|
|
|
|
|
|
pScreenPriv->pCursor = pCursor;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 13:00:41 +02:00
|
|
|
static void miDCCloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2025-07-18 09:51:34 +03:00
|
|
|
dixScreenUnhookPostClose(pScreen, miDCCloseScreen);
|
2003-11-14 15:54:54 +00:00
|
|
|
|
2025-04-28 13:00:41 +02:00
|
|
|
miDCScreenPtr pScreenPriv;
|
2007-08-28 09:28:25 -04:00
|
|
|
pScreenPriv = (miDCScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
|
miDCScreenKey);
|
2012-07-05 11:15:18 -07:00
|
|
|
miDCSwitchScreenCursor(pScreen, NULL, NULL, NULL, NULL);
|
2013-12-15 01:05:51 -08:00
|
|
|
free((void *) pScreenPriv);
|
2025-04-28 13:00:41 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, NULL); /* clear it, just for sure */
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-24 09:15:32 -07:00
|
|
|
#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
|
2003-11-14 16:49:22 +00:00
|
|
|
|
|
|
|
|
static PicturePtr
|
|
|
|
|
miDCMakePicture(PicturePtr * ppPicture, DrawablePtr pDraw, WindowPtr pWin)
|
|
|
|
|
{
|
|
|
|
|
PictFormatPtr pFormat;
|
|
|
|
|
XID subwindow_mode = IncludeInferiors;
|
|
|
|
|
PicturePtr pPicture;
|
|
|
|
|
int error;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2012-06-27 14:36:04 +01:00
|
|
|
pFormat = PictureWindowFormat(pWin);
|
2003-11-14 16:49:22 +00:00
|
|
|
if (!pFormat)
|
|
|
|
|
return 0;
|
|
|
|
|
pPicture = CreatePicture(0, pDraw, pFormat,
|
|
|
|
|
CPSubwindowMode, &subwindow_mode,
|
|
|
|
|
serverClient, &error);
|
|
|
|
|
*ppPicture = pPicture;
|
|
|
|
|
return pPicture;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
static Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCRealize(ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2012-07-05 11:15:18 -07:00
|
|
|
miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey);
|
2003-11-14 15:54:54 +00:00
|
|
|
GCPtr pGC;
|
2010-05-08 14:10:51 -07:00
|
|
|
ChangeGCVal gcvals;
|
2012-07-05 11:15:18 -07:00
|
|
|
PixmapPtr sourceBits, maskBits;
|
|
|
|
|
|
|
|
|
|
if (pScreenPriv->pCursor == pCursor)
|
|
|
|
|
return TRUE;
|
2003-11-14 15:54:54 +00:00
|
|
|
|
2003-11-14 16:49:22 +00:00
|
|
|
if (pCursor->bits->argb) {
|
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
PictFormatPtr pFormat;
|
|
|
|
|
int error;
|
2012-07-05 11:15:18 -07:00
|
|
|
PicturePtr pPicture;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2025-08-05 19:41:23 +02:00
|
|
|
pFormat = PictureMatchFormat(pScreen, 32, PIXMAN_a8r8g8b8);
|
2012-07-05 11:15:18 -07:00
|
|
|
if (!pFormat)
|
|
|
|
|
return FALSE;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:49:22 +00:00
|
|
|
pPixmap = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width,
|
2007-10-31 14:15:35 -07:00
|
|
|
pCursor->bits->height, 32,
|
|
|
|
|
CREATE_PIXMAP_USAGE_SCRATCH);
|
2012-07-05 11:15:18 -07:00
|
|
|
if (!pPixmap)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-11-14 16:49:22 +00:00
|
|
|
pGC = GetScratchGC(32, pScreen);
|
|
|
|
|
if (!pGC) {
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(pPixmap, 0);
|
2012-07-05 11:15:18 -07:00
|
|
|
return FALSE;
|
2003-11-14 16:49:22 +00: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);
|
2012-07-05 11:15:18 -07:00
|
|
|
pPicture = CreatePicture(0, &pPixmap->drawable,
|
|
|
|
|
pFormat, 0, 0, serverClient, &error);
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(pPixmap, 0);
|
2012-07-05 11:15:18 -07:00
|
|
|
if (!pPicture)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
miDCSwitchScreenCursor(pScreen, pCursor, NULL, NULL, pPicture);
|
|
|
|
|
return TRUE;
|
2003-11-14 16:49:22 +00:00
|
|
|
}
|
2015-06-09 15:30:22 +10:00
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
sourceBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width,
|
|
|
|
|
pCursor->bits->height, 1, 0);
|
|
|
|
|
if (!sourceBits)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
maskBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width,
|
|
|
|
|
pCursor->bits->height, 1, 0);
|
|
|
|
|
if (!maskBits) {
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(sourceBits, 0);
|
2012-07-05 11:15:18 -07:00
|
|
|
return FALSE;
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create the two sets of bits, clipping as appropriate */
|
|
|
|
|
|
|
|
|
|
pGC = GetScratchGC(1, pScreen);
|
|
|
|
|
if (!pGC) {
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(sourceBits, 0);
|
|
|
|
|
dixDestroyPixmap(maskBits, 0);
|
2012-07-05 11:15:18 -07:00
|
|
|
return FALSE;
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
ValidateGC((DrawablePtr) sourceBits, pGC);
|
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr) sourceBits, pGC, 1,
|
2003-11-14 15:54:54 +00:00
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
|
0, XYPixmap, (char *) pCursor->bits->source);
|
2010-05-08 14:10:51 -07:00
|
|
|
gcvals.val = GXand;
|
2025-07-16 12:06:03 +02:00
|
|
|
ChangeGC(NULL, pGC, GCFunction, &gcvals);
|
2012-07-05 11:15:18 -07:00
|
|
|
ValidateGC((DrawablePtr) sourceBits, pGC);
|
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr) sourceBits, pGC, 1,
|
2003-11-14 15:54:54 +00:00
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
|
0, XYPixmap, (char *) pCursor->bits->mask);
|
|
|
|
|
|
|
|
|
|
/* mask bits -- pCursor->mask & ~pCursor->source */
|
2010-05-08 14:10:51 -07:00
|
|
|
gcvals.val = GXcopy;
|
2025-07-16 12:06:03 +02:00
|
|
|
ChangeGC(NULL, pGC, GCFunction, &gcvals);
|
2012-07-05 11:15:18 -07:00
|
|
|
ValidateGC((DrawablePtr) maskBits, pGC);
|
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr) maskBits, pGC, 1,
|
2003-11-14 15:54:54 +00:00
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
|
0, XYPixmap, (char *) pCursor->bits->mask);
|
2010-05-08 14:10:51 -07:00
|
|
|
gcvals.val = GXandInverted;
|
2025-07-16 12:06:03 +02:00
|
|
|
ChangeGC(NULL, pGC, GCFunction, &gcvals);
|
2012-07-05 11:15:18 -07:00
|
|
|
ValidateGC((DrawablePtr) maskBits, pGC);
|
|
|
|
|
(*pGC->ops->PutImage) ((DrawablePtr) maskBits, pGC, 1,
|
2003-11-14 15:54:54 +00:00
|
|
|
0, 0, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
|
0, XYPixmap, (char *) pCursor->bits->source);
|
|
|
|
|
FreeScratchGC(pGC);
|
2012-07-05 11:15:18 -07:00
|
|
|
|
|
|
|
|
miDCSwitchScreenCursor(pScreen, pCursor, sourceBits, maskBits, NULL);
|
|
|
|
|
return TRUE;
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2012-07-05 11:15:18 -07:00
|
|
|
miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey);
|
2003-11-14 15:54:54 +00:00
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
if (pCursor == pScreenPriv->pCursor)
|
|
|
|
|
miDCSwitchScreenCursor(pScreen, NULL, NULL, NULL, NULL);
|
2003-11-14 15:54:54 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-11-14 16:49:22 +00:00
|
|
|
miDCPutBits(DrawablePtr pDrawable,
|
|
|
|
|
GCPtr sourceGC,
|
|
|
|
|
GCPtr maskGC,
|
2003-11-25 19:29:01 +00:00
|
|
|
int x_org,
|
|
|
|
|
int y_org,
|
2003-11-14 16:49:22 +00:00
|
|
|
unsigned w, unsigned h, unsigned long source, unsigned long mask)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2012-07-05 11:15:18 -07:00
|
|
|
miDCScreenPtr pScreenPriv = dixLookupPrivate(&pDrawable->pScreen->devPrivates, miDCScreenKey);
|
2010-05-08 14:10:51 -07:00
|
|
|
ChangeGCVal gcval;
|
2003-11-25 19:29:01 +00:00
|
|
|
int x, y;
|
2003-11-14 15:54:54 +00:00
|
|
|
|
|
|
|
|
if (sourceGC->fgPixel != source) {
|
2010-05-08 14:10:51 -07:00
|
|
|
gcval.val = source;
|
2025-07-16 12:06:03 +02:00
|
|
|
ChangeGC(NULL, sourceGC, GCForeground, &gcval);
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
if (sourceGC->serialNumber != pDrawable->serialNumber)
|
|
|
|
|
ValidateGC(pDrawable, sourceGC);
|
2003-11-25 19:29:01 +00:00
|
|
|
|
|
|
|
|
if (sourceGC->miTranslate) {
|
|
|
|
|
x = pDrawable->x + x_org;
|
|
|
|
|
y = pDrawable->y + y_org;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
x = x_org;
|
|
|
|
|
y = y_org;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
(*sourceGC->ops->PushPixels) (sourceGC, pScreenPriv->sourceBits, pDrawable, w, h,
|
2003-11-14 15:54:54 +00:00
|
|
|
x, y);
|
|
|
|
|
if (maskGC->fgPixel != mask) {
|
2010-05-08 14:10:51 -07:00
|
|
|
gcval.val = mask;
|
2025-07-16 12:06:03 +02:00
|
|
|
ChangeGC(NULL, maskGC, GCForeground, &gcval);
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
if (maskGC->serialNumber != pDrawable->serialNumber)
|
|
|
|
|
ValidateGC(pDrawable, maskGC);
|
2003-11-25 19:29:01 +00:00
|
|
|
|
|
|
|
|
if (maskGC->miTranslate) {
|
|
|
|
|
x = pDrawable->x + x_org;
|
|
|
|
|
y = pDrawable->y + y_org;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
x = x_org;
|
|
|
|
|
y = y_org;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
(*maskGC->ops->PushPixels) (maskGC, pScreenPriv->maskBits, pDrawable, w, h, x, y);
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GCPtr
|
2010-04-21 16:46:17 -07:00
|
|
|
miDCMakeGC(WindowPtr pWin)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
|
|
|
|
GCPtr pGC;
|
|
|
|
|
int status;
|
|
|
|
|
XID gcvals[2];
|
|
|
|
|
|
|
|
|
|
gcvals[0] = IncludeInferiors;
|
|
|
|
|
gcvals[1] = FALSE;
|
|
|
|
|
pGC = CreateGC((DrawablePtr) pWin,
|
2007-08-14 13:09:38 -04:00
|
|
|
GCSubwindowMode | GCGraphicsExposures, gcvals, &status,
|
|
|
|
|
(XID) 0, serverClient);
|
2003-11-14 15:54:54 +00:00
|
|
|
return pGC;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCPutUpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
|
|
|
|
|
int x, int y, unsigned long source, unsigned long mask)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2012-07-05 11:15:18 -07:00
|
|
|
miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey);
|
2006-11-21 14:00:46 +10:30
|
|
|
miDCBufferPtr pBuffer;
|
2003-11-14 15:54:54 +00:00
|
|
|
WindowPtr pWin;
|
|
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
if (!miDCRealize(pScreen, pCursor))
|
|
|
|
|
return FALSE;
|
2011-03-25 18:24:34 +02:00
|
|
|
|
2010-05-22 00:26:28 -07:00
|
|
|
pWin = pScreen->root;
|
2010-04-30 22:05:27 -07:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2006-11-21 14:00:46 +10:30
|
|
|
|
2012-07-05 11:15:18 -07:00
|
|
|
if (pScreenPriv->pPicture) {
|
2010-05-24 09:15:32 -07:00
|
|
|
if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
|
|
|
|
|
return FALSE;
|
2003-11-14 16:49:22 +00:00
|
|
|
CompositePicture(PictOpOver,
|
2012-07-05 11:15:18 -07:00
|
|
|
pScreenPriv->pPicture,
|
2003-11-14 16:49:22 +00:00
|
|
|
NULL,
|
2006-11-21 14:00:46 +10:30
|
|
|
pBuffer->pRootPicture,
|
2003-11-14 16:49:22 +00:00
|
|
|
0, 0, 0, 0,
|
|
|
|
|
x, y, pCursor->bits->width, pCursor->bits->height);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-07-05 11:15:18 -07:00
|
|
|
miDCPutBits((DrawablePtr) pWin,
|
2006-11-21 14:00:46 +10:30
|
|
|
pBuffer->pSourceGC, pBuffer->pMaskGC,
|
2003-11-14 16:49:22 +00:00
|
|
|
x, y, pCursor->bits->width, pCursor->bits->height,
|
|
|
|
|
source, mask);
|
2003-11-14 15:54:54 +00:00
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
|
int x, int y, int w, int h)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2006-11-21 14:00:46 +10:30
|
|
|
miDCBufferPtr pBuffer;
|
2003-11-14 15:54:54 +00:00
|
|
|
PixmapPtr pSave;
|
|
|
|
|
WindowPtr pWin;
|
|
|
|
|
GCPtr pGC;
|
|
|
|
|
|
2010-04-30 22:05:27 -07:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2006-12-14 10:50:18 +10:30
|
|
|
|
2006-11-21 14:00:46 +10:30
|
|
|
pSave = pBuffer->pSave;
|
2010-05-22 00:26:28 -07:00
|
|
|
pWin = pScreen->root;
|
2003-11-14 15:54:54 +00:00
|
|
|
if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h) {
|
2024-09-30 17:56:15 +02:00
|
|
|
dixDestroyPixmap(pSave, 0);
|
2006-11-21 14:00:46 +10:30
|
|
|
pBuffer->pSave = pSave =
|
2007-10-31 14:15:35 -07:00
|
|
|
(*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth, 0);
|
2003-11-14 15:54:54 +00:00
|
|
|
if (!pSave)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2010-04-21 16:46:17 -07:00
|
|
|
|
2006-11-21 14:00:46 +10:30
|
|
|
pGC = pBuffer->pSaveGC;
|
2003-11-14 15:54:54 +00:00
|
|
|
if (pSave->drawable.serialNumber != pGC->serialNumber)
|
|
|
|
|
ValidateGC((DrawablePtr) pSave, pGC);
|
2024-08-20 18:23:48 +02:00
|
|
|
(void) (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
|
2003-11-14 15:54:54 +00:00
|
|
|
x, y, w, h, 0, 0);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
|
int x, int y, int w, int h)
|
2003-11-14 15:54:54 +00:00
|
|
|
{
|
2006-11-21 14:00:46 +10:30
|
|
|
miDCBufferPtr pBuffer;
|
2003-11-14 15:54:54 +00:00
|
|
|
PixmapPtr pSave;
|
|
|
|
|
WindowPtr pWin;
|
|
|
|
|
GCPtr pGC;
|
|
|
|
|
|
2010-04-30 22:05:27 -07:00
|
|
|
pBuffer = miGetDCDevice(pDev, pScreen);
|
2006-11-21 14:00:46 +10:30
|
|
|
pSave = pBuffer->pSave;
|
2008-01-03 17:04:54 +10:30
|
|
|
|
2010-05-22 00:26:28 -07:00
|
|
|
pWin = pScreen->root;
|
2003-11-14 15:54:54 +00:00
|
|
|
if (!pSave)
|
|
|
|
|
return FALSE;
|
2010-04-21 16:46:17 -07:00
|
|
|
|
2006-11-21 14:00:46 +10:30
|
|
|
pGC = pBuffer->pRestoreGC;
|
2003-11-14 15:54:54 +00:00
|
|
|
if (pWin->drawable.serialNumber != pGC->serialNumber)
|
|
|
|
|
ValidateGC((DrawablePtr) pWin, pGC);
|
2024-08-20 18:23:48 +02:00
|
|
|
(void) (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
|
2003-11-14 15:54:54 +00:00
|
|
|
0, 0, w, h, x, y);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
Bool
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
|
2007-04-09 19:31:59 +09:30
|
|
|
{
|
2010-04-21 16:46:17 -07:00
|
|
|
miDCBufferPtr pBuffer;
|
2007-04-09 19:31:59 +09:30
|
|
|
|
2010-04-21 16:46:17 -07:00
|
|
|
if (!DevHasCursor(pDev))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2025-08-11 09:53:01 +02:00
|
|
|
DIX_FOR_EACH_SCREEN({
|
2010-05-19 10:44:33 -07:00
|
|
|
pBuffer = calloc(1, sizeof(miDCBufferRec));
|
2010-04-21 16:46:17 -07:00
|
|
|
if (!pBuffer)
|
|
|
|
|
goto failure;
|
|
|
|
|
|
2025-08-12 18:51:31 +02:00
|
|
|
dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, walkScreen,
|
2010-09-17 02:11:44 +02:00
|
|
|
pBuffer);
|
2025-08-12 18:51:31 +02:00
|
|
|
WindowPtr pWin = walkScreen->root;
|
2010-04-21 16:46:17 -07: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;
|
|
|
|
|
|
2010-05-24 09:15:32 -07:00
|
|
|
pBuffer->pRootPicture = NULL;
|
2010-04-21 16:46:17 -07:00
|
|
|
|
2010-05-24 18:41:54 -07:00
|
|
|
/* (re)allocated lazily depending on the cursor size */
|
|
|
|
|
pBuffer->pSave = NULL;
|
2025-08-12 18:51:31 +02:00
|
|
|
|
|
|
|
|
continue;
|
2025-08-11 09:53:01 +02:00
|
|
|
|
2025-08-12 18:51:31 +02:00
|
|
|
failure:
|
|
|
|
|
miDCDeviceCleanup(pDev, walkScreen);
|
|
|
|
|
return FALSE;
|
2025-08-11 09:53:01 +02:00
|
|
|
});
|
2007-04-09 19:31:59 +09:30
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-18 16:48:08 -07:00
|
|
|
void
|
2008-05-28 12:27:07 +09:30
|
|
|
miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
|
2007-04-09 19:31:59 +09:30
|
|
|
{
|
2025-09-03 12:04:13 +02:00
|
|
|
if (!DevHasCursor(pDev))
|
|
|
|
|
return;
|
2007-04-09 19:31:59 +09:30
|
|
|
|
2025-08-11 09:53:01 +02:00
|
|
|
DIX_FOR_EACH_SCREEN({
|
2025-09-03 12:04:13 +02:00
|
|
|
miDCBufferPtr pBuffer = miGetDCDevice(pDev, walkScreen);
|
2025-09-03 16:18:31 +02:00
|
|
|
if (!pBuffer)
|
|
|
|
|
continue;
|
2010-04-21 16:46:17 -07:00
|
|
|
|
2025-09-03 16:18:31 +02:00
|
|
|
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 11:50:52 -07:00
|
|
|
|
2025-09-03 16:18:31 +02:00
|
|
|
/* 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. */
|
2010-04-21 16:46:17 -07:00
|
|
|
|
2025-09-03 16:18:31 +02:00
|
|
|
dixDestroyPixmap(pBuffer->pSave, 0);
|
|
|
|
|
free(pBuffer);
|
|
|
|
|
dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, walkScreen, NULL);
|
2025-08-11 09:53:01 +02:00
|
|
|
});
|
2007-04-09 19:31:59 +09:30
|
|
|
}
|