resource.h revision 65fea56f17cd614bc8908264df980a62e1931468
65fea56f17cd614bc8908264df980a62e1931468vboxsync/***********************************************************
65fea56f17cd614bc8908264df980a62e1931468vboxsyncCopyright 1987, 1989, 1998 The Open Group
65fea56f17cd614bc8908264df980a62e1931468vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
65fea56f17cd614bc8908264df980a62e1931468vboxsyncthe above copyright notice appear in all copies and that both that
65fea56f17cd614bc8908264df980a62e1931468vboxsynccopyright notice and this permission notice appear in supporting
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncThe above copyright notice and this permission notice shall be included in
65fea56f17cd614bc8908264df980a62e1931468vboxsyncall copies or substantial portions of the Software.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65fea56f17cd614bc8908264df980a62e1931468vboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65fea56f17cd614bc8908264df980a62e1931468vboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
65fea56f17cd614bc8908264df980a62e1931468vboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
65fea56f17cd614bc8908264df980a62e1931468vboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncExcept as contained in this notice, the name of The Open Group shall not be
65fea56f17cd614bc8908264df980a62e1931468vboxsyncused in advertising or otherwise to promote the sale, use or other dealings
65fea56f17cd614bc8908264df980a62e1931468vboxsyncin this Software without prior written authorization from The Open Group.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncCopyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
65fea56f17cd614bc8908264df980a62e1931468vboxsync All Rights Reserved
65fea56f17cd614bc8908264df980a62e1931468vboxsyncPermission to use, copy, modify, and distribute this software and its
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation for any purpose and without fee is hereby granted,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncprovided that the above copyright notice appear in all copies and that
65fea56f17cd614bc8908264df980a62e1931468vboxsyncboth that copyright notice and this permission notice appear in
65fea56f17cd614bc8908264df980a62e1931468vboxsyncsupporting documentation, and that the name of Digital not be
65fea56f17cd614bc8908264df980a62e1931468vboxsyncused in advertising or publicity pertaining to distribution of the
65fea56f17cd614bc8908264df980a62e1931468vboxsyncsoftware without specific, written prior permission.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
65fea56f17cd614bc8908264df980a62e1931468vboxsyncALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
65fea56f17cd614bc8908264df980a62e1931468vboxsyncDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
65fea56f17cd614bc8908264df980a62e1931468vboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
65fea56f17cd614bc8908264df980a62e1931468vboxsync******************************************************************/
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*****************************************************************
65fea56f17cd614bc8908264df980a62e1931468vboxsync * STUFF FOR RESOURCES
65fea56f17cd614bc8908264df980a62e1931468vboxsync *****************************************************************/
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* classes for Resource routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Use class RC_NEVERRETAIN for resources that should not be retained
65fea56f17cd614bc8908264df980a62e1931468vboxsync * regardless of the close down mode when the client dies. (A client's
65fea56f17cd614bc8908264df980a62e1931468vboxsync * event selections on objects that it doesn't own are good candidates.)
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Extensions can use this too!
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* types for Resource routines */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* bits and fields within a resource id */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* client field offset */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* resource field */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* client field */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* extract the client mask from an XID */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* extract the client id from an XID */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Invalid resource id */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Resource state callback */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT CallbackListPtr ResourceStateCallback;
65fea56f17cd614bc8908264df980a62e1931468vboxsynctypedef struct {
65fea56f17cd614bc8908264df980a62e1931468vboxsynctypedef Bool (*FindComplexResType) (pointer /*value */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Structure for estimating resource memory usage. Memory usage
65fea56f17cd614bc8908264df980a62e1931468vboxsync * consists of space allocated for the resource itself and of
65fea56f17cd614bc8908264df980a62e1931468vboxsync * references to other resources. Currently the most important use for
65fea56f17cd614bc8908264df980a62e1931468vboxsync * this structure is to estimate pixmap usage of different resources
65fea56f17cd614bc8908264df980a62e1931468vboxsync * more accurately. */
65fea56f17cd614bc8908264df980a62e1931468vboxsynctypedef struct {
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* Size of resource itself. Zero if not implemented. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long resourceSize;
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* Size attributed to pixmap references from the resource. */
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long pixmapRefSize;
65fea56f17cd614bc8908264df980a62e1931468vboxsync /* Number of references to this resource; typically 1 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned long refCnt;
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT RESTYPE CreateNewResourceType(DeleteType /*deleteFunc */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync const char * /*name */ );
65fea56f17cd614bc8908264df980a62e1931468vboxsynctypedef void (*FindTypeSubResources)(pointer /* value */,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void SetResourceTypeFindSubResFunc(
65fea56f17cd614bc8908264df980a62e1931468vboxsync RESTYPE /*type*/, FindTypeSubResources /*findFunc*/);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT RESTYPE CreateNewResourceClass(void);
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT Bool InitClientResources(ClientPtr /*client */ );
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT XID FakeClientID(int /*client */ );
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Quartz support on Mac OS X uses the CarbonCore
65fea56f17cd614bc8908264df980a62e1931468vboxsync framework whose AddResource function conflicts here. */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void FreeResourceByType(XID /*id */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT Bool ChangeResourceValue(XID /*id */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void FindClientResourcesByType(ClientPtr /*client */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void FindAllClientResources(ClientPtr /*client */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync/** @brief Iterate through all subresources of a resource.
65fea56f17cd614bc8908264df980a62e1931468vboxsync @note The XID argument provided to the FindAllRes function
65fea56f17cd614bc8908264df980a62e1931468vboxsync may be 0 for subresources that don't have an XID */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void FindSubResources(pointer /*resource*/,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void FreeClientNeverRetainResources(ClientPtr /*client */ );
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void FreeClientResources(ClientPtr /*client */ );
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT pointer LookupClientResourceComplex(ClientPtr client,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int dixLookupResourceByType(pointer *result,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int dixLookupResourceByClass(pointer *result,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT unsigned int GetXIDList(ClientPtr /*client */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int /*count */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync/** @brief A hashing function to be used for hashing resource IDs
65fea56f17cd614bc8908264df980a62e1931468vboxsync @param id The resource ID to hash
65fea56f17cd614bc8908264df980a62e1931468vboxsync @param numBits The number of bits in the resulting hash. Must be >=0.
65fea56f17cd614bc8908264df980a62e1931468vboxsync @note This function is really only for handling
65fea56f17cd614bc8908264df980a62e1931468vboxsync INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
65fea56f17cd614bc8908264df980a62e1931468vboxsync of bits by either masking numBits lower bits of the ID or by
65fea56f17cd614bc8908264df980a62e1931468vboxsync providing at most MAXHASHSIZE hashes.
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* RESOURCE_H */