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