3 Copyright 1993 by Davor Matic
5 Permission to use, copy, modify, distribute, and sell this software
6 and its documentation for any purpose is hereby granted without fee,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation. Davor Matic makes no representations about
10 the suitability of this software for any purpose. It is provided "as
11 is" without express or implied warranty.
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
20 #include <X11/Xproto.h>
21 #include "screenint.h"
25 #include "cursorstr.h"
26 #include "scrnintstr.h"
28 #include "mipointrst.h"
39 xnestCursorFuncRec xnestCursorFuncs
= { NULL
};
42 xnestRealizeCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, CursorPtr pCursor
)
46 XColor fg_color
, bg_color
;
47 unsigned long valuemask
;
50 valuemask
= GCFunction
|
51 GCPlaneMask
| GCForeground
| GCBackground
| GCClipMask
;
53 values
.function
= GXcopy
;
54 values
.plane_mask
= AllPlanes
;
55 values
.foreground
= 1L;
56 values
.background
= 0L;
57 values
.clip_mask
= None
;
59 XChangeGC(xnestDisplay
, xnestBitmapGC
, valuemask
, &values
);
61 source
= XCreatePixmap(xnestDisplay
,
62 xnestDefaultWindows
[pScreen
->myNum
],
63 pCursor
->bits
->width
, pCursor
->bits
->height
, 1);
65 mask
= XCreatePixmap(xnestDisplay
,
66 xnestDefaultWindows
[pScreen
->myNum
],
67 pCursor
->bits
->width
, pCursor
->bits
->height
, 1);
69 ximage
= XCreateImage(xnestDisplay
,
70 xnestDefaultVisual(pScreen
),
72 (char *) pCursor
->bits
->source
,
74 pCursor
->bits
->height
, BitmapPad(xnestDisplay
), 0);
76 XPutImage(xnestDisplay
, source
, xnestBitmapGC
, ximage
,
77 0, 0, 0, 0, pCursor
->bits
->width
, pCursor
->bits
->height
);
81 ximage
= XCreateImage(xnestDisplay
,
82 xnestDefaultVisual(pScreen
),
84 (char *) pCursor
->bits
->mask
,
86 pCursor
->bits
->height
, BitmapPad(xnestDisplay
), 0);
88 XPutImage(xnestDisplay
, mask
, xnestBitmapGC
, ximage
,
89 0, 0, 0, 0, pCursor
->bits
->width
, pCursor
->bits
->height
);
93 fg_color
.red
= pCursor
->foreRed
;
94 fg_color
.green
= pCursor
->foreGreen
;
95 fg_color
.blue
= pCursor
->foreBlue
;
97 bg_color
.red
= pCursor
->backRed
;
98 bg_color
.green
= pCursor
->backGreen
;
99 bg_color
.blue
= pCursor
->backBlue
;
101 xnestSetCursorPriv(pCursor
, pScreen
, malloc(sizeof(xnestPrivCursor
)));
102 xnestCursor(pCursor
, pScreen
) =
103 XCreatePixmapCursor(xnestDisplay
, source
, mask
, &fg_color
, &bg_color
,
104 pCursor
->bits
->xhot
, pCursor
->bits
->yhot
);
106 XFreePixmap(xnestDisplay
, source
);
107 XFreePixmap(xnestDisplay
, mask
);
113 xnestUnrealizeCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, CursorPtr pCursor
)
115 XFreeCursor(xnestDisplay
, xnestCursor(pCursor
, pScreen
));
116 free(xnestGetCursorPriv(pCursor
, pScreen
));
121 xnestRecolorCursor(ScreenPtr pScreen
, CursorPtr pCursor
, Bool displayed
)
123 XColor fg_color
, bg_color
;
125 fg_color
.red
= pCursor
->foreRed
;
126 fg_color
.green
= pCursor
->foreGreen
;
127 fg_color
.blue
= pCursor
->foreBlue
;
129 bg_color
.red
= pCursor
->backRed
;
130 bg_color
.green
= pCursor
->backGreen
;
131 bg_color
.blue
= pCursor
->backBlue
;
133 XRecolorCursor(xnestDisplay
,
134 xnestCursor(pCursor
, pScreen
), &fg_color
, &bg_color
);
138 xnestSetCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, CursorPtr pCursor
, int x
,
142 XDefineCursor(xnestDisplay
,
143 xnestDefaultWindows
[pScreen
->myNum
],
144 xnestCursor(pCursor
, pScreen
));
149 xnestMoveCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, int x
, int y
)
154 xnestDeviceCursorInitialize(DeviceIntPtr pDev
, ScreenPtr pScreen
)
156 xnestCursorFuncPtr pScreenPriv
;
158 pScreenPriv
= (xnestCursorFuncPtr
)
159 dixLookupPrivate(&pScreen
->devPrivates
, xnestCursorScreenKey
);
161 return pScreenPriv
->spriteFuncs
->DeviceCursorInitialize(pDev
, pScreen
);
165 xnestDeviceCursorCleanup(DeviceIntPtr pDev
, ScreenPtr pScreen
)
167 xnestCursorFuncPtr pScreenPriv
;
169 pScreenPriv
= (xnestCursorFuncPtr
)
170 dixLookupPrivate(&pScreen
->devPrivates
, xnestCursorScreenKey
);
172 pScreenPriv
->spriteFuncs
->DeviceCursorCleanup(pDev
, pScreen
);