Path: blob/master/src/java.desktop/unix/native/libawt_xawt/awt/wsutils.h
41155 views
/*1* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.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 it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/** ------------------------------------------------------------------------25This file contains routines for manipulating generic lists.26Lists are implemented with a "harness". In other words, each27node in the list consists of two pointers, one to the data item28and one to the next node in the list. The head of the list is29the same struct as each node, but the "item" ptr is used to point30to the current member of the list (used by the first_in_list and31next_in_list functions).3233This file is available under and governed by the GNU General Public34License version 2 only, as published by the Free Software Foundation.35However, the following notice accompanied the original version of this36file:3738Copyright 1994 Hewlett-Packard Co.39Copyright 1996, 1998 The Open Group4041Permission to use, copy, modify, distribute, and sell this software and its42documentation for any purpose is hereby granted without fee, provided that43the above copyright notice appear in all copies and that both that44copyright notice and this permission notice appear in supporting45documentation.4647The above copyright notice and this permission notice shall be included48in all copies or substantial portions of the Software.4950THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS51OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF52MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.53IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR54OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,55ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR56OTHER DEALINGS IN THE SOFTWARE.5758Except as contained in this notice, the name of The Open Group shall59not be used in advertising or otherwise to promote the sale, use or60other dealings in this Software without prior written authorization61from The Open Group.6263------------------------------------------------------------------------ **/6465/******************************************************************************66*67* This file contains various typedef's, macros and procedure declarations for68* a set of example utility procedures contained in the file "wsutils.c".69*70******************************************************************************/7172#ifdef HEADLESS73#error This file should not be included in headless library74#endif7576typedef unsigned long Pixel;7778/* This is the actual structure returned by the X server describing the79* SERVER_OVERLAY_VISUAL property.80*/81typedef struct82{83VisualID visualID; /* The VisualID of the overlay visual */84int transparentType; /* Can be None, TransparentPixel or85* TransparentMask */86Pixel value; /* Pixel value */87int layer; /* Overlay planes will always be in88* layer 1 */89} OverlayVisualPropertyRec;909192/* This is structure also describes the SERVER_OVERLAY_VISUAL property, but93* should be more useful than the one actually returned by the X server94* because it actually points to the visual's XVisualInfo struct rather than95* refering to the visual's ID.96*/97typedef struct98{99XVisualInfo *pOverlayVisualInfo; /* Pointer to the XVisualInfo struct */100int transparentType; /* Can be None, TransparentPixel or101* TransparentMask */102Pixel value; /* Pixel value */103int layer; /* Overlay planes will always be in104* layer 1 */105} OverlayInfo;106107108/* These macros are the values of the "transparentType" above: */109#ifndef None110#define None 0111#endif112#ifndef TransparentPixel113#define TransparentPixel 1114#endif115116117/* These macros define how flexible a program is when it requests a window's118* creation with either the CreateImagePlanesWindow() or119* CreateOverlayPlanesWindow():120*/121#ifndef NOT_FLEXIBLE122#define NOT_FLEXIBLE 0123#define FLEXIBLE 1124#endif125126127/* These macros define the values of the "sbCmapHint" parameter of the128* CreateImagePlanesWindow():129*/130#ifndef SB_CMAP_TYPE_NORMAL131#define SB_CMAP_TYPE_NORMAL 1132#endif133134#ifndef SB_CMAP_TYPE_MONOTONIC135#define SB_CMAP_TYPE_MONOTONIC 2136#endif137138#ifndef SB_CMAP_TYPE_FULL139#define SB_CMAP_TYPE_FULL 4140#endif141142143/******************************************************************************144*145* GetXVisualInfo()146*147* This routine takes an X11 Display, screen number, and returns whether the148* screen supports transparent overlays and three arrays:149*150* 1) All of the XVisualInfo struct's for the screen.151* 2) All of the OverlayInfo struct's for the screen.152* 3) An array of pointers to the screen's image plane XVisualInfo153* structs.154*155* The code below obtains the array of all the screen's visuals, and obtains156* the array of all the screen's overlay visual information. It then processes157* the array of the screen's visuals, determining whether the visual is an158* overlay or image visual.159*160* If the routine sucessfully obtained the visual information, it returns zero.161* If the routine didn't obtain the visual information, it returns non-zero.162*163******************************************************************************/164165extern int GetXVisualInfo(166Display *display, /* Which X server (aka "display"). */167int screen, /* Which screen of the "display". */168int *transparentOverlays, /* Non-zero if there's at least one169* overlay visual and if at least one170* of those supports a transparent171* pixel. */172int *numVisuals, /* Number of XVisualInfo struct's173* pointed to to by pVisuals. */174XVisualInfo **pVisuals, /* All of the device's visuals. */175int *numOverlayVisuals, /* Number of OverlayInfo's pointed176* to by pOverlayVisuals. If this177* number is zero, the device does178* not have overlay planes. */179OverlayInfo **pOverlayVisuals, /* The device's overlay plane visual180* information. */181int *numImageVisuals, /* Number of XVisualInfo's pointed182* to by pImageVisuals. */183XVisualInfo ***pImageVisuals /* The device's image visuals. */184);185186187/******************************************************************************188*189* FreeXVisualInfo()190*191* This routine frees the data that was allocated by GetXVisualInfo().192*193******************************************************************************/194195extern void FreeXVisualInfo(196XVisualInfo *pVisuals,197OverlayInfo *pOverlayVisuals,198XVisualInfo **pImageVisuals199);200201202/******************************************************************************203*204* FindImagePlanesVisual()205*206* This routine attempts to find a visual to use to create an image planes207* 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 wants211* the actual "depthHint" specified. If the program can't live with the212* screen's image planes visuals, the routine returns non-zero, and the213* "depthObtained" and "pImageVisualToUse" return parameters are NOT valid.214* Otherwise, the "depthObtained" and "pImageVisualToUse" return parameters215* 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 be218* useful for any specific application.219*220******************************************************************************/221222extern int FindImagePlanesVisual(223Display *display, /* Which X server (aka "display"). */224int screen, /* Which screen of the "display". */225int numImageVisuals, /* Number of XVisualInfo's pointed226* to by pImageVisuals. */227XVisualInfo **pImageVisuals, /* The device's image visuals. */228int sbCmapHint, /* What Starbase cmap modes will be229* used with the visual. NOTE: This230* is a mask of the possible values. */231int depthHint, /* Desired depth. */232int depthFlexibility, /* How much the actual value in233* "depthHint" is desired. */234Visual **pImageVisualToUse, /* The screen's image visual to use. */235int *depthObtained /* Actual depth of the visual. */236);237238239/******************************************************************************240*241* FindOverlayPlanesVisual()242*243* This routine attempts to find a visual to use to create an overlay planes244* window based upon the information passed in.245*246* While the CreateImagePlanesWindow() routine took a sbCmapHint, this247* routine doesn't. Starbase's CMAP_FULL shouldn't be used in overlay planes248* windows. This is partially because this functionality is better suited in249* the image planes where there are generally more planes, and partially250* because the overlay planes generally have PseudoColor visuals with one251* color being transparent (the transparent normally being the "white" color252* for CMAP_FULL).253*254* The "depthHint" values give guides to the routine as to what depth the255* program wants the window to be. The "depthFlexibility" value tells the256* routine how much the program wants the actual "depthHint" specified. If257* the program can't live with the screen's overlay planes visuals, the258* routine returns non-zero, and the "depthObtained" and "pOverlayVisualToUse"259* return parameters are NOT valid. Otherwise, the "depthObtained" and260* "pOverlayVisualToUse" return parameters are valid and the routine returns261* zero.262*263* NOTE: This is just an example of what can be done. It may or may not be264* useful for any specific application.265*266******************************************************************************/267268extern int FindOverlayPlanesVisual(269Display *display, /* Which X server (aka "display"). */270int screen, /* Which screen of the "display". */271int numOverlayVisuals, /* Number of OverlayInfo's pointed272* to by pOverlayVisuals. */273OverlayInfo *pOverlayVisuals, /* The device's overlay plane visual274* information. */275int depthHint, /* Desired depth. */276int depthFlexibility, /* How much the actual value in277* "depthHint" is desired. */278int transparentBackground, /* Non-zero if the visual must have279* a transparent color. */280Visual **pOverlayVisualToUse, /* The screen's overlay visual to281* use. */282int *depthObtained, /* Actual depth of the visual. */283int *transparentColor /* The transparent color the program284* can use with the visual. */285);286287288/******************************************************************************289*290* CreateImagePlanesWindow()291*292* This routine creates an image planes window, potentially creates a colormap293* for the window to use, and sets the window's standard properties, based294* upon the information passed in to the routine. While "created," the window295* has not been mapped.296*297* If the routine suceeds, it returns zero and the return parameters298* "imageWindow", "imageColormap" and "mustFreeImageColormap" are valid.299* Otherwise, the routine returns non-zero and the return parameters are300* NOT valid.301*302* NOTE: This is just an example of what can be done. It may or may not be303* useful for any specific application.304*305******************************************************************************/306307extern int CreateImagePlanesWindow(308Display *display, /* Which X server (aka "display"). */309int screen, /* Which screen of the "display". */310Window parentWindow, /* Window ID of the parent window for311* the created window. */312int windowX, /* Desired X coord. of the window. */313int windowY, /* Desired Y coord of the window. */314int windowWidth, /* Desired width of the window. */315int windowHeight, /* Desired height of the window. */316int windowDepth, /* Desired depth of the window. */317Visual *pImageVisualToUse, /* The window's image planes visual. */318int argc, /* Program's argc parameter. */319char *argv[], /* Program's argv parameter. */320char *windowName, /* Name to put on window's border. */321char *iconName, /* Name to put on window's icon. */322Window *imageWindow, /* Window ID of the created window. */323Colormap *imageColormap, /* The window's colormap. */324int *mustFreeImageColormap /* Non-zero if the program must call325* XFreeColormap() for imageColormap. */326);327328329/******************************************************************************330*331* CreateOverlayPlanesWindow()332*333* This routine creates an overlay planes window, potentially creates a colormap334* for the window to use, and sets the window's standard properties, based335* upon the information passed in to the routine. While "created," the window336* has not been mapped.337*338* If the routine suceeds, it returns zero and the return parameters339* "overlayWindow", "overlayColormap" and "mustFreeOverlayColormap" are valid.340* Otherwise, the routine returns non-zero and the return parameters are341* NOT valid.342*343* NOTE: This is just an example of what can be done. It may or may not be344* useful for any specific application.345*346******************************************************************************/347348int CreateOverlayPlanesWindow(349Display *display, /* Which X server (aka "display"). */350int screen, /* Which screen of the "display". */351Window parentWindow, /* Window ID of the parent window for352* the created window. */353int windowX, /* Desired X coord. of the window. */354int windowY, /* Desired Y coord of the window. */355int windowWidth, /* Desired width of the window. */356int windowHeight, /* Desired height of the window. */357int windowDepth, /* Desired depth of the window. */358Visual *pOverlayVisualToUse, /* The window's overlay planes visual.*/359int argc, /* Program's argc parameter. */360char *argv[], /* Program's argv parameter. */361char *windowName, /* Name to put on window's border. */362char *iconName, /* Name to put on window's icon. */363int transparentBackground, /* Non-zero if the window's background364* should be a transparent color. */365int *transparentColor, /* The transparent color to use as the366* window's background. */367Window *overlayWindow, /* Window ID of the created window. */368Colormap *overlayColormap, /* The window's colormap. */369int *mustFreeOverlayColormap/* Non-zero if the program must call370* XFreeColormap() for371* overlayColormap. */372);373374375