aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/include
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/include')
-rw-r--r--xorg-server/include/dix.h9
-rw-r--r--xorg-server/include/dixgrabs.h4
-rw-r--r--xorg-server/include/eventconvert.h7
-rw-r--r--xorg-server/include/exevents.h6
-rw-r--r--xorg-server/include/input.h20
-rw-r--r--xorg-server/include/inputstr.h10
-rw-r--r--xorg-server/include/inpututils.h6
-rw-r--r--xorg-server/include/misc.h2
-rw-r--r--xorg-server/include/os.h6
-rw-r--r--xorg-server/include/registry.h2
-rw-r--r--xorg-server/include/resource.h510
11 files changed, 304 insertions, 278 deletions
diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h
index cfbfa1f41..272fd4161 100644
--- a/xorg-server/include/dix.h
+++ b/xorg-server/include/dix.h
@@ -175,9 +175,9 @@ extern _X_HIDDEN Bool CreateConnectionBlock(void);
/* dixutils.c */
extern _X_EXPORT int CompareISOLatin1Lowered(
- unsigned char * /*a*/,
+ const unsigned char * /*a*/,
int alen,
- unsigned char * /*b*/,
+ const unsigned char * /*b*/,
int blen);
extern _X_EXPORT int dixLookupWindow(
@@ -400,6 +400,11 @@ extern int DeliverDeviceEvents(
WindowPtr /* stopAt */,
DeviceIntPtr /* dev */);
+extern int DeliverOneGrabbedEvent(
+ InternalEvent* /* event*/,
+ DeviceIntPtr /* dev */,
+ enum InputLevel /* level */);
+
extern void InitializeSprite(
DeviceIntPtr /* pDev */,
WindowPtr /* pWin */);
diff --git a/xorg-server/include/dixgrabs.h b/xorg-server/include/dixgrabs.h
index 65ff45d1d..4dd5eae6d 100644
--- a/xorg-server/include/dixgrabs.h
+++ b/xorg-server/include/dixgrabs.h
@@ -40,7 +40,7 @@ extern GrabPtr CreateGrab(
DeviceIntPtr /* device */,
DeviceIntPtr /* modDevice */,
WindowPtr /* window */,
- GrabType /* grabtype */,
+ enum InputLevel /* grabtype */,
GrabMask * /* mask */,
struct _GrabParameters * /* param */,
int /* type */,
@@ -64,4 +64,6 @@ extern _X_EXPORT int AddPassiveGrabToList(
extern _X_EXPORT Bool DeletePassiveGrabFromList(
GrabPtr /* pMinuendGrab */);
+extern Bool GrabIsPointerGrab(GrabPtr grab);
+extern Bool GrabIsKeyboardGrab(GrabPtr grab);
#endif /* DIXGRABS_H */
diff --git a/xorg-server/include/eventconvert.h b/xorg-server/include/eventconvert.h
index b000abc4b..571a51109 100644
--- a/xorg-server/include/eventconvert.h
+++ b/xorg-server/include/eventconvert.h
@@ -27,14 +27,15 @@
#include <X11/extensions/XIproto.h>
#include "input.h"
#include "events.h"
+#include "eventstr.h"
#define FP1616(integral, frac) ((integral) * (1 << 16) + (frac) * (1 << 16))
_X_EXPORT int EventToCore(InternalEvent *event, xEvent **core, int *count);
_X_EXPORT int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
_X_EXPORT int EventToXI2(InternalEvent *ev, xEvent **xi);
-_X_INTERNAL int GetCoreType(InternalEvent* ev);
-_X_INTERNAL int GetXIType(InternalEvent* ev);
-_X_INTERNAL int GetXI2Type(InternalEvent* ev);
+_X_INTERNAL int GetCoreType(enum EventType type);
+_X_INTERNAL int GetXIType(enum EventType type);
+_X_INTERNAL int GetXI2Type(enum EventType type);
#endif /* _EVENTCONVERT_H_ */
diff --git a/xorg-server/include/exevents.h b/xorg-server/include/exevents.h
index 12ea37885..0ab04f525 100644
--- a/xorg-server/include/exevents.h
+++ b/xorg-server/include/exevents.h
@@ -159,7 +159,7 @@ typedef struct _XIClientRec {
typedef struct _GrabParameters {
- int grabtype; /* GRABTYPE_CORE, etc. */
+ int grabtype; /* CORE, etc. */
unsigned int ownerEvents;
unsigned int this_device_mode;
unsigned int other_devices_mode;
@@ -200,7 +200,7 @@ GrabButton(
DeviceIntPtr /* modifier_device */,
int /* button */,
GrabParameters* /* param */,
- GrabType /* grabtype */,
+ enum InputLevel /* grabtype */,
GrabMask* /* eventMask */);
extern int
@@ -210,7 +210,7 @@ GrabKey(
DeviceIntPtr /* modifier_device */,
int /* key */,
GrabParameters* /* param */,
- GrabType /* grabtype */,
+ enum InputLevel /* grabtype */,
GrabMask* /* eventMask */);
extern int
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h
index 8b0c18e70..bd12f6829 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/include/input.h
@@ -57,6 +57,7 @@ SOFTWARE.
#include "xkbrules.h"
#include "events.h"
#include "list.h"
+#include <X11/extensions/XI2.h>
#define DEVICE_INIT 0
#define DEVICE_ON 1
@@ -101,6 +102,12 @@ SOFTWARE.
#define RevertToFollowKeyboard 3
#endif
+enum InputLevel {
+ CORE,
+ XI,
+ XI2,
+};
+
typedef unsigned long Leds;
typedef struct _OtherClients *OtherClientsPtr;
typedef struct _InputClients *InputClientsPtr;
@@ -537,14 +544,16 @@ extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
extern Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
+extern int GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type);
void FixUpEventFromWindow(SpritePtr pSprite,
xEvent *xE,
WindowPtr pWin,
Window child,
Bool calcChild);
extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
-extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
- WindowPtr win);
+extern int EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win);
+extern Bool ActivatePassiveGrab(DeviceIntPtr dev, GrabPtr grab,
+ InternalEvent *ev);
/**
* Masks specifying the type of event to deliver for an InternalEvent; used
* by EventIsDeliverable.
@@ -557,6 +566,13 @@ extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
#define EVENT_XI2_MASK (1 << 3) /**< XI2 mask set on window */
/* @} */
+enum EventDeliveryState {
+ EVENT_DELIVERED, /**< Event has been delivered to a client */
+ EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */
+ EVENT_SKIP, /**< Event can be discarded by the caller */
+ EVENT_REJECTED, /**< Event was rejected for delivery to the client */
+};
+
/* Implemented by the DDX. */
extern _X_EXPORT int NewInputDeviceRequest(
InputOption *options,
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h
index 5634f3cfc..5aae1b512 100644
--- a/xorg-server/include/inputstr.h
+++ b/xorg-server/include/inputstr.h
@@ -57,7 +57,7 @@ SOFTWARE.
#include "geext.h"
#include "privates.h"
-#define BitIsOn(ptr, bit) (!!(((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
+#define BitIsOn(ptr, bit) (!!(((const BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
#define SetBit(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
#define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
extern _X_EXPORT int CountBits(const uint8_t *mask, int len);
@@ -167,12 +167,6 @@ typedef struct _DetailRec { /* Grab details may be bit masks */
Mask *pMask;
} DetailRec;
-typedef enum {
- GRABTYPE_CORE,
- GRABTYPE_XI,
- GRABTYPE_XI2
-} GrabType;
-
union _GrabMask {
Mask core;
Mask xi;
@@ -200,7 +194,7 @@ typedef struct _GrabRec {
unsigned ownerEvents:1;
unsigned keyboardMode:1;
unsigned pointerMode:1;
- GrabType grabtype;
+ enum InputLevel grabtype;
CARD8 type; /* event type */
DetailRec modifiersDetail;
DeviceIntPtr modifierDevice;
diff --git a/xorg-server/include/inpututils.h b/xorg-server/include/inpututils.h
index 5f9dfecc3..9e22c5a28 100644
--- a/xorg-server/include/inpututils.h
+++ b/xorg-server/include/inpututils.h
@@ -32,6 +32,8 @@
#include "input.h"
#include <X11/extensions/XI2proto.h>
+extern Mask event_filters[MAXDEVICES][MAXEVENTS];
+
struct _ValuatorMask {
int8_t last_bit; /* highest bit set in mask */
uint8_t mask[(MAX_VALUATORS + 7)/8];
@@ -40,6 +42,10 @@ struct _ValuatorMask {
extern void verify_internal_event(const InternalEvent *ev);
extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms);
+extern int event_get_corestate(DeviceIntPtr mouse, DeviceIntPtr kbd);
+extern void event_set_state(DeviceIntPtr mouse, DeviceIntPtr kbd, DeviceEvent *event);
+extern Mask event_get_filter_from_type(DeviceIntPtr dev, int evtype);
+extern Mask event_get_filter_from_xi2type(int evtype);
FP3232 double_to_fp3232(double in);
FP1616 double_to_fp1616(double in);
diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h
index ed280337a..d401537c6 100644
--- a/xorg-server/include/misc.h
+++ b/xorg-server/include/misc.h
@@ -99,6 +99,8 @@ static double __inline trunc(double d)
#define MAXFORMATS 8
#define MAXDEVICES 40 /* input devices */
+/* 128 event opcodes for core + extension events, excluding GE */
+#define MAXEVENTS 128
#define EXTENSION_EVENT_BASE 64
#define EXTENSION_BASE 128
diff --git a/xorg-server/include/os.h b/xorg-server/include/os.h
index 67493645d..f62ada207 100644
--- a/xorg-server/include/os.h
+++ b/xorg-server/include/os.h
@@ -129,7 +129,7 @@ extern _X_EXPORT void CloseWellKnownConnections(void);
extern _X_EXPORT XID AuthorizationIDOfClient(ClientPtr /*client*/);
-extern _X_EXPORT char *ClientAuthorized(
+extern _X_EXPORT const char *ClientAuthorized(
ClientPtr /*client*/,
unsigned int /*proto_n*/,
char* /*auth_proto*/,
@@ -407,7 +407,7 @@ extern _X_EXPORT void InitAuthorization(char * /*filename*/);
extern _X_EXPORT int AuthorizationFromID (
XID id,
unsigned short *name_lenp,
- char **namep,
+ const char **namep,
unsigned short *data_lenp,
char **datap);
@@ -417,7 +417,7 @@ extern _X_EXPORT XID CheckAuthorization(
unsigned int /*datalength*/,
const char * /*data*/,
ClientPtr /*client*/,
- char ** /*reason*/
+ const char ** /*reason*/
);
extern _X_EXPORT void ResetAuthorization(void);
diff --git a/xorg-server/include/registry.h b/xorg-server/include/registry.h
index 325f76515..44f79259e 100644
--- a/xorg-server/include/registry.h
+++ b/xorg-server/include/registry.h
@@ -28,7 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Registration functions. The name string is not copied, so it must
* not be a stack variable.
*/
-extern _X_EXPORT void RegisterResourceName(RESTYPE type, char *name);
+extern _X_EXPORT void RegisterResourceName(RESTYPE type, const char *name);
extern _X_EXPORT void RegisterExtensionNames(ExtensionEntry *ext);
/*
diff --git a/xorg-server/include/resource.h b/xorg-server/include/resource.h
index 2bed80577..ea4043b2f 100644
--- a/xorg-server/include/resource.h
+++ b/xorg-server/include/resource.h
@@ -1,255 +1,255 @@
-/***********************************************************
-
-Copyright 1987, 1989, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-
-Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifndef RESOURCE_H
-#define RESOURCE_H 1
-#include "misc.h"
-#include "dixaccess.h"
-
-/*****************************************************************
- * STUFF FOR RESOURCES
- *****************************************************************/
-
-/* classes for Resource routines */
-
-typedef uint32_t RESTYPE;
-
-#define RC_VANILLA ((RESTYPE)0)
-#define RC_CACHED ((RESTYPE)1<<31)
-#define RC_DRAWABLE ((RESTYPE)1<<30)
-/* Use class RC_NEVERRETAIN for resources that should not be retained
- * regardless of the close down mode when the client dies. (A client's
- * event selections on objects that it doesn't own are good candidates.)
- * Extensions can use this too!
- */
-#define RC_NEVERRETAIN ((RESTYPE)1<<29)
-#define RC_LASTPREDEF RC_NEVERRETAIN
-#define RC_ANY (~(RESTYPE)0)
-
-/* types for Resource routines. When you change one of them, please also update the predefTypes array in resource.c*/
-
-#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
-#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
-#define RT_GC ((RESTYPE)3)
-#undef RT_FONT
-#undef RT_CURSOR
-#define RT_FONT ((RESTYPE)4)
-#define RT_CURSOR ((RESTYPE)5)
-#define RT_COLORMAP ((RESTYPE)6)
-#define RT_CMAPENTRY ((RESTYPE)7)
-#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
-#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
-#define RT_LASTPREDEF ((RESTYPE)9)
-#define RT_NONE ((RESTYPE)0)
-
-/* bits and fields within a resource id */
-#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
-#if MAXCLIENTS == 64
-#define RESOURCE_CLIENT_BITS 6
-#endif
-#if MAXCLIENTS == 128
-#define RESOURCE_CLIENT_BITS 7
-#endif
-#if MAXCLIENTS == 256
-#define RESOURCE_CLIENT_BITS 8
-#endif
-#if MAXCLIENTS == 512
-#define RESOURCE_CLIENT_BITS 9
-#endif
-/* client field offset */
-#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
-/* resource field */
-#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
-/* client field */
-#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
-/* extract the client mask from an XID */
-#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
-/* extract the client id from an XID */
-#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
-#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
-
-#ifdef INVALID
-#undef INVALID /* needed on HP/UX */
-#endif
-
-/* Invalid resource id */
-#define INVALID (0)
-
-#define BAD_RESOURCE 0xe0000000
-
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
-/* Resource state callback */
-extern _X_EXPORT CallbackListPtr ResourceStateCallback;
-
-typedef enum {ResourceStateAdding,
- ResourceStateFreeing} ResourceState;
-
-typedef struct {
- ResourceState state;
- XID id;
- RESTYPE type;
- pointer value;
-} ResourceStateInfoRec;
-
-typedef int (*DeleteType)(
- pointer /*value*/,
- XID /*id*/);
-
-typedef void (*FindResType)(
- pointer /*value*/,
- XID /*id*/,
- pointer /*cdata*/);
-
-typedef void (*FindAllRes)(
- pointer /*value*/,
- XID /*id*/,
- RESTYPE /*type*/,
- pointer /*cdata*/);
-
-typedef Bool (*FindComplexResType)(
- pointer /*value*/,
- XID /*id*/,
- pointer /*cdata*/);
-
-extern _X_EXPORT RESTYPE CreateNewResourceType(
- DeleteType /*deleteFunc*/, char * /*name*/);
-
-extern _X_EXPORT void SetResourceTypeErrorValue(
- RESTYPE /*type*/, int /*errorValue*/);
-
-extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
-
-extern _X_EXPORT Bool InitClientResources(
- ClientPtr /*client*/);
-
-extern _X_EXPORT XID FakeClientID(
- int /*client*/);
-
-/* Quartz support on Mac OS X uses the CarbonCore
- framework whose AddResource function conflicts here. */
-#ifdef __APPLE__
-#define AddResource Darwin_X_AddResource
-#endif
-extern _X_EXPORT Bool AddResource(
- XID /*id*/,
- RESTYPE /*type*/,
- pointer /*value*/);
-
-extern _X_EXPORT void FreeResource(
- XID /*id*/,
- RESTYPE /*skipDeleteFuncType*/);
-
-extern _X_EXPORT void FreeResourceByType(
- XID /*id*/,
- RESTYPE /*type*/,
- Bool /*skipFree*/);
-
-extern _X_EXPORT Bool ChangeResourceValue(
- XID /*id*/,
- RESTYPE /*rtype*/,
- pointer /*value*/);
-
-extern _X_EXPORT void FindClientResourcesByType(
- ClientPtr /*client*/,
- RESTYPE /*type*/,
- FindResType /*func*/,
- pointer /*cdata*/);
-
-extern _X_EXPORT void FindAllClientResources(
- ClientPtr /*client*/,
- FindAllRes /*func*/,
- pointer /*cdata*/);
-
-extern _X_EXPORT void FreeClientNeverRetainResources(
- ClientPtr /*client*/);
-
-extern _X_EXPORT void FreeClientResources(
- ClientPtr /*client*/);
-
-extern _X_EXPORT void FreeAllResources(void);
-
-extern _X_EXPORT Bool LegalNewID(
- XID /*id*/,
- ClientPtr /*client*/);
-
-extern _X_EXPORT pointer LookupClientResourceComplex(
- ClientPtr client,
- RESTYPE type,
- FindComplexResType func,
- pointer cdata);
-
-extern _X_EXPORT int dixLookupResourceByType(
- pointer *result,
- XID id,
- RESTYPE rtype,
- ClientPtr client,
- Mask access_mode);
-
-extern _X_EXPORT int dixLookupResourceByClass(
- pointer *result,
- XID id,
- RESTYPE rclass,
- ClientPtr client,
- Mask access_mode);
-
-extern _X_EXPORT void GetXIDRange(
- int /*client*/,
- Bool /*server*/,
- XID * /*minp*/,
- XID * /*maxp*/);
-
-extern _X_EXPORT unsigned int GetXIDList(
- ClientPtr /*client*/,
- unsigned int /*count*/,
- XID * /*pids*/);
-
-extern _X_EXPORT RESTYPE lastResourceType;
-extern _X_EXPORT RESTYPE TypeMask;
-
-#endif /* RESOURCE_H */
-
+/***********************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef RESOURCE_H
+#define RESOURCE_H 1
+#include "misc.h"
+#include "dixaccess.h"
+
+/*****************************************************************
+ * STUFF FOR RESOURCES
+ *****************************************************************/
+
+/* classes for Resource routines */
+
+typedef uint32_t RESTYPE;
+
+#define RC_VANILLA ((RESTYPE)0)
+#define RC_CACHED ((RESTYPE)1<<31)
+#define RC_DRAWABLE ((RESTYPE)1<<30)
+/* Use class RC_NEVERRETAIN for resources that should not be retained
+ * regardless of the close down mode when the client dies. (A client's
+ * event selections on objects that it doesn't own are good candidates.)
+ * Extensions can use this too!
+ */
+#define RC_NEVERRETAIN ((RESTYPE)1<<29)
+#define RC_LASTPREDEF RC_NEVERRETAIN
+#define RC_ANY (~(RESTYPE)0)
+
+/* types for Resource routines. When you change one of them, please also update the predefTypes array in resource.c*/
+
+#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
+#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
+#define RT_GC ((RESTYPE)3)
+#undef RT_FONT
+#undef RT_CURSOR
+#define RT_FONT ((RESTYPE)4)
+#define RT_CURSOR ((RESTYPE)5)
+#define RT_COLORMAP ((RESTYPE)6)
+#define RT_CMAPENTRY ((RESTYPE)7)
+#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
+#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
+#define RT_LASTPREDEF ((RESTYPE)9)
+#define RT_NONE ((RESTYPE)0)
+
+/* bits and fields within a resource id */
+#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
+#if MAXCLIENTS == 64
+#define RESOURCE_CLIENT_BITS 6
+#endif
+#if MAXCLIENTS == 128
+#define RESOURCE_CLIENT_BITS 7
+#endif
+#if MAXCLIENTS == 256
+#define RESOURCE_CLIENT_BITS 8
+#endif
+#if MAXCLIENTS == 512
+#define RESOURCE_CLIENT_BITS 9
+#endif
+/* client field offset */
+#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
+/* resource field */
+#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
+/* client field */
+#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
+/* extract the client mask from an XID */
+#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
+/* extract the client id from an XID */
+#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
+#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
+
+#ifdef INVALID
+#undef INVALID /* needed on HP/UX */
+#endif
+
+/* Invalid resource id */
+#define INVALID (0)
+
+#define BAD_RESOURCE 0xe0000000
+
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+/* Resource state callback */
+extern _X_EXPORT CallbackListPtr ResourceStateCallback;
+
+typedef enum {ResourceStateAdding,
+ ResourceStateFreeing} ResourceState;
+
+typedef struct {
+ ResourceState state;
+ XID id;
+ RESTYPE type;
+ pointer value;
+} ResourceStateInfoRec;
+
+typedef int (*DeleteType)(
+ pointer /*value*/,
+ XID /*id*/);
+
+typedef void (*FindResType)(
+ pointer /*value*/,
+ XID /*id*/,
+ pointer /*cdata*/);
+
+typedef void (*FindAllRes)(
+ pointer /*value*/,
+ XID /*id*/,
+ RESTYPE /*type*/,
+ pointer /*cdata*/);
+
+typedef Bool (*FindComplexResType)(
+ pointer /*value*/,
+ XID /*id*/,
+ pointer /*cdata*/);
+
+extern _X_EXPORT RESTYPE CreateNewResourceType(
+ DeleteType /*deleteFunc*/, const char * /*name*/);
+
+extern _X_EXPORT void SetResourceTypeErrorValue(
+ RESTYPE /*type*/, int /*errorValue*/);
+
+extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
+
+extern _X_EXPORT Bool InitClientResources(
+ ClientPtr /*client*/);
+
+extern _X_EXPORT XID FakeClientID(
+ int /*client*/);
+
+/* Quartz support on Mac OS X uses the CarbonCore
+ framework whose AddResource function conflicts here. */
+#ifdef __APPLE__
+#define AddResource Darwin_X_AddResource
+#endif
+extern _X_EXPORT Bool AddResource(
+ XID /*id*/,
+ RESTYPE /*type*/,
+ pointer /*value*/);
+
+extern _X_EXPORT void FreeResource(
+ XID /*id*/,
+ RESTYPE /*skipDeleteFuncType*/);
+
+extern _X_EXPORT void FreeResourceByType(
+ XID /*id*/,
+ RESTYPE /*type*/,
+ Bool /*skipFree*/);
+
+extern _X_EXPORT Bool ChangeResourceValue(
+ XID /*id*/,
+ RESTYPE /*rtype*/,
+ pointer /*value*/);
+
+extern _X_EXPORT void FindClientResourcesByType(
+ ClientPtr /*client*/,
+ RESTYPE /*type*/,
+ FindResType /*func*/,
+ pointer /*cdata*/);
+
+extern _X_EXPORT void FindAllClientResources(
+ ClientPtr /*client*/,
+ FindAllRes /*func*/,
+ pointer /*cdata*/);
+
+extern _X_EXPORT void FreeClientNeverRetainResources(
+ ClientPtr /*client*/);
+
+extern _X_EXPORT void FreeClientResources(
+ ClientPtr /*client*/);
+
+extern _X_EXPORT void FreeAllResources(void);
+
+extern _X_EXPORT Bool LegalNewID(
+ XID /*id*/,
+ ClientPtr /*client*/);
+
+extern _X_EXPORT pointer LookupClientResourceComplex(
+ ClientPtr client,
+ RESTYPE type,
+ FindComplexResType func,
+ pointer cdata);
+
+extern _X_EXPORT int dixLookupResourceByType(
+ pointer *result,
+ XID id,
+ RESTYPE rtype,
+ ClientPtr client,
+ Mask access_mode);
+
+extern _X_EXPORT int dixLookupResourceByClass(
+ pointer *result,
+ XID id,
+ RESTYPE rclass,
+ ClientPtr client,
+ Mask access_mode);
+
+extern _X_EXPORT void GetXIDRange(
+ int /*client*/,
+ Bool /*server*/,
+ XID * /*minp*/,
+ XID * /*maxp*/);
+
+extern _X_EXPORT unsigned int GetXIDList(
+ ClientPtr /*client*/,
+ unsigned int /*count*/,
+ XID * /*pids*/);
+
+extern _X_EXPORT RESTYPE lastResourceType;
+extern _X_EXPORT RESTYPE TypeMask;
+
+#endif /* RESOURCE_H */
+