First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xnest / Cursor.c
blob134276e7bfb7e816c09af3bf8bf724aa1d8c53f7
1 /*
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>
17 #endif
19 #include <X11/X.h>
20 #include <X11/Xproto.h>
21 #include "screenint.h"
22 #include "input.h"
23 #include "misc.h"
24 #include "cursor.h"
25 #include "cursorstr.h"
26 #include "scrnintstr.h"
27 #include "servermd.h"
29 #include "Xnest.h"
31 #include "Display.h"
32 #include "Screen.h"
33 #include "XNCursor.h"
34 #include "Visual.h"
35 #include "Keyboard.h"
36 #include "Args.h"
38 Bool
39 xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
41 XImage *ximage;
42 Pixmap source, mask;
43 XColor fg_color, bg_color;
44 unsigned long valuemask;
45 XGCValues values;
47 valuemask = GCFunction |
48 GCPlaneMask |
49 GCForeground |
50 GCBackground |
51 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,
64 pCursor->bits->height,
65 1);
67 mask = XCreatePixmap(xnestDisplay,
68 xnestDefaultWindows[pScreen->myNum],
69 pCursor->bits->width,
70 pCursor->bits->height,
71 1);
73 ximage = XCreateImage(xnestDisplay,
74 xnestDefaultVisual(pScreen),
75 1, XYBitmap, 0,
76 (char *)pCursor->bits->source,
77 pCursor->bits->width,
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);
84 XFree(ximage);
86 ximage = XCreateImage(xnestDisplay,
87 xnestDefaultVisual(pScreen),
88 1, XYBitmap, 0,
89 (char *)pCursor->bits->mask,
90 pCursor->bits->width,
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);
97 XFree(ximage);
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);
115 return True;
118 Bool
119 xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
121 XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen));
122 xfree(xnestCursorPriv(pCursor, pScreen));
123 return True;
126 void
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)
146 if (pCursor)
148 XDefineCursor(xnestDisplay,
149 xnestDefaultWindows[pScreen->myNum],
150 xnestCursor(pCursor, pScreen));
154 void
155 xnestMoveCursor (ScreenPtr pScreen, int x, int y)