Back to index

im-sdk  12.3.91
xaux_common.h
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2003 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 
00043 #ifndef       XAUX_COMMON_H
00044 #define       XAUX_COMMON_H
00045 
00046 #pragma ident "$Id$"
00047 
00048 #define       ME_SO  "xaux_so"
00049 #define       ME_EXT "xaux_ext"
00050 
00051 #define       XAUX_SOWIN_SUFFIX    "_sowin"
00052 #define       XAUX_EXTWIN_SUFFIX   "_extwin"
00053 #define       XAUX_XS_SUFFIX              "_xs"
00054 #define       XAUX_SX_SUFFIX              "_sx"
00055 
00056 #define       XAUX_MAXCLASSNAMELEN 255
00057 #define       XAUX_MAXSUFFIXLEN    16
00058 #define       XAUX_MAXPROPSZ              0x30000
00059 
00060 #define       XAUX_MAXNPROPS_INIT  64
00061 
00062 typedef enum {
00063        XAUX_PRIVTYPE_PUBLIC = 0,
00064        XAUX_PRIVTYPE_REQSEG = 1
00065 } xaux_privtype_t;
00066 
00067 #define       XAUX_PROTOVERS_MAJOR 1
00068 #define       XAUX_PROTOVERS_MINOR 0
00069 
00070 /* SX header */
00071 #define       SX_PROTOVERS_MAJOR(prop)    (*((CARD16 *)((prop) + 0))) /* 2 */
00072 #define       SX_PROTOVERS_MINOR(prop)    (*((CARD16 *)((prop) + 2))) /* 2 */
00073 #define       SX_SEQNO(prop)              (*((CARD32 *)((prop) + 4))) /* 4 */
00074 #define       SX_ATOM_AUX_NAME(prop)      (*((CARD32 *)((prop) + 8))) /* 4 */
00075 #define       SX_INDEX(prop)              (*((CARD16 *)((prop) + 12))) /* 2 */
00076 #define       SX_PRIVTYPE(prop)    (*((CARD8 *)((prop) + 14))) /* 1 */
00077 #define       SX_AUXTYPE(prop)     (*((CARD8 *)((prop) + 15))) /* 1 */
00078 #define       SX_IMID(prop)        (*((CARD16 *)((prop) + 16))) /* 2 */
00079 #define       SX_ICID(prop)        (*((CARD16 *)((prop) + 18))) /* 2 */
00080 #define       SX_MORESEGS(prop)    (*((CARD16 *)((prop) + 20))) /* 2 */
00081 #define       SX_SEGNO(prop)              (*((CARD16 *)((prop) + 22))) /* 2 */
00082 #define       SX_SEGSIZE(prop)     (*((CARD32 *)((prop) + 24))) /* 4 */
00083 #define       SX_SIZE_HEADER              28
00084 #define       SX_DATA_TOP(prop)    ((prop) + SX_SIZE_HEADER)
00085 
00086 /* AUX_DRAW */
00087 #define       SX_DRAW_SOWIN(draw)         (*((CARD32 *)((draw) + 0))) /* 4 */
00088 #define       SX_DRAW_CLIENTWIN(draw)            (*((CARD32 *)((draw) + 4))) /* 4 */
00089 #define       SX_DRAW_FOCUSWIN(draw)             (*((CARD32 *)((draw) + 8))) /* 4 */
00090 #define       SX_DRAW_POSX(draw)          (*((CARD16 *)((draw) + 12))) /* 2 */
00091 #define       SX_DRAW_POSY(draw)          (*((CARD16 *)((draw) + 14))) /* 2 */
00092 #define       SX_DRAW_INT_COUNT(draw)            (*((CARD32 *)((draw) + 16))) /* 4 */
00093 #define       SX_DRAW_STR_COUNT(draw)            (*((CARD32 *)((draw) + 20))) /* 4 */
00094 #define       SX_DRAW_TOTAL_STR_LEN(draw) (*((CARD32 *)((draw) + 24))) /* 4 */
00095 #define SX_SIZE_DRAW_HEADER        28
00096 #define       SX_DRAW_INT_LIST(draw) \
00097        ((CARD32 *)((draw) + SX_SIZE_DRAW_HEADER))
00098 #define       SX_DRAW_STR_LIST(draw) \
00099        ((unsigned char *)((draw) + SX_SIZE_DRAW_HEADER) \
00100               + SX_DRAW_INT_COUNT((draw)) * 4)
00101 
00102 /* XS header */
00103 #define       XS_PROTOVERS_MAJOR(prop)    (*((CARD16 *)((prop) + 0))) /* 2 */
00104 #define       XS_PROTOVERS_MINOR(prop)    (*((CARD16 *)((prop) + 2))) /* 2 */
00105 #define       XS_SEQNO(prop)              (*((CARD32 *)((prop) + 4))) /* 4 */
00106 #define       XS_ATOM_AUX_NAME(prop)      (*((CARD32 *)((prop) + 8))) /* 4 */
00107 #define       XS_INDEX(prop)              (*((CARD16 *)((prop) + 12))) /* 2 */
00108 #define       XS_PRIVTYPE(prop)    (*((CARD8 *)((prop) + 14))) /* 1 */
00109 #define       XS_AUXTYPE(prop)     (*((CARD8 *)((prop) + 15))) /* 1 */
00110 #define       XS_IMID(prop)        (*((CARD16 *)((prop) + 16))) /* 2 */
00111 #define       XS_ICID(prop)        (*((CARD16 *)((prop) + 18))) /* 2 */
00112 #define       XS_MORESEGS(prop)    (*((CARD16 *)((prop) + 20))) /* 2 */
00113 #define       XS_SEGNO(prop)              (*((CARD16 *)((prop) + 22))) /* 2 */
00114 #define       XS_SEGSIZE(prop)     (*((CARD32 *)((prop) + 24))) /* 4 */
00115 #define       XS_SIZE_HEADER              28
00116 #define       XS_DATA_TOP(prop)    ((prop) + XS_SIZE_HEADER)
00117 
00118 /* AUX_SETVALUE */
00119 #define       XS_SETV_INT_COUNT(setvalue) (*((CARD32 *)((setvalue) + 0))) /* 4 */
00120 #define       XS_SETV_STR_COUNT(setvalue) (*((CARD32 *)((setvalue) + 4))) /* 4 */
00121 #define XS_SIZE_SETV_HEADER        8
00122 #define       XS_SETV_INT_LIST(setvalue) \
00123        ((CARD32 *)((setvalue) + XS_SIZE_SETV_HEADER))
00124 #define       XS_SETV_STR_LIST(setvalue) \
00125        ((unsigned char *)((setvalue) + XS_SIZE_SETV_HEADER) \
00126               + XS_SETV_INT_COUNT((setvalue)) * 4)
00127 
00128 /* byte order */
00129 #define       BO_SWAP2(n)   ((((*((CARD8 *)(n))) | 0x0000ff00) >> 8) | \
00130                       (((*((CARD8 *)(n))) | 0x000000ff) << 8))
00131 #define       BO_SWAP4(n)   ((((*((CARD8 *)(n))) | 0xff000000) >> 24) | \
00132                       (((*((CARD8 *)(n))) | 0x00ff0000) >> 8)  | \
00133                       (((*((CARD8 *)(n))) | 0x0000ff00) << 8)  | \
00134                       (((*((CARD8 *)(n))) | 0x000000ff) << 24))
00135                                                  
00136 #define       BO_CARD16(p, n)      ((1 == (*((CARD16 *)(p)))) ? \
00137                       *((CARD16 *)(n)) : ((CARD16)(BO_SWAP2(n))))
00138 
00139 #define       BO_CARD32(p, n)      ((1 == (*((CARD16 *)(p)))) ? \
00140                       *((CARD32 *)(n)) : ((CARD32)(BO_SWAP4(n))))
00141 
00142 #define       BO_PROTOVERS_MAJOR(prop)    ((1 == (*((CARD16 *)(prop)))) ? \
00143                                     (*((CARD16 *)((prop) + 0))) : \
00144                                     BO_SWAP2((prop) + 0))
00145 #define       BO_PROTOVERS_MINOR(prop)    ((1 == (*((CARD16 *)(prop)))) ? \
00146                                     (*((CARD16 *)((prop) + 2))) : \
00147                                     BO_SWAP2((prop) + 2))
00148 #define       BO_SEQNO(prop)                     ((1 == (*((CARD16 *)(prop)))) ? \
00149                                     (*((CARD32 *)((prop) + 4))) : \
00150                                     BO_SWAP4((prop) + 4))
00151 #define       BO_ATOM_AUX_NAME(prop)             ((1 == (*((CARD16 *)(prop)))) ? \
00152                                     (*((CARD32 *)((prop) + 8))) : \
00153                                     BO_SWAP4((prop) + 8))
00154 #define       BO_INDEX(prop)                     ((1 == (*((CARD16 *)(prop)))) ? \
00155                                     (*((CARD16 *)((prop) + 12))) : \
00156                                     BO_SWAP2((prop) + 12))
00157 #define       BO_PRIVTYPE(prop)           (*((CARD8 *)((prop) + 14)))
00158 #define       BO_AUXTYPE(prop)            (*((CARD8 *)((prop) + 15)))
00159 #define       BO_IMID(prop)               ((1 == (*((CARD16 *)(prop)))) ? \
00160                                     (*((CARD16 *)((prop) + 16))) : \
00161                                     BO_SWAP2((prop) + 16))
00162 #define       BO_ICID(prop)               ((1 == (*((CARD16 *)(prop)))) ? \
00163                                     (*((CARD16 *)((prop) + 18))) : \
00164                                     BO_SWAP2((prop) + 18))
00165 #define       BO_MORESEGS(prop)           ((1 == (*((CARD16 *)(prop)))) ? \
00166                                     (*((CARD16 *)((prop) + 20))) : \
00167                                     BO_SWAP2((prop) + 20))
00168 #define       BO_SEGNO(prop)                     ((1 == (*((CARD16 *)(prop)))) ? \
00169                                     (*((CARD16 *)((prop) + 22))) : \
00170                                     BO_SWAP2((prop) + 22))
00171 #define       BO_SEGSIZE(prop)            ((1 == (*((CARD16 *)(prop)))) ? \
00172                                     (*((CARD32 *)((prop) + 24))) : \
00173                                     BO_SWAP4((prop) + 24))
00174 
00175 #define       BO_DRAW_SOWIN(prop)         ((1 == (*((CARD16 *)(prop)))) ? \
00176                                     (*((CARD32 *)((prop) + 28))) : \
00177                                     BO_SWAP4((prop) + 28))
00178 #define       BO_DRAW_CLIENTWIN(prop)            ((1 == (*((CARD16 *)(prop)))) ? \
00179                                     (*((CARD32 *)((prop) + 32))) : \
00180                                     BO_SWAP4((prop) + 32))
00181 #define       BO_DRAW_FOCUSWIN(prop)             ((1 == (*((CARD16 *)(prop)))) ? \
00182                                     (*((CARD32 *)((prop) + 36))) : \
00183                                     BO_SWAP4((prop) + 36))
00184 #define       BO_DRAW_POSX(prop)          ((1 == (*((CARD16 *)(prop)))) ? \
00185                                     (*((CARD16 *)((prop) + 40))) : \
00186                                     BO_SWAP2((prop) + 40))
00187 #define       BO_DRAW_POSY(prop)          ((1 == (*((CARD16 *)(prop)))) ? \
00188                                     (*((CARD16 *)((prop) + 42))) : \
00189                                     BO_SWAP2((prop) + 42))
00190 #define       BO_DRAW_INT_COUNT(prop)            ((1 == (*((CARD16 *)(prop)))) ? \
00191                                     (*((CARD32 *)((prop) + 44))) : \
00192                                     BO_SWAP4((prop) + 44))
00193 #define       BO_DRAW_STR_COUNT(prop)            ((1 == (*((CARD16 *)(prop)))) ? \
00194                                     (*((CARD32 *)((prop) + 48))) : \
00195                                     BO_SWAP4((prop) + 48))
00196 #define       BO_DRAW_TOTAL_STR_LEN(prop) ((1 == (*((CARD16 *)(prop)))) ? \
00197                                     (*((CARD32 *)((prop) + 52))) : \
00198                                     BO_SWAP4((prop) + 52))
00199 #define BO_SIZE_DRAW_HEADER        28
00200 #define       BO_DRAW_INT_LIST(prop) \
00201        ((CARD32 *)((prop) + BO_SIZE_DRAW_HEADER))
00202 #define       BO_DRAW_STR_LIST(prop) \
00203        ((unsigned char *)((prop) + BO_SIZE_DRAW_HEADER) \
00204               + BO_DRAW_INT_COUNT((prop)) * 4)
00205 
00206 #define       BO_SETV_INT_COUNT(prop)            ((1 == (*((CARD16 *)(prop)))) ? \
00207                                     (*((CARD32 *)((prop) + 28))) : \
00208                                     BO_SWAP4((prop) + 28))
00209 #define       BO_SETV_STR_COUNT(prop)            ((1 == (*((CARD16 *)(prop)))) ? \
00210                                     (*((CARD32 *)((prop) + 32))) : \
00211                                     BO_SWAP4((prop) + 32))
00212 #define BO_SIZE_SETV_HEADER        8
00213 #define       BO_SETV_INT_LIST(prop) \
00214        ((CARD32 *)((prop) + BO_SIZE_SETV_HEADER))
00215 #define       BO_SETV_STR_LIST(prop) \
00216        ((unsigned char *)((prop) + BO_SIZE_SETV_HEADER) \
00217               + BO_SETV_INT_COUNT((prop)) * 4)
00218 
00219 #include      "xaux_atommng.h"
00220 
00221 static const int     padding[4] = {0, 3, 2, 1};
00222 
00223 #endif /* !XAUX_COMMON_H */