0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A/* $XConsortium: wsutils.h /main/3 1996/10/14 15:04:17 swick $ */
0N/A/** ------------------------------------------------------------------------
0N/A This file contains routines for manipulating generic lists.
0N/A Lists are implemented with a "harness". In other words, each
0N/A node in the list consists of two pointers, one to the data item
0N/A and one to the next node in the list. The head of the list is
0N/A the same struct as each node, but the "item" ptr is used to point
0N/A to the current member of the list (used by the first_in_list and
0N/A next_in_list functions).
0N/A
0N/A This file is available under and governed by the GNU General Public
0N/A License version 2 only, as published by the Free Software Foundation.
0N/A However, the following notice accompanied the original version of this
0N/A file:
0N/A
0N/ACopyright (c) 1994 Hewlett-Packard Co.
0N/ACopyright (c) 1996 X Consortium
0N/A
0N/APermission is hereby granted, free of charge, to any person obtaining
0N/Aa copy of this software and associated documentation files (the
0N/A"Software"), to deal in the Software without restriction, including
0N/Awithout limitation the rights to use, copy, modify, merge, publish,
0N/Adistribute, sublicense, and sell copies of the Software, and to
0N/Apermit persons to whom the Software is furnished to do so, subject to
0N/Athe following conditions:
0N/A
0N/AThe above copyright notice and this permission notice shall be included
0N/Ain all copies or substantial portions of the Software.
0N/A
0N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0N/AOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0N/AMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0N/AIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
0N/AOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0N/AARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0N/AOTHER DEALINGS IN THE SOFTWARE.
0N/A
0N/AExcept as contained in this notice, the name of the X Consortium shall
0N/Anot be used in advertising or otherwise to promote the sale, use or
0N/Aother dealings in this Software without prior written authorization
0N/Afrom the X Consortium.
0N/A
0N/A ------------------------------------------------------------------------ **/
0N/A/******************************************************************************
0N/A *
0N/A * This file contains various typedef's, macros and procedure declarations for
0N/A * a set of example utility procedures contained in the file "wsutils.c".
0N/A *
0N/A ******************************************************************************/
0N/A
0N/A/* This is the actual structure returned by the X server describing the
0N/A * SERVER_OVERLAY_VISUAL property.
0N/A */
0N/Atypedef struct
0N/A{
0N/A VisualID visualID; /* The VisualID of the overlay visual */
0N/A long transparentType; /* Can be None, TransparentPixel or
0N/A * TransparentMask */
0N/A long value; /* Pixel value */
0N/A long layer; /* Overlay planes will always be in
0N/A * layer 1 */
0N/A} OverlayVisualPropertyRec;
0N/A
0N/A
0N/A/* This is structure also describes the SERVER_OVERLAY_VISUAL property, but
0N/A * should be more useful than the one actually returned by the X server
0N/A * because it actually points to the visual's XVisualInfo struct rather than
0N/A * refering to the visual's ID.
0N/A */
0N/Atypedef struct
0N/A{
0N/A XVisualInfo *pOverlayVisualInfo; /* Pointer to the XVisualInfo struct */
0N/A long transparentType; /* Can be None, TransparentPixel or
0N/A * TransparentMask */
0N/A long value; /* Pixel value */
0N/A long layer; /* Overlay planes will always be in
0N/A * layer 1 */
0N/A} OverlayInfo;
0N/A
0N/A
0N/A/* These macros are the values of the "transparentType" above: */
0N/A#ifndef None
0N/A#define None 0
0N/A#endif
0N/A#ifndef TransparentPixel
0N/A#define TransparentPixel 1
0N/A#endif
0N/A
0N/A
0N/A/* These macros define how flexible a program is when it requests a window's
0N/A * creation with either the CreateImagePlanesWindow() or
0N/A * CreateOverlayPlanesWindow():
0N/A */
0N/A#ifndef NOT_FLEXIBLE
0N/A#define NOT_FLEXIBLE 0
0N/A#define FLEXIBLE 1
0N/A#endif
0N/A
0N/A
0N/A/* These macros define the values of the "sbCmapHint" parameter of the
0N/A * CreateImagePlanesWindow():
0N/A */
0N/A#ifndef SB_CMAP_TYPE_NORMAL
0N/A#define SB_CMAP_TYPE_NORMAL 1
0N/A#endif
0N/A
0N/A#ifndef SB_CMAP_TYPE_MONOTONIC
0N/A#define SB_CMAP_TYPE_MONOTONIC 2
0N/A#endif
0N/A
0N/A#ifndef SB_CMAP_TYPE_FULL
0N/A#define SB_CMAP_TYPE_FULL 4
0N/A#endif
0N/A
0N/A
0N/A/******************************************************************************
0N/A *
0N/A * GetXVisualInfo()
0N/A *
0N/A * This routine takes an X11 Display, screen number, and returns whether the
0N/A * screen supports transparent overlays and three arrays:
0N/A *
0N/A * 1) All of the XVisualInfo struct's for the screen.
0N/A * 2) All of the OverlayInfo struct's for the screen.
0N/A * 3) An array of pointers to the screen's image plane XVisualInfo
0N/A * structs.
0N/A *
0N/A * The code below obtains the array of all the screen's visuals, and obtains
0N/A * the array of all the screen's overlay visual information. It then processes
0N/A * the array of the screen's visuals, determining whether the visual is an
0N/A * overlay or image visual.
0N/A *
0N/A * If the routine sucessfully obtained the visual information, it returns zero.
0N/A * If the routine didn't obtain the visual information, it returns non-zero.
0N/A *
0N/A ******************************************************************************/
0N/A
0N/Aextern int32_t GetXVisualInfo(
0N/A#if NeedFunctionPrototypes
0N/A Display *display, /* Which X server (aka "display"). */
0N/A int32_t screen, /* Which screen of the "display". */
0N/A int32_t *transparentOverlays, /* Non-zero if there's at least one
0N/A * overlay visual and if at least one
0N/A * of those supports a transparent
0N/A * pixel. */
0N/A int32_t *numVisuals, /* Number of XVisualInfo struct's
0N/A * pointed to to by pVisuals. */
0N/A XVisualInfo **pVisuals, /* All of the device's visuals. */
0N/A int32_t *numOverlayVisuals, /* Number of OverlayInfo's pointed
0N/A * to by pOverlayVisuals. If this
0N/A * number is zero, the device does
0N/A * not have overlay planes. */
0N/A OverlayInfo **pOverlayVisuals, /* The device's overlay plane visual
0N/A * information. */
0N/A int32_t *numImageVisuals, /* Number of XVisualInfo's pointed
0N/A * to by pImageVisuals. */
0N/A XVisualInfo ***pImageVisuals /* The device's image visuals. */
0N/A#endif
0N/A );
0N/A
0N/A
0N/A/******************************************************************************
0N/A *
0N/A * FreeXVisualInfo()
0N/A *
0N/A * This routine frees the data that was allocated by GetXVisualInfo().
0N/A *
0N/A ******************************************************************************/
0N/A
0N/Aextern void FreeXVisualInfo(
0N/A#if NeedFunctionPrototypes
0N/A XVisualInfo *pVisuals,
0N/A OverlayInfo *pOverlayVisuals,
0N/A XVisualInfo **pImageVisuals
0N/A#endif
0N/A );
0N/A
0N/A
0N/A/******************************************************************************
0N/A *
0N/A * FindImagePlanesVisual()
0N/A *
0N/A * This routine attempts to find a visual to use to create an image planes
0N/A * window based upon the information passed in.
0N/A *
0N/A * The "Hint" values give guides to the routine as to what the program wants.
0N/A * The "depthFlexibility" value tells the routine how much the program wants
0N/A * the actual "depthHint" specified. If the program can't live with the
0N/A * screen's image planes visuals, the routine returns non-zero, and the
0N/A * "depthObtained" and "pImageVisualToUse" return parameters are NOT valid.
0N/A * Otherwise, the "depthObtained" and "pImageVisualToUse" return parameters
0N/A * are valid and the routine returns zero.
0N/A *
0N/A * NOTE: This is just an example of what can be done. It may or may not be
0N/A * useful for any specific application.
0N/A *
0N/A ******************************************************************************/
0N/A
0N/Aextern int32_t FindImagePlanesVisual(
0N/A#if NeedFunctionPrototypes
0N/A Display *display, /* Which X server (aka "display"). */
0N/A int32_t screen, /* Which screen of the "display". */
0N/A int32_t numImageVisuals, /* Number of XVisualInfo's pointed
0N/A * to by pImageVisuals. */
0N/A XVisualInfo **pImageVisuals, /* The device's image visuals. */
0N/A int32_t sbCmapHint, /* What Starbase cmap modes will be
0N/A * used with the visual. NOTE: This
0N/A * is a mask of the possible values. */
0N/A int32_t depthHint, /* Desired depth. */
0N/A int32_t depthFlexibility, /* How much the actual value in
0N/A * "depthHint" is desired. */
0N/A Visual **pImageVisualToUse, /* The screen's image visual to use. */
0N/A int32_t *depthObtained /* Actual depth of the visual. */
0N/A#endif
0N/A );
0N/A
0N/A
0N/A/******************************************************************************
0N/A *
0N/A * FindOverlayPlanesVisual()
0N/A *
0N/A * This routine attempts to find a visual to use to create an overlay planes
0N/A * window based upon the information passed in.
0N/A *
0N/A * While the CreateImagePlanesWindow() routine took a sbCmapHint, this
0N/A * routine doesn't. Starbase's CMAP_FULL shouldn't be used in overlay planes
0N/A * windows. This is partially because this functionality is better suited in
0N/A * the image planes where there are generally more planes, and partially
0N/A * because the overlay planes generally have PseudoColor visuals with one
0N/A * color being transparent (the transparent normally being the "white" color
0N/A * for CMAP_FULL).
0N/A *
0N/A * The "depthHint" values give guides to the routine as to what depth the
0N/A * program wants the window to be. The "depthFlexibility" value tells the
0N/A * routine how much the program wants the actual "depthHint" specified. If
0N/A * the program can't live with the screen's overlay planes visuals, the
0N/A * routine returns non-zero, and the "depthObtained" and "pOverlayVisualToUse"
0N/A * return parameters are NOT valid. Otherwise, the "depthObtained" and
0N/A * "pOverlayVisualToUse" return parameters are valid and the routine returns
0N/A * zero.
0N/A *
0N/A * NOTE: This is just an example of what can be done. It may or may not be
0N/A * useful for any specific application.
0N/A *
0N/A ******************************************************************************/
0N/A
0N/Aextern int32_t FindOverlayPlanesVisual(
0N/A#if NeedFunctionPrototypes
0N/A Display *display, /* Which X server (aka "display"). */
0N/A int32_t screen, /* Which screen of the "display". */
0N/A int32_t numOverlayVisuals, /* Number of OverlayInfo's pointed
0N/A * to by pOverlayVisuals. */
0N/A OverlayInfo *pOverlayVisuals, /* The device's overlay plane visual
0N/A * information. */
0N/A int32_t depthHint, /* Desired depth. */
0N/A int32_t depthFlexibility, /* How much the actual value in
0N/A * "depthHint" is desired. */
0N/A int32_t transparentBackground, /* Non-zero if the visual must have
0N/A * a transparent color. */
0N/A Visual **pOverlayVisualToUse, /* The screen's overlay visual to
0N/A * use. */
0N/A int32_t *depthObtained, /* Actual depth of the visual. */
0N/A int32_t *transparentColor /* The transparent color the program
0N/A * can use with the visual. */
0N/A#endif
0N/A );
0N/A
0N/A
0N/A/******************************************************************************
0N/A *
0N/A * CreateImagePlanesWindow()
0N/A *
0N/A * This routine creates an image planes window, potentially creates a colormap
0N/A * for the window to use, and sets the window's standard properties, based
0N/A * upon the information passed in to the routine. While "created," the window
0N/A * has not been mapped.
0N/A *
0N/A * If the routine suceeds, it returns zero and the return parameters
0N/A * "imageWindow", "imageColormap" and "mustFreeImageColormap" are valid.
0N/A * Otherwise, the routine returns non-zero and the return parameters are
0N/A * NOT valid.
0N/A *
0N/A * NOTE: This is just an example of what can be done. It may or may not be
0N/A * useful for any specific application.
0N/A *
0N/A ******************************************************************************/
0N/A
0N/Aextern int32_t CreateImagePlanesWindow(
0N/A#if NeedFunctionPrototypes
0N/A Display *display, /* Which X server (aka "display"). */
0N/A int32_t screen, /* Which screen of the "display". */
0N/A Window parentWindow, /* Window ID of the parent window for
0N/A * the created window. */
0N/A int32_t windowX, /* Desired X coord. of the window. */
0N/A int32_t windowY, /* Desired Y coord of the window. */
0N/A int32_t windowWidth, /* Desired width of the window. */
0N/A int32_t windowHeight, /* Desired height of the window. */
0N/A int32_t windowDepth, /* Desired depth of the window. */
0N/A Visual *pImageVisualToUse, /* The window's image planes visual. */
0N/A int32_t argc, /* Program's argc parameter. */
0N/A char *argv[], /* Program's argv parameter. */
0N/A char *windowName, /* Name to put on window's border. */
0N/A char *iconName, /* Name to put on window's icon. */
0N/A Window *imageWindow, /* Window ID of the created window. */
0N/A Colormap *imageColormap, /* The window's colormap. */
0N/A int32_t *mustFreeImageColormap /* Non-zero if the program must call
0N/A * XFreeColormap() for imageColormap. */
0N/A#endif
0N/A );
0N/A
0N/A
0N/A/******************************************************************************
0N/A *
0N/A * CreateOverlayPlanesWindow()
0N/A *
0N/A * This routine creates an overlay planes window, potentially creates a colormap
0N/A * for the window to use, and sets the window's standard properties, based
0N/A * upon the information passed in to the routine. While "created," the window
0N/A * has not been mapped.
0N/A *
0N/A * If the routine suceeds, it returns zero and the return parameters
0N/A * "overlayWindow", "overlayColormap" and "mustFreeOverlayColormap" are valid.
0N/A * Otherwise, the routine returns non-zero and the return parameters are
0N/A * NOT valid.
0N/A *
0N/A * NOTE: This is just an example of what can be done. It may or may not be
0N/A * useful for any specific application.
0N/A *
0N/A ******************************************************************************/
0N/A
0N/Aint32_t CreateOverlayPlanesWindow(
0N/A#if NeedFunctionPrototypes
0N/A Display *display, /* Which X server (aka "display"). */
0N/A int32_t screen, /* Which screen of the "display". */
0N/A Window parentWindow, /* Window ID of the parent window for
0N/A * the created window. */
0N/A int32_t windowX, /* Desired X coord. of the window. */
0N/A int32_t windowY, /* Desired Y coord of the window. */
0N/A int32_t windowWidth, /* Desired width of the window. */
0N/A int32_t windowHeight, /* Desired height of the window. */
0N/A int32_t windowDepth, /* Desired depth of the window. */
0N/A Visual *pOverlayVisualToUse, /* The window's overlay planes visual.*/
0N/A int32_t argc, /* Program's argc parameter. */
0N/A char *argv[], /* Program's argv parameter. */
0N/A char *windowName, /* Name to put on window's border. */
0N/A char *iconName, /* Name to put on window's icon. */
0N/A int32_t transparentBackground, /* Non-zero if the window's background
0N/A * should be a transparent color. */
0N/A int32_t *transparentColor, /* The transparent color to use as the
0N/A * window's background. */
0N/A Window *overlayWindow, /* Window ID of the created window. */
0N/A Colormap *overlayColormap, /* The window's colormap. */
0N/A int32_t *mustFreeOverlayColormap/* Non-zero if the program must call
0N/A * XFreeColormap() for
0N/A * overlayColormap. */
0N/A#endif
0N/A );