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