blob: ded2646908996de3f64edf829395a0f4b4c3db17 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Sun designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Sun in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 */
24/* $XConsortium: wsutils.h /main/3 1996/10/14 15:04:17 swick $ */
25/** ------------------------------------------------------------------------
26 This file contains routines for manipulating generic lists.
27 Lists are implemented with a "harness". In other words, each
28 node in the list consists of two pointers, one to the data item
29 and one to the next node in the list. The head of the list is
30 the same struct as each node, but the "item" ptr is used to point
31 to the current member of the list (used by the first_in_list and
32 next_in_list functions).
33
34 This file is available under and governed by the GNU General Public
35 License version 2 only, as published by the Free Software Foundation.
36 However, the following notice accompanied the original version of this
37 file:
38
39Copyright (c) 1994 Hewlett-Packard Co.
40Copyright (c) 1996 X Consortium
41
42Permission is hereby granted, free of charge, to any person obtaining
43a copy of this software and associated documentation files (the
44"Software"), to deal in the Software without restriction, including
45without limitation the rights to use, copy, modify, merge, publish,
46distribute, sublicense, and sell copies of the Software, and to
47permit persons to whom the Software is furnished to do so, subject to
48the following conditions:
49
50The above copyright notice and this permission notice shall be included
51in all copies or substantial portions of the Software.
52
53THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
54OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
56IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
57OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
58ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
59OTHER DEALINGS IN THE SOFTWARE.
60
61Except as contained in this notice, the name of the X Consortium shall
62not be used in advertising or otherwise to promote the sale, use or
63other dealings in this Software without prior written authorization
64from the X Consortium.
65
66 ------------------------------------------------------------------------ **/
67/******************************************************************************
68 *
69 * This file contains various typedef's, macros and procedure declarations for
70 * a set of example utility procedures contained in the file "wsutils.c".
71 *
72 ******************************************************************************/
73
74/* This is the actual structure returned by the X server describing the
75 * SERVER_OVERLAY_VISUAL property.
76 */
77typedef struct
78{
79 VisualID visualID; /* The VisualID of the overlay visual */
80 long transparentType; /* Can be None, TransparentPixel or
81 * TransparentMask */
82 long value; /* Pixel value */
83 long layer; /* Overlay planes will always be in
84 * layer 1 */
85} OverlayVisualPropertyRec;
86
87
88/* This is structure also describes the SERVER_OVERLAY_VISUAL property, but
89 * should be more useful than the one actually returned by the X server
90 * because it actually points to the visual's XVisualInfo struct rather than
91 * refering to the visual's ID.
92 */
93typedef struct
94{
95 XVisualInfo *pOverlayVisualInfo; /* Pointer to the XVisualInfo struct */
96 long transparentType; /* Can be None, TransparentPixel or
97 * TransparentMask */
98 long value; /* Pixel value */
99 long layer; /* Overlay planes will always be in
100 * layer 1 */
101} OverlayInfo;
102
103
104/* These macros are the values of the "transparentType" above: */
105#ifndef None
106#define None 0
107#endif
108#ifndef TransparentPixel
109#define TransparentPixel 1
110#endif
111
112
113/* These macros define how flexible a program is when it requests a window's
114 * creation with either the CreateImagePlanesWindow() or
115 * CreateOverlayPlanesWindow():
116 */
117#ifndef NOT_FLEXIBLE
118#define NOT_FLEXIBLE 0
119#define FLEXIBLE 1
120#endif
121
122
123/* These macros define the values of the "sbCmapHint" parameter of the
124 * CreateImagePlanesWindow():
125 */
126#ifndef SB_CMAP_TYPE_NORMAL
127#define SB_CMAP_TYPE_NORMAL 1
128#endif
129
130#ifndef SB_CMAP_TYPE_MONOTONIC
131#define SB_CMAP_TYPE_MONOTONIC 2
132#endif
133
134#ifndef SB_CMAP_TYPE_FULL
135#define SB_CMAP_TYPE_FULL 4
136#endif
137
138
139/******************************************************************************
140 *
141 * GetXVisualInfo()
142 *
143 * This routine takes an X11 Display, screen number, and returns whether the
144 * screen supports transparent overlays and three arrays:
145 *
146 * 1) All of the XVisualInfo struct's for the screen.
147 * 2) All of the OverlayInfo struct's for the screen.
148 * 3) An array of pointers to the screen's image plane XVisualInfo
149 * structs.
150 *
151 * The code below obtains the array of all the screen's visuals, and obtains
152 * the array of all the screen's overlay visual information. It then processes
153 * the array of the screen's visuals, determining whether the visual is an
154 * overlay or image visual.
155 *
156 * If the routine sucessfully obtained the visual information, it returns zero.
157 * If the routine didn't obtain the visual information, it returns non-zero.
158 *
159 ******************************************************************************/
160
161extern int32_t GetXVisualInfo(
162#if NeedFunctionPrototypes
163 Display *display, /* Which X server (aka "display"). */
164 int32_t screen, /* Which screen of the "display". */
165 int32_t *transparentOverlays, /* Non-zero if there's at least one
166 * overlay visual and if at least one
167 * of those supports a transparent
168 * pixel. */
169 int32_t *numVisuals, /* Number of XVisualInfo struct's
170 * pointed to to by pVisuals. */
171 XVisualInfo **pVisuals, /* All of the device's visuals. */
172 int32_t *numOverlayVisuals, /* Number of OverlayInfo's pointed
173 * to by pOverlayVisuals. If this
174 * number is zero, the device does
175 * not have overlay planes. */
176 OverlayInfo **pOverlayVisuals, /* The device's overlay plane visual
177 * information. */
178 int32_t *numImageVisuals, /* Number of XVisualInfo's pointed
179 * to by pImageVisuals. */
180 XVisualInfo ***pImageVisuals /* The device's image visuals. */
181#endif
182 );
183
184
185/******************************************************************************
186 *
187 * FreeXVisualInfo()
188 *
189 * This routine frees the data that was allocated by GetXVisualInfo().
190 *
191 ******************************************************************************/
192
193extern void FreeXVisualInfo(
194#if NeedFunctionPrototypes
195 XVisualInfo *pVisuals,
196 OverlayInfo *pOverlayVisuals,
197 XVisualInfo **pImageVisuals
198#endif
199 );
200
201
202/******************************************************************************
203 *
204 * FindImagePlanesVisual()
205 *
206 * This routine attempts to find a visual to use to create an image planes
207 * window based upon the information passed in.
208 *
209 * The "Hint" values give guides to the routine as to what the program wants.
210 * The "depthFlexibility" value tells the routine how much the program wants
211 * the actual "depthHint" specified. If the program can't live with the
212 * screen's image planes visuals, the routine returns non-zero, and the
213 * "depthObtained" and "pImageVisualToUse" return parameters are NOT valid.
214 * Otherwise, the "depthObtained" and "pImageVisualToUse" return parameters
215 * are valid and the routine returns zero.
216 *
217 * NOTE: This is just an example of what can be done. It may or may not be
218 * useful for any specific application.
219 *
220 ******************************************************************************/
221
222extern int32_t FindImagePlanesVisual(
223#if NeedFunctionPrototypes
224 Display *display, /* Which X server (aka "display"). */
225 int32_t screen, /* Which screen of the "display". */
226 int32_t numImageVisuals, /* Number of XVisualInfo's pointed
227 * to by pImageVisuals. */
228 XVisualInfo **pImageVisuals, /* The device's image visuals. */
229 int32_t sbCmapHint, /* What Starbase cmap modes will be
230 * used with the visual. NOTE: This
231 * is a mask of the possible values. */
232 int32_t depthHint, /* Desired depth. */
233 int32_t depthFlexibility, /* How much the actual value in
234 * "depthHint" is desired. */
235 Visual **pImageVisualToUse, /* The screen's image visual to use. */
236 int32_t *depthObtained /* Actual depth of the visual. */
237#endif
238 );
239
240
241/******************************************************************************
242 *
243 * FindOverlayPlanesVisual()
244 *
245 * This routine attempts to find a visual to use to create an overlay planes
246 * window based upon the information passed in.
247 *
248 * While the CreateImagePlanesWindow() routine took a sbCmapHint, this
249 * routine doesn't. Starbase's CMAP_FULL shouldn't be used in overlay planes
250 * windows. This is partially because this functionality is better suited in
251 * the image planes where there are generally more planes, and partially
252 * because the overlay planes generally have PseudoColor visuals with one
253 * color being transparent (the transparent normally being the "white" color
254 * for CMAP_FULL).
255 *
256 * The "depthHint" values give guides to the routine as to what depth the
257 * program wants the window to be. The "depthFlexibility" value tells the
258 * routine how much the program wants the actual "depthHint" specified. If
259 * the program can't live with the screen's overlay planes visuals, the
260 * routine returns non-zero, and the "depthObtained" and "pOverlayVisualToUse"
261 * return parameters are NOT valid. Otherwise, the "depthObtained" and
262 * "pOverlayVisualToUse" return parameters are valid and the routine returns
263 * zero.
264 *
265 * NOTE: This is just an example of what can be done. It may or may not be
266 * useful for any specific application.
267 *
268 ******************************************************************************/
269
270extern int32_t FindOverlayPlanesVisual(
271#if NeedFunctionPrototypes
272 Display *display, /* Which X server (aka "display"). */
273 int32_t screen, /* Which screen of the "display". */
274 int32_t numOverlayVisuals, /* Number of OverlayInfo's pointed
275 * to by pOverlayVisuals. */
276 OverlayInfo *pOverlayVisuals, /* The device's overlay plane visual
277 * information. */
278 int32_t depthHint, /* Desired depth. */
279 int32_t depthFlexibility, /* How much the actual value in
280 * "depthHint" is desired. */
281 int32_t transparentBackground, /* Non-zero if the visual must have
282 * a transparent color. */
283 Visual **pOverlayVisualToUse, /* The screen's overlay visual to
284 * use. */
285 int32_t *depthObtained, /* Actual depth of the visual. */
286 int32_t *transparentColor /* The transparent color the program
287 * can use with the visual. */
288#endif
289 );
290
291
292/******************************************************************************
293 *
294 * CreateImagePlanesWindow()
295 *
296 * This routine creates an image planes window, potentially creates a colormap
297 * for the window to use, and sets the window's standard properties, based
298 * upon the information passed in to the routine. While "created," the window
299 * has not been mapped.
300 *
301 * If the routine suceeds, it returns zero and the return parameters
302 * "imageWindow", "imageColormap" and "mustFreeImageColormap" are valid.
303 * Otherwise, the routine returns non-zero and the return parameters are
304 * NOT valid.
305 *
306 * NOTE: This is just an example of what can be done. It may or may not be
307 * useful for any specific application.
308 *
309 ******************************************************************************/
310
311extern int32_t CreateImagePlanesWindow(
312#if NeedFunctionPrototypes
313 Display *display, /* Which X server (aka "display"). */
314 int32_t screen, /* Which screen of the "display". */
315 Window parentWindow, /* Window ID of the parent window for
316 * the created window. */
317 int32_t windowX, /* Desired X coord. of the window. */
318 int32_t windowY, /* Desired Y coord of the window. */
319 int32_t windowWidth, /* Desired width of the window. */
320 int32_t windowHeight, /* Desired height of the window. */
321 int32_t windowDepth, /* Desired depth of the window. */
322 Visual *pImageVisualToUse, /* The window's image planes visual. */
323 int32_t argc, /* Program's argc parameter. */
324 char *argv[], /* Program's argv parameter. */
325 char *windowName, /* Name to put on window's border. */
326 char *iconName, /* Name to put on window's icon. */
327 Window *imageWindow, /* Window ID of the created window. */
328 Colormap *imageColormap, /* The window's colormap. */
329 int32_t *mustFreeImageColormap /* Non-zero if the program must call
330 * XFreeColormap() for imageColormap. */
331#endif
332 );
333
334
335/******************************************************************************
336 *
337 * CreateOverlayPlanesWindow()
338 *
339 * This routine creates an overlay planes window, potentially creates a colormap
340 * for the window to use, and sets the window's standard properties, based
341 * upon the information passed in to the routine. While "created," the window
342 * has not been mapped.
343 *
344 * If the routine suceeds, it returns zero and the return parameters
345 * "overlayWindow", "overlayColormap" and "mustFreeOverlayColormap" are valid.
346 * Otherwise, the routine returns non-zero and the return parameters are
347 * NOT valid.
348 *
349 * NOTE: This is just an example of what can be done. It may or may not be
350 * useful for any specific application.
351 *
352 ******************************************************************************/
353
354int32_t CreateOverlayPlanesWindow(
355#if NeedFunctionPrototypes
356 Display *display, /* Which X server (aka "display"). */
357 int32_t screen, /* Which screen of the "display". */
358 Window parentWindow, /* Window ID of the parent window for
359 * the created window. */
360 int32_t windowX, /* Desired X coord. of the window. */
361 int32_t windowY, /* Desired Y coord of the window. */
362 int32_t windowWidth, /* Desired width of the window. */
363 int32_t windowHeight, /* Desired height of the window. */
364 int32_t windowDepth, /* Desired depth of the window. */
365 Visual *pOverlayVisualToUse, /* The window's overlay planes visual.*/
366 int32_t argc, /* Program's argc parameter. */
367 char *argv[], /* Program's argv parameter. */
368 char *windowName, /* Name to put on window's border. */
369 char *iconName, /* Name to put on window's icon. */
370 int32_t transparentBackground, /* Non-zero if the window's background
371 * should be a transparent color. */
372 int32_t *transparentColor, /* The transparent color to use as the
373 * window's background. */
374 Window *overlayWindow, /* Window ID of the created window. */
375 Colormap *overlayColormap, /* The window's colormap. */
376 int32_t *mustFreeOverlayColormap/* Non-zero if the program must call
377 * XFreeColormap() for
378 * overlayColormap. */
379#endif
380 );