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"
39 xnestRealizeCursor(ScreenPtr pScreen
, CursorPtr pCursor
)
43 XColor fg_color
, bg_color
;
44 unsigned long valuemask
;
47 valuemask
= GCFunction
|
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
],
64 pCursor
->bits
->height
,
67 mask
= XCreatePixmap(xnestDisplay
,
68 xnestDefaultWindows
[pScreen
->myNum
],
70 pCursor
->bits
->height
,
73 ximage
= XCreateImage(xnestDisplay
,
74 xnestDefaultVisual(pScreen
),
76 (char *)pCursor
->bits
->source
,
78 pCursor
->bits
->height
,
79 BitmapPad(xnestDisplay
), 0);
81 XPutImage(xnestDisplay
, source
, xnestBitmapGC
, ximage
,
82 0, 0, 0, 0, pCursor
->bits
->width
, pCursor
->bits
->height
);
86 ximage
= XCreateImage(xnestDisplay
,
87 xnestDefaultVisual(pScreen
),
89 (char *)pCursor
->bits
->mask
,
91 pCursor
->bits
->height
,
92 BitmapPad(xnestDisplay
), 0);
94 XPutImage(xnestDisplay
, mask
, xnestBitmapGC
, ximage
,
95 0, 0, 0, 0, pCursor
->bits
->width
, pCursor
->bits
->height
);
99 fg_color
.red
= pCursor
->foreRed
;
100 fg_color
.green
= pCursor
->foreGreen
;
101 fg_color
.blue
= pCursor
->foreBlue
;
103 bg_color
.red
= pCursor
->backRed
;
104 bg_color
.green
= pCursor
->backGreen
;
105 bg_color
.blue
= pCursor
->backBlue
;
107 pCursor
->devPriv
[pScreen
->myNum
] = (pointer
)xalloc(sizeof(xnestPrivCursor
));
108 xnestCursorPriv(pCursor
, pScreen
)->cursor
=
109 XCreatePixmapCursor(xnestDisplay
, source
, mask
, &fg_color
, &bg_color
,
110 pCursor
->bits
->xhot
, pCursor
->bits
->yhot
);
112 XFreePixmap(xnestDisplay
, source
);
113 XFreePixmap(xnestDisplay
, mask
);
119 xnestUnrealizeCursor(ScreenPtr pScreen
, CursorPtr pCursor
)
121 XFreeCursor(xnestDisplay
, xnestCursor(pCursor
, pScreen
));
122 xfree(xnestCursorPriv(pCursor
, pScreen
));
127 xnestRecolorCursor(ScreenPtr pScreen
, CursorPtr pCursor
, Bool displayed
)
129 XColor fg_color
, bg_color
;
131 fg_color
.red
= pCursor
->foreRed
;
132 fg_color
.green
= pCursor
->foreGreen
;
133 fg_color
.blue
= pCursor
->foreBlue
;
135 bg_color
.red
= pCursor
->backRed
;
136 bg_color
.green
= pCursor
->backGreen
;
137 bg_color
.blue
= pCursor
->backBlue
;
139 XRecolorCursor(xnestDisplay
,
140 xnestCursor(pCursor
, pScreen
),
141 &fg_color
, &bg_color
);
144 void xnestSetCursor (ScreenPtr pScreen
, CursorPtr pCursor
, int x
, int y
)
148 XDefineCursor(xnestDisplay
,
149 xnestDefaultWindows
[pScreen
->myNum
],
150 xnestCursor(pCursor
, pScreen
));
155 xnestMoveCursor (ScreenPtr pScreen
, int x
, int y
)