resource.h revision 9ace9065
105b261ecSmrg/*********************************************************** 205b261ecSmrg 305b261ecSmrgCopyright 1987, 1989, 1998 The Open Group 405b261ecSmrg 505b261ecSmrgPermission to use, copy, modify, distribute, and sell this software and its 605b261ecSmrgdocumentation for any purpose is hereby granted without fee, provided that 705b261ecSmrgthe above copyright notice appear in all copies and that both that 805b261ecSmrgcopyright notice and this permission notice appear in supporting 905b261ecSmrgdocumentation. 1005b261ecSmrg 1105b261ecSmrgThe above copyright notice and this permission notice shall be included in 1205b261ecSmrgall copies or substantial portions of the Software. 1305b261ecSmrg 1405b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1505b261ecSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1605b261ecSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1705b261ecSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1805b261ecSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1905b261ecSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2005b261ecSmrg 2105b261ecSmrgExcept as contained in this notice, the name of The Open Group shall not be 2205b261ecSmrgused in advertising or otherwise to promote the sale, use or other dealings 2305b261ecSmrgin this Software without prior written authorization from The Open Group. 2405b261ecSmrg 2505b261ecSmrg 2605b261ecSmrgCopyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 2705b261ecSmrg 2805b261ecSmrg All Rights Reserved 2905b261ecSmrg 3005b261ecSmrgPermission to use, copy, modify, and distribute this software and its 3105b261ecSmrgdocumentation for any purpose and without fee is hereby granted, 3205b261ecSmrgprovided that the above copyright notice appear in all copies and that 3305b261ecSmrgboth that copyright notice and this permission notice appear in 3405b261ecSmrgsupporting documentation, and that the name of Digital not be 3505b261ecSmrgused in advertising or publicity pertaining to distribution of the 3605b261ecSmrgsoftware without specific, written prior permission. 3705b261ecSmrg 3805b261ecSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 3905b261ecSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 4005b261ecSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 4105b261ecSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 4205b261ecSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 4305b261ecSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 4405b261ecSmrgSOFTWARE. 4505b261ecSmrg 4605b261ecSmrg******************************************************************/ 4705b261ecSmrg 4805b261ecSmrg#ifndef RESOURCE_H 4905b261ecSmrg#define RESOURCE_H 1 5005b261ecSmrg#include "misc.h" 514642e01fSmrg#include "dixaccess.h" 5205b261ecSmrg 5305b261ecSmrg/***************************************************************** 5405b261ecSmrg * STUFF FOR RESOURCES 5505b261ecSmrg *****************************************************************/ 5605b261ecSmrg 5705b261ecSmrg/* classes for Resource routines */ 5805b261ecSmrg 5905b261ecSmrgtypedef unsigned long RESTYPE; 6005b261ecSmrg 6105b261ecSmrg#define RC_VANILLA ((RESTYPE)0) 6205b261ecSmrg#define RC_CACHED ((RESTYPE)1<<31) 6305b261ecSmrg#define RC_DRAWABLE ((RESTYPE)1<<30) 6405b261ecSmrg/* Use class RC_NEVERRETAIN for resources that should not be retained 6505b261ecSmrg * regardless of the close down mode when the client dies. (A client's 6605b261ecSmrg * event selections on objects that it doesn't own are good candidates.) 6705b261ecSmrg * Extensions can use this too! 6805b261ecSmrg */ 6905b261ecSmrg#define RC_NEVERRETAIN ((RESTYPE)1<<29) 7005b261ecSmrg#define RC_LASTPREDEF RC_NEVERRETAIN 7105b261ecSmrg#define RC_ANY (~(RESTYPE)0) 7205b261ecSmrg 7305b261ecSmrg/* types for Resource routines */ 7405b261ecSmrg 754642e01fSmrg#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE) 764642e01fSmrg#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE) 774642e01fSmrg#define RT_GC ((RESTYPE)3) 7805b261ecSmrg#undef RT_FONT 7905b261ecSmrg#undef RT_CURSOR 8005b261ecSmrg#define RT_FONT ((RESTYPE)4) 8105b261ecSmrg#define RT_CURSOR ((RESTYPE)5) 8205b261ecSmrg#define RT_COLORMAP ((RESTYPE)6) 8305b261ecSmrg#define RT_CMAPENTRY ((RESTYPE)7) 8405b261ecSmrg#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN) 8505b261ecSmrg#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN) 8605b261ecSmrg#define RT_LASTPREDEF ((RESTYPE)9) 8705b261ecSmrg#define RT_NONE ((RESTYPE)0) 8805b261ecSmrg 8905b261ecSmrg/* bits and fields within a resource id */ 9005b261ecSmrg#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */ 9105b261ecSmrg#if MAXCLIENTS == 64 9205b261ecSmrg#define RESOURCE_CLIENT_BITS 6 9305b261ecSmrg#endif 9405b261ecSmrg#if MAXCLIENTS == 128 9505b261ecSmrg#define RESOURCE_CLIENT_BITS 7 9605b261ecSmrg#endif 9705b261ecSmrg#if MAXCLIENTS == 256 9805b261ecSmrg#define RESOURCE_CLIENT_BITS 8 9905b261ecSmrg#endif 10005b261ecSmrg#if MAXCLIENTS == 512 10105b261ecSmrg#define RESOURCE_CLIENT_BITS 9 10205b261ecSmrg#endif 10305b261ecSmrg/* client field offset */ 10405b261ecSmrg#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS) 10505b261ecSmrg/* resource field */ 10605b261ecSmrg#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1) 10705b261ecSmrg/* client field */ 10805b261ecSmrg#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET) 10905b261ecSmrg/* extract the client mask from an XID */ 11005b261ecSmrg#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK) 11105b261ecSmrg/* extract the client id from an XID */ 11205b261ecSmrg#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET)) 11305b261ecSmrg#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */ 11405b261ecSmrg 11505b261ecSmrg#ifdef INVALID 11605b261ecSmrg#undef INVALID /* needed on HP/UX */ 11705b261ecSmrg#endif 11805b261ecSmrg 11905b261ecSmrg/* Invalid resource id */ 12005b261ecSmrg#define INVALID (0) 12105b261ecSmrg 12205b261ecSmrg#define BAD_RESOURCE 0xe0000000 12305b261ecSmrg 1249ace9065Smrg#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) 1259ace9065Smrg 1264642e01fSmrg/* Resource state callback */ 1276747b715Smrgextern _X_EXPORT CallbackListPtr ResourceStateCallback; 1284642e01fSmrg 1294642e01fSmrgtypedef enum {ResourceStateAdding, 1304642e01fSmrg ResourceStateFreeing} ResourceState; 1314642e01fSmrg 1324642e01fSmrgtypedef struct { 1334642e01fSmrg ResourceState state; 1344642e01fSmrg XID id; 1354642e01fSmrg RESTYPE type; 1364642e01fSmrg pointer value; 1374642e01fSmrg} ResourceStateInfoRec; 1384642e01fSmrg 13905b261ecSmrgtypedef int (*DeleteType)( 14005b261ecSmrg pointer /*value*/, 14105b261ecSmrg XID /*id*/); 14205b261ecSmrg 14305b261ecSmrgtypedef void (*FindResType)( 14405b261ecSmrg pointer /*value*/, 14505b261ecSmrg XID /*id*/, 14605b261ecSmrg pointer /*cdata*/); 14705b261ecSmrg 14805b261ecSmrgtypedef void (*FindAllRes)( 14905b261ecSmrg pointer /*value*/, 15005b261ecSmrg XID /*id*/, 15105b261ecSmrg RESTYPE /*type*/, 15205b261ecSmrg pointer /*cdata*/); 15305b261ecSmrg 15405b261ecSmrgtypedef Bool (*FindComplexResType)( 15505b261ecSmrg pointer /*value*/, 15605b261ecSmrg XID /*id*/, 15705b261ecSmrg pointer /*cdata*/); 15805b261ecSmrg 1596747b715Smrgextern _X_EXPORT RESTYPE CreateNewResourceType( 1606747b715Smrg DeleteType /*deleteFunc*/, char * /*name*/); 16105b261ecSmrg 1626747b715Smrgextern _X_EXPORT void SetResourceTypeErrorValue( 1636747b715Smrg RESTYPE /*type*/, int /*errorValue*/); 16405b261ecSmrg 1656747b715Smrgextern _X_EXPORT RESTYPE CreateNewResourceClass(void); 1666747b715Smrg 1676747b715Smrgextern _X_EXPORT Bool InitClientResources( 16805b261ecSmrg ClientPtr /*client*/); 16905b261ecSmrg 1706747b715Smrgextern _X_EXPORT XID FakeClientID( 17105b261ecSmrg int /*client*/); 17205b261ecSmrg 17305b261ecSmrg/* Quartz support on Mac OS X uses the CarbonCore 17405b261ecSmrg framework whose AddResource function conflicts here. */ 1754642e01fSmrg#ifdef __APPLE__ 17605b261ecSmrg#define AddResource Darwin_X_AddResource 17705b261ecSmrg#endif 1786747b715Smrgextern _X_EXPORT Bool AddResource( 17905b261ecSmrg XID /*id*/, 18005b261ecSmrg RESTYPE /*type*/, 18105b261ecSmrg pointer /*value*/); 18205b261ecSmrg 1836747b715Smrgextern _X_EXPORT void FreeResource( 18405b261ecSmrg XID /*id*/, 18505b261ecSmrg RESTYPE /*skipDeleteFuncType*/); 18605b261ecSmrg 1876747b715Smrgextern _X_EXPORT void FreeResourceByType( 18805b261ecSmrg XID /*id*/, 18905b261ecSmrg RESTYPE /*type*/, 19005b261ecSmrg Bool /*skipFree*/); 19105b261ecSmrg 1926747b715Smrgextern _X_EXPORT Bool ChangeResourceValue( 19305b261ecSmrg XID /*id*/, 19405b261ecSmrg RESTYPE /*rtype*/, 19505b261ecSmrg pointer /*value*/); 19605b261ecSmrg 1976747b715Smrgextern _X_EXPORT void FindClientResourcesByType( 19805b261ecSmrg ClientPtr /*client*/, 19905b261ecSmrg RESTYPE /*type*/, 20005b261ecSmrg FindResType /*func*/, 20105b261ecSmrg pointer /*cdata*/); 20205b261ecSmrg 2036747b715Smrgextern _X_EXPORT void FindAllClientResources( 20405b261ecSmrg ClientPtr /*client*/, 20505b261ecSmrg FindAllRes /*func*/, 20605b261ecSmrg pointer /*cdata*/); 20705b261ecSmrg 2086747b715Smrgextern _X_EXPORT void FreeClientNeverRetainResources( 20905b261ecSmrg ClientPtr /*client*/); 21005b261ecSmrg 2116747b715Smrgextern _X_EXPORT void FreeClientResources( 21205b261ecSmrg ClientPtr /*client*/); 21305b261ecSmrg 2146747b715Smrgextern _X_EXPORT void FreeAllResources(void); 21505b261ecSmrg 2166747b715Smrgextern _X_EXPORT Bool LegalNewID( 21705b261ecSmrg XID /*id*/, 21805b261ecSmrg ClientPtr /*client*/); 21905b261ecSmrg 2206747b715Smrgextern _X_EXPORT pointer LookupClientResourceComplex( 22105b261ecSmrg ClientPtr client, 22205b261ecSmrg RESTYPE type, 22305b261ecSmrg FindComplexResType func, 22405b261ecSmrg pointer cdata); 22505b261ecSmrg 2266747b715Smrgextern _X_EXPORT int dixLookupResourceByType( 2274642e01fSmrg pointer *result, 2284642e01fSmrg XID id, 2294642e01fSmrg RESTYPE rtype, 2304642e01fSmrg ClientPtr client, 2314642e01fSmrg Mask access_mode); 23205b261ecSmrg 2336747b715Smrgextern _X_EXPORT int dixLookupResourceByClass( 234b86d567bSmrg pointer *result, 235b86d567bSmrg XID id, 236b86d567bSmrg RESTYPE rclass, 237b86d567bSmrg ClientPtr client, 238b86d567bSmrg Mask access_mode); 239b86d567bSmrg 2406747b715Smrgextern _X_EXPORT void GetXIDRange( 24105b261ecSmrg int /*client*/, 24205b261ecSmrg Bool /*server*/, 24305b261ecSmrg XID * /*minp*/, 24405b261ecSmrg XID * /*maxp*/); 24505b261ecSmrg 2466747b715Smrgextern _X_EXPORT unsigned int GetXIDList( 24705b261ecSmrg ClientPtr /*client*/, 24805b261ecSmrg unsigned int /*count*/, 24905b261ecSmrg XID * /*pids*/); 25005b261ecSmrg 2516747b715Smrgextern _X_EXPORT RESTYPE lastResourceType; 2526747b715Smrgextern _X_EXPORT RESTYPE TypeMask; 25305b261ecSmrg 2544642e01fSmrg/* 2554642e01fSmrg * These are deprecated compatibility functions and will be removed soon! 2564642e01fSmrg * Please use the noted replacements instead. 2574642e01fSmrg */ 2584642e01fSmrg 2596747b715Smrg/* replaced by dixLookupResourceByType */ 2606747b715Smrgextern _X_EXPORT pointer SecurityLookupIDByType( 2614642e01fSmrg ClientPtr client, 2624642e01fSmrg XID id, 2634642e01fSmrg RESTYPE rtype, 2646747b715Smrg Mask access_mode) _X_DEPRECATED; 2654642e01fSmrg 266b86d567bSmrg/* replaced by dixLookupResourceByClass */ 2676747b715Smrgextern _X_EXPORT pointer SecurityLookupIDByClass( 2684642e01fSmrg ClientPtr client, 2694642e01fSmrg XID id, 2704642e01fSmrg RESTYPE classes, 2716747b715Smrg Mask access_mode) _X_DEPRECATED; 2724642e01fSmrg 273b86d567bSmrg/* replaced by dixLookupResourceByType */ 2746747b715Smrgextern _X_EXPORT pointer LookupIDByType( 2754642e01fSmrg XID id, 2766747b715Smrg RESTYPE rtype) _X_DEPRECATED; 2774642e01fSmrg 278b86d567bSmrg/* replaced by dixLookupResourceByClass */ 2796747b715Smrgextern _X_EXPORT pointer LookupIDByClass( 2804642e01fSmrg XID id, 2816747b715Smrg RESTYPE classes) _X_DEPRECATED; 28205b261ecSmrg 28305b261ecSmrg#endif /* RESOURCE_H */ 28405b261ecSmrg 285