xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

resource.h (10684B)


      1 /***********************************************************
      2 
      3 Copyright 1987, 1989, 1998  The Open Group
      4 
      5 Permission to use, copy, modify, distribute, and sell this software and its
      6 documentation for any purpose is hereby granted without fee, provided that
      7 the above copyright notice appear in all copies and that both that
      8 copyright notice and this permission notice appear in supporting
      9 documentation.
     10 
     11 The above copyright notice and this permission notice shall be included in
     12 all copies or substantial portions of the Software.
     13 
     14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     20 
     21 Except as contained in this notice, the name of The Open Group shall not be
     22 used in advertising or otherwise to promote the sale, use or other dealings
     23 in this Software without prior written authorization from The Open Group.
     24 
     25 Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
     26 
     27                         All Rights Reserved
     28 
     29 Permission to use, copy, modify, and distribute this software and its
     30 documentation for any purpose and without fee is hereby granted,
     31 provided that the above copyright notice appear in all copies and that
     32 both that copyright notice and this permission notice appear in
     33 supporting documentation, and that the name of Digital not be
     34 used in advertising or publicity pertaining to distribution of the
     35 software without specific, written prior permission.
     36 
     37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
     38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
     39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
     40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     43 SOFTWARE.
     44 
     45 ******************************************************************/
     46 
     47 #ifndef RESOURCE_H
     48 #define RESOURCE_H 1
     49 #include "misc.h"
     50 #include "dixaccess.h"
     51 
     52 /*****************************************************************
     53  * STUFF FOR RESOURCES
     54  *****************************************************************/
     55 
     56 /* classes for Resource routines */
     57 
     58 typedef uint32_t RESTYPE;
     59 
     60 #define RC_VANILLA	((RESTYPE)0)
     61 #define RC_CACHED	((RESTYPE)1<<31)
     62 #define RC_DRAWABLE	((RESTYPE)1<<30)
     63 /*  Use class RC_NEVERRETAIN for resources that should not be retained
     64  *  regardless of the close down mode when the client dies.  (A client's
     65  *  event selections on objects that it doesn't own are good candidates.)
     66  *  Extensions can use this too!
     67  */
     68 #define RC_NEVERRETAIN	((RESTYPE)1<<29)
     69 #define RC_LASTPREDEF	RC_NEVERRETAIN
     70 #define RC_ANY		(~(RESTYPE)0)
     71 
     72 /* types for Resource routines */
     73 
     74 #define RT_WINDOW	((RESTYPE)1|RC_DRAWABLE)
     75 #define RT_PIXMAP	((RESTYPE)2|RC_DRAWABLE)
     76 #define RT_GC		((RESTYPE)3)
     77 #undef RT_FONT
     78 #undef RT_CURSOR
     79 #define RT_FONT		((RESTYPE)4)
     80 #define RT_CURSOR	((RESTYPE)5)
     81 #define RT_COLORMAP	((RESTYPE)6)
     82 #define RT_CMAPENTRY	((RESTYPE)7)
     83 #define RT_OTHERCLIENT	((RESTYPE)8|RC_NEVERRETAIN)
     84 #define RT_PASSIVEGRAB	((RESTYPE)9|RC_NEVERRETAIN)
     85 #define RT_LASTPREDEF	((RESTYPE)9)
     86 #define RT_NONE		((RESTYPE)0)
     87 
     88 extern _X_EXPORT unsigned int ResourceClientBits(void);
     89 /* bits and fields within a resource id */
     90 #define RESOURCE_AND_CLIENT_COUNT   29  /* 29 bits for XIDs */
     91 #define RESOURCE_CLIENT_BITS        ResourceClientBits() /* client field offset */
     92 #define CLIENTOFFSET	    (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
     93 /* resource field */
     94 #define RESOURCE_ID_MASK	((1 << CLIENTOFFSET) - 1)
     95 /* client field */
     96 #define RESOURCE_CLIENT_MASK	(((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
     97 /* extract the client mask from an XID */
     98 #define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
     99 /* extract the client id from an XID */
    100 #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
    101 #define SERVER_BIT		(Mask)0x40000000        /* use illegal bit */
    102 
    103 #ifdef INVALID
    104 #undef INVALID                  /* needed on HP/UX */
    105 #endif
    106 
    107 /* Invalid resource id */
    108 #define INVALID	(0)
    109 
    110 #define BAD_RESOURCE 0xe0000000
    111 
    112 #define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
    113 
    114 /* Resource state callback */
    115 extern _X_EXPORT CallbackListPtr ResourceStateCallback;
    116 
    117 typedef enum { ResourceStateAdding,
    118     ResourceStateFreeing
    119 } ResourceState;
    120 
    121 typedef struct {
    122     ResourceState state;
    123     XID id;
    124     RESTYPE type;
    125     void *value;
    126 } ResourceStateInfoRec;
    127 
    128 typedef int (*DeleteType) (void *value,
    129                            XID id);
    130 
    131 typedef void (*FindResType) (void *value,
    132                              XID id,
    133                              void *cdata);
    134 
    135 typedef void (*FindAllRes) (void *value,
    136                             XID id,
    137                             RESTYPE type,
    138                             void *cdata);
    139 
    140 typedef Bool (*FindComplexResType) (void *value,
    141                                     XID id,
    142                                     void *cdata);
    143 
    144 /* Structure for estimating resource memory usage. Memory usage
    145  * consists of space allocated for the resource itself and of
    146  * references to other resources. Currently the most important use for
    147  * this structure is to estimate pixmap usage of different resources
    148  * more accurately. */
    149 typedef struct {
    150     /* Size of resource itself. Zero if not implemented. */
    151     unsigned long resourceSize;
    152     /* Size attributed to pixmap references from the resource. */
    153     unsigned long pixmapRefSize;
    154     /* Number of references to this resource; typically 1 */
    155     unsigned long refCnt;
    156 } ResourceSizeRec, *ResourceSizePtr;
    157 
    158 typedef void (*SizeType)(void *value,
    159                          XID id,
    160                          ResourceSizePtr size);
    161 
    162 extern _X_EXPORT RESTYPE CreateNewResourceType(DeleteType deleteFunc,
    163                                                const char *name);
    164 
    165 typedef void (*FindTypeSubResources)(void *value,
    166                                      FindAllRes func,
    167                                      void *cdata);
    168 
    169 extern _X_EXPORT SizeType GetResourceTypeSizeFunc(
    170     RESTYPE /*type*/);
    171 
    172 extern _X_EXPORT void SetResourceTypeFindSubResFunc(
    173     RESTYPE /*type*/, FindTypeSubResources /*findFunc*/);
    174 
    175 extern _X_EXPORT void SetResourceTypeSizeFunc(
    176     RESTYPE /*type*/, SizeType /*sizeFunc*/);
    177 
    178 extern _X_EXPORT void SetResourceTypeErrorValue(
    179     RESTYPE /*type*/, int /*errorValue*/);
    180 
    181 extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
    182 
    183 extern _X_EXPORT Bool InitClientResources(ClientPtr /*client */ );
    184 
    185 extern _X_EXPORT XID FakeClientID(int /*client */ );
    186 
    187 /* Quartz support on Mac OS X uses the CarbonCore
    188    framework whose AddResource function conflicts here. */
    189 #ifdef __APPLE__
    190 #define AddResource Darwin_X_AddResource
    191 #endif
    192 extern _X_EXPORT Bool AddResource(XID id,
    193                                   RESTYPE type,
    194                                   void *value);
    195 
    196 extern _X_EXPORT void FreeResource(XID /*id */ ,
    197                                    RESTYPE /*skipDeleteFuncType */ );
    198 
    199 extern _X_EXPORT void FreeResourceByType(XID /*id */ ,
    200                                          RESTYPE /*type */ ,
    201                                          Bool /*skipFree */ );
    202 
    203 extern _X_EXPORT Bool ChangeResourceValue(XID id,
    204                                           RESTYPE rtype,
    205                                           void *value);
    206 
    207 extern _X_EXPORT void FindClientResourcesByType(ClientPtr client,
    208                                                 RESTYPE type,
    209                                                 FindResType func,
    210                                                 void *cdata);
    211 
    212 extern _X_EXPORT void FindAllClientResources(ClientPtr client,
    213                                              FindAllRes func,
    214                                              void *cdata);
    215 
    216 /** @brief Iterate through all subresources of a resource.
    217 
    218     @note The XID argument provided to the FindAllRes function
    219           may be 0 for subresources that don't have an XID */
    220 extern _X_EXPORT void FindSubResources(void *resource,
    221                                        RESTYPE type,
    222                                        FindAllRes func,
    223                                        void *cdata);
    224 
    225 extern _X_EXPORT void FreeClientNeverRetainResources(ClientPtr /*client */ );
    226 
    227 extern _X_EXPORT void FreeClientResources(ClientPtr /*client */ );
    228 
    229 extern _X_EXPORT void FreeAllResources(void);
    230 
    231 extern _X_EXPORT Bool LegalNewID(XID /*id */ ,
    232                                  ClientPtr /*client */ );
    233 
    234 extern _X_EXPORT void *LookupClientResourceComplex(ClientPtr client,
    235                                                      RESTYPE type,
    236                                                      FindComplexResType func,
    237                                                      void *cdata);
    238 
    239 extern _X_EXPORT int dixLookupResourceByType(void **result,
    240                                              XID id,
    241                                              RESTYPE rtype,
    242                                              ClientPtr client,
    243                                              Mask access_mode);
    244 
    245 extern _X_EXPORT int dixLookupResourceByClass(void **result,
    246                                               XID id,
    247                                               RESTYPE rclass,
    248                                               ClientPtr client,
    249                                               Mask access_mode);
    250 
    251 extern _X_EXPORT void GetXIDRange(int /*client */ ,
    252                                   Bool /*server */ ,
    253                                   XID * /*minp */ ,
    254                                   XID * /*maxp */ );
    255 
    256 extern _X_EXPORT unsigned int GetXIDList(ClientPtr /*client */ ,
    257                                          unsigned int /*count */ ,
    258                                          XID * /*pids */ );
    259 
    260 extern _X_EXPORT RESTYPE lastResourceType;
    261 extern _X_EXPORT RESTYPE TypeMask;
    262 
    263 /** @brief A hashing function to be used for hashing resource IDs
    264 
    265     @param id The resource ID to hash
    266     @param numBits The number of bits in the resulting hash. Must be >=0.
    267 
    268     @note This function is really only for handling
    269     INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
    270     of bits by either masking numBits lower bits of the ID or by
    271     providing at most MAXHASHSIZE hashes.
    272 */
    273 extern _X_EXPORT int HashResourceID(XID id, unsigned int numBits);
    274 
    275 #endif /* RESOURCE_H */