diff options
Diffstat (limited to 'Xext/cup.c')
-rw-r--r-- | Xext/cup.c | 342 |
1 files changed, 0 insertions, 342 deletions
diff --git a/Xext/cup.c b/Xext/cup.c deleted file mode 100644 index fd1409e33..000000000 --- a/Xext/cup.c +++ /dev/null | |||
@@ -1,342 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 1997, 1998 The Open Group | ||
4 | |||
5 | Permission to use, copy, modify, distribute, and sell this software and its | ||
6 | documentation for any purpose is hereby granted without fee, provided that | ||
7 | the above copyright notice appear in all copies and that both that | ||
8 | copyright notice and this permission notice appear in supporting | ||
9 | documentation. | ||
10 | |||
11 | The above copyright notice and this permission notice shall be included in | ||
12 | all copies or substantial portions of the Software. | ||
13 | |||
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
20 | |||
21 | Except as contained in this notice, the name of The Open Group shall not be | ||
22 | used in advertising or otherwise to promote the sale, use or other dealings | ||
23 | in this Software without prior written authorization from The Open Group. | ||
24 | |||
25 | */ | ||
26 | |||
27 | #define NEED_REPLIES | ||
28 | #define NEED_EVENTS | ||
29 | #ifdef HAVE_DIX_CONFIG_H | ||
30 | #include <dix-config.h> | ||
31 | #endif | ||
32 | |||
33 | #include <X11/X.h> | ||
34 | #include <X11/Xproto.h> | ||
35 | #include "misc.h" | ||
36 | #include "dixstruct.h" | ||
37 | #include "extnsionst.h" | ||
38 | #include "colormapst.h" | ||
39 | #include "scrnintstr.h" | ||
40 | #include "servermd.h" | ||
41 | #include "swapreq.h" | ||
42 | #define _XCUP_SERVER_ | ||
43 | #include <X11/extensions/Xcupstr.h> | ||
44 | #include <X11/Xfuncproto.h> | ||
45 | |||
46 | #include "../os/osdep.h" | ||
47 | |||
48 | #include "modinit.h" | ||
49 | |||
50 | static int ProcDispatch(ClientPtr client); | ||
51 | static int SProcDispatch(ClientPtr client); | ||
52 | static void ResetProc(ExtensionEntry* extEntry); | ||
53 | |||
54 | #if defined(WIN32) || defined(TESTWIN32) | ||
55 | #define HAVE_SPECIAL_DESKTOP_COLORS | ||
56 | #endif | ||
57 | |||
58 | static xColorItem citems[] = { | ||
59 | #ifndef HAVE_SPECIAL_DESKTOP_COLORS | ||
60 | #define CUP_BLACK_PIXEL 0 | ||
61 | #define CUP_WHITE_PIXEL 1 | ||
62 | /* pix red green blue */ | ||
63 | { 0, 0, 0, 0, 0, 0 }, | ||
64 | { 1, 0xffff, 0xffff, 0xffff, 0, 0 } | ||
65 | #else | ||
66 | #ifndef WIN32 | ||
67 | /* | ||
68 | This approximates the MS-Windows desktop colormap for testing | ||
69 | purposes but has black and white pixels in the typical Unix | ||
70 | locations, which should be switched if necessary if your system | ||
71 | has blackPixel and whitePixel swapped. No entries are provided | ||
72 | for colormap entries 254 and 255 because AllocColor/FindColor | ||
73 | will reuse entries zero and one. | ||
74 | */ | ||
75 | { 0, 0, 0, 0, 0, 0 }, | ||
76 | { 1, 0xffff, 0xffff, 0xffff, 0, 0 }, | ||
77 | { 2, 0x8000, 0, 0, 0, 0 }, | ||
78 | { 3, 0, 0x8000, 0, 0, 0 }, | ||
79 | { 4, 0x8000, 0x8000, 0, 0, 0 }, | ||
80 | { 5, 0, 0, 0x8000, 0, 0 }, | ||
81 | { 6, 0x8000, 0, 0x8000, 0, 0 }, | ||
82 | { 7, 0, 0x8000, 0x8000, 0, 0 }, | ||
83 | { 8, 0xc000, 0xc000, 0xc000, 0, 0 }, | ||
84 | { 9, 0xc000, 0xdc00, 0xc000, 0, 0 }, | ||
85 | { 246, 0xa000, 0xa000, 0xa000, 0, 0 }, | ||
86 | { 247, 0x8000, 0x8000, 0x8000, 0, 0 }, | ||
87 | { 248, 0xffff, 0, 0, 0, 0 }, | ||
88 | { 249, 0, 0xffff, 0, 0, 0 }, | ||
89 | { 250, 0xffff, 0xffff, 0, 0, 0 }, | ||
90 | { 251, 0, 0, 0xffff, 0, 0 }, | ||
91 | { 252, 0xffff, 0, 0xffff, 0, 0 }, | ||
92 | { 253, 0, 0xffff, 0xffff, 0, 0 } | ||
93 | #else | ||
94 | /* | ||
95 | this is the MS-Windows desktop, adjusted for X's 16-bit color | ||
96 | specifications. | ||
97 | */ | ||
98 | { 0, 0, 0, 0, 0, 0 }, | ||
99 | { 1, 0x8000, 0, 0, 0, 0 }, | ||
100 | { 2, 0, 0x8000, 0, 0, 0 }, | ||
101 | { 3, 0x8000, 0x8000, 0, 0, 0 }, | ||
102 | { 4, 0, 0, 0x8000, 0, 0 }, | ||
103 | { 5, 0x8000, 0, 0x8000, 0, 0 }, | ||
104 | { 6, 0, 0x8000, 0x8000, 0, 0 }, | ||
105 | { 7, 0xc000, 0xc000, 0xc000, 0, 0 }, | ||
106 | { 8, 0xc000, 0xdc00, 0xc000, 0, 0 }, | ||
107 | { 9, 0xa600, 0xca00, 0xf000, 0, 0 }, | ||
108 | { 246, 0xff00, 0xfb00, 0xf000, 0, 0 }, | ||
109 | { 247, 0xa000, 0xa000, 0xa400, 0, 0 }, | ||
110 | { 248, 0x8000, 0x8000, 0x8000, 0, 0 }, | ||
111 | { 249, 0xff00, 0, 0, 0, 0 }, | ||
112 | { 250, 0, 0xff00, 0, 0, 0 }, | ||
113 | { 251, 0xff00, 0xff00, 0, 0, 0 }, | ||
114 | { 252, 0, 0, 0xff00, 0, 0 }, | ||
115 | { 253, 0xff00, 0, 0xff00, 0, 0 }, | ||
116 | { 254, 0, 0xff00, 0xff00, 0, 0 }, | ||
117 | { 255, 0xff00, 0xff00, 0xff00, 0, 0 } | ||
118 | #endif | ||
119 | #endif | ||
120 | }; | ||
121 | #define NUM_DESKTOP_COLORS (sizeof citems / sizeof citems[0]) | ||
122 | |||
123 | void | ||
124 | XcupExtensionInit (INITARGS) | ||
125 | { | ||
126 | (void) AddExtension (XCUPNAME, | ||
127 | 0, | ||
128 | XcupNumberErrors, | ||
129 | ProcDispatch, | ||
130 | SProcDispatch, | ||
131 | ResetProc, | ||
132 | StandardMinorOpcode); | ||
133 | |||
134 | /* PC servers initialize the desktop colors (citems) here! */ | ||
135 | } | ||
136 | |||
137 | /*ARGSUSED*/ | ||
138 | static | ||
139 | void ResetProc( | ||
140 | ExtensionEntry* extEntry) | ||
141 | { | ||
142 | } | ||
143 | |||
144 | static | ||
145 | int ProcQueryVersion( | ||
146 | register ClientPtr client) | ||
147 | { | ||
148 | /* REQUEST (xXcupQueryVersionReq); */ | ||
149 | xXcupQueryVersionReply rep; | ||
150 | register int n; | ||
151 | |||
152 | REQUEST_SIZE_MATCH (xXcupQueryVersionReq); | ||
153 | rep.type = X_Reply; | ||
154 | rep.length = 0; | ||
155 | rep.sequence_number = client->sequence; | ||
156 | rep.server_major_version = XCUP_MAJOR_VERSION; | ||
157 | rep.server_minor_version = XCUP_MINOR_VERSION; | ||
158 | if (client->swapped) { | ||
159 | swaps (&rep.sequence_number, n); | ||
160 | swapl (&rep.length, n); | ||
161 | swaps (&rep.server_major_version, n); | ||
162 | swaps (&rep.server_minor_version, n); | ||
163 | } | ||
164 | WriteToClient (client, sizeof (xXcupQueryVersionReply), (char *)&rep); | ||
165 | return client->noClientException; | ||
166 | } | ||
167 | |||
168 | static | ||
169 | int ProcGetReservedColormapEntries( | ||
170 | register ClientPtr client) | ||
171 | { | ||
172 | REQUEST (xXcupGetReservedColormapEntriesReq); | ||
173 | xXcupGetReservedColormapEntriesReply rep; | ||
174 | xColorItem* cptr; | ||
175 | register int n; | ||
176 | |||
177 | REQUEST_SIZE_MATCH (xXcupGetReservedColormapEntriesReq); | ||
178 | |||
179 | if (stuff->screen >= screenInfo.numScreens) | ||
180 | return BadValue; | ||
181 | |||
182 | #ifndef HAVE_SPECIAL_DESKTOP_COLORS | ||
183 | citems[CUP_BLACK_PIXEL].pixel = | ||
184 | screenInfo.screens[stuff->screen]->blackPixel; | ||
185 | citems[CUP_WHITE_PIXEL].pixel = | ||
186 | screenInfo.screens[stuff->screen]->whitePixel; | ||
187 | #endif | ||
188 | |||
189 | rep.type = X_Reply; | ||
190 | rep.sequence_number = client->sequence; | ||
191 | rep.length = NUM_DESKTOP_COLORS * 3; | ||
192 | if (client->swapped) { | ||
193 | swaps (&rep.sequence_number, n); | ||
194 | swapl (&rep.length, n); | ||
195 | } | ||
196 | WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep); | ||
197 | for (n = 0, cptr = citems; n < NUM_DESKTOP_COLORS; n++, cptr++) { | ||
198 | if (client->swapped) SwapColorItem (cptr); | ||
199 | WriteToClient (client, SIZEOF(xColorItem), (char *)cptr); | ||
200 | } | ||
201 | return client->noClientException; | ||
202 | } | ||
203 | |||
204 | static | ||
205 | int ProcStoreColors( | ||
206 | register ClientPtr client) | ||
207 | { | ||
208 | REQUEST (xXcupStoreColorsReq); | ||
209 | ColormapPtr pcmp; | ||
210 | int rc; | ||
211 | |||
212 | REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq); | ||
213 | rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, | ||
214 | client, DixAddAccess); | ||
215 | |||
216 | if (rc == Success) { | ||
217 | int ncolors, n; | ||
218 | xXcupStoreColorsReply rep; | ||
219 | xColorItem* cptr; | ||
220 | |||
221 | if (!(pcmp->class & DynamicClass)) | ||
222 | return BadMatch; | ||
223 | |||
224 | ncolors = (client->req_len << 2) - SIZEOF (xXcupStoreColorsReq); | ||
225 | if (ncolors % SIZEOF(xColorItem)) | ||
226 | return BadLength; | ||
227 | |||
228 | ncolors /= SIZEOF (xColorItem); | ||
229 | |||
230 | |||
231 | for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) { | ||
232 | Pixel pixel = cptr->pixel; | ||
233 | |||
234 | if (AllocColor (pcmp, | ||
235 | &cptr->red, &cptr->green, &cptr->blue, | ||
236 | &pixel, client->index) == Success) { | ||
237 | cptr->pixel = pixel; | ||
238 | cptr->flags = 0x08; | ||
239 | } else | ||
240 | cptr->flags = 0; | ||
241 | cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem)); | ||
242 | } | ||
243 | |||
244 | rep.type = X_Reply; | ||
245 | rep.sequence_number = client->sequence; | ||
246 | rep.length = ncolors * 3; | ||
247 | if (client->swapped) { | ||
248 | swaps (&rep.sequence_number, n); | ||
249 | swapl (&rep.length, n); | ||
250 | } | ||
251 | WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep); | ||
252 | for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) { | ||
253 | if (client->swapped) SwapColorItem (cptr); | ||
254 | WriteToClient (client, SIZEOF(xColorItem), (char *)cptr); | ||
255 | cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem)); | ||
256 | } | ||
257 | return client->noClientException; | ||
258 | } else { | ||
259 | client->errorValue = stuff->cmap; | ||
260 | return (rc == BadValue) ? BadColor : rc; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | static | ||
265 | int ProcDispatch( | ||
266 | register ClientPtr client) | ||
267 | { | ||
268 | REQUEST (xReq); | ||
269 | switch (stuff->data) | ||
270 | { | ||
271 | case X_XcupQueryVersion: | ||
272 | return ProcQueryVersion (client); | ||
273 | case X_XcupGetReservedColormapEntries: | ||
274 | return ProcGetReservedColormapEntries (client); | ||
275 | case X_XcupStoreColors: | ||
276 | return ProcStoreColors (client); | ||
277 | default: | ||
278 | return BadRequest; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | static | ||
283 | int SProcQueryVersion( | ||
284 | register ClientPtr client) | ||
285 | { | ||
286 | register int n; | ||
287 | |||
288 | REQUEST(xXcupQueryVersionReq); | ||
289 | swaps(&stuff->length, n); | ||
290 | return ProcQueryVersion(client); | ||
291 | } | ||
292 | |||
293 | static | ||
294 | int SProcGetReservedColormapEntries( | ||
295 | ClientPtr client) | ||
296 | { | ||
297 | register int n; | ||
298 | |||
299 | REQUEST (xXcupGetReservedColormapEntriesReq); | ||
300 | swaps (&stuff->length, n); | ||
301 | swapl (&stuff->screen, n); | ||
302 | REQUEST_AT_LEAST_SIZE (xXcupGetReservedColormapEntriesReq); | ||
303 | return ProcGetReservedColormapEntries (client); | ||
304 | } | ||
305 | |||
306 | static | ||
307 | int SProcXcupStoreColors( | ||
308 | ClientPtr client) | ||
309 | { | ||
310 | register int n; | ||
311 | int count; | ||
312 | xColorItem* pItem; | ||
313 | |||
314 | REQUEST (xXcupStoreColorsReq); | ||
315 | swaps (&stuff->length, n); | ||
316 | REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq); | ||
317 | swapl(&stuff->cmap, n); | ||
318 | pItem = (xColorItem*) &stuff[1]; | ||
319 | for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; ) | ||
320 | SwapColorItem(pItem++); | ||
321 | return ProcStoreColors (client); | ||
322 | } | ||
323 | |||
324 | static | ||
325 | int SProcDispatch( | ||
326 | register ClientPtr client) | ||
327 | { | ||
328 | REQUEST(xReq); | ||
329 | switch (stuff->data) | ||
330 | { | ||
331 | case X_XcupQueryVersion: | ||
332 | return SProcQueryVersion (client); | ||
333 | case X_XcupGetReservedColormapEntries: | ||
334 | return SProcGetReservedColormapEntries (client); | ||
335 | case X_XcupStoreColors: | ||
336 | return SProcXcupStoreColors (client); | ||
337 | default: | ||
338 | return BadRequest; | ||
339 | } | ||
340 | } | ||
341 | |||
342 | |||