#ifndef DIX_H
#define DIX_H
#include "gc.h"
#include "window.h"
#include "input.h"
#define EARLIER -1
#define SAMETIME 0
#define LATER 1
#define NullClient ((ClientPtr) 0)
#define REQUEST(type) \
register type *stuff = (type *)client->requestBuffer
#define REQUEST_SIZE_MATCH(req)\
if ((sizeof(req) >> 2) != client->req_len)\
return(BadLength)
#define REQUEST_AT_LEAST_SIZE(req) \
if ((sizeof(req) >> 2) > client->req_len )\
return(BadLength)
#define REQUEST_FIXED_SIZE(req, n)\
if (((sizeof(req) >> 2) > client->req_len) || \
(((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
return(BadLength)
#define LEGAL_NEW_RESOURCE(id,client)\
if (!LegalNewID(id,client)) \
{\
client->errorValue = id;\
return(BadIDChoice);\
}
#define LOOKUP_DRAWABLE(did, client)\
((client->lastDrawableID == did) ? \
client->lastDrawable : (DrawablePtr)LookupDrawable(did, client))
#ifdef XCSECURITY
#define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
if (client->lastDrawableID == did && !client->trustLevel)\
pDraw = client->lastDrawable;\
else \
{\
pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
RC_DRAWABLE, mode);\
if (!pDraw) \
{\
client->errorValue = did; \
return BadDrawable;\
}\
if (pDraw->type == UNDRAWABLE_WINDOW)\
return BadMatch;\
}
#define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
if (client->lastDrawableID == did && !client->trustLevel)\
pDraw = client->lastDrawable;\
else \
{\
pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
RC_DRAWABLE, mode);\
if (!pDraw) \
{\
client->errorValue = did; \
return BadDrawable;\
}\
}
#define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
if (client->lastGCID == rid && !client->trustLevel)\
pGC = client->lastGC;\
else\
pGC = (GC *) SecurityLookupIDByType(client, rid, RT_GC, mode);\
if (!pGC)\
{\
client->errorValue = rid;\
return (BadGC);\
}
#define VERIFY_DRAWABLE(pDraw, did, client)\
SECURITY_VERIFY_DRAWABLE(pDraw, did, client, SecurityUnknownAccess)
#define VERIFY_GEOMETRABLE(pDraw, did, client)\
SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, SecurityUnknownAccess)
#define VERIFY_GC(pGC, rid, client)\
SECURITY_VERIFY_GC(pGC, rid, client, SecurityUnknownAccess)
#else
#define VERIFY_DRAWABLE(pDraw, did, client)\
if (client->lastDrawableID == did)\
pDraw = client->lastDrawable;\
else \
{\
pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
if (!pDraw) \
{\
client->errorValue = did; \
return BadDrawable;\
}\
if (pDraw->type == UNDRAWABLE_WINDOW)\
return BadMatch;\
}
#define VERIFY_GEOMETRABLE(pDraw, did, client)\
if (client->lastDrawableID == did)\
pDraw = client->lastDrawable;\
else \
{\
pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
if (!pDraw) \
{\
client->errorValue = did; \
return BadDrawable;\
}\
}
#define VERIFY_GC(pGC, rid, client)\
if (client->lastGCID == rid)\
pGC = client->lastGC;\
else\
pGC = (GC *)LookupIDByType(rid, RT_GC);\
if (!pGC)\
{\
client->errorValue = rid;\
return (BadGC);\
}
#define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
VERIFY_DRAWABLE(pDraw, did, client)
#define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
VERIFY_GEOMETRABLE(pDraw, did, client)
#define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
VERIFY_GC(pGC, rid, client)
#endif
#if defined(NEED_DBE_BUF_BITS)
#define SET_DBE_DSTBUF(_pDraw, _drawID) \
SET_DBE_BUF(_pDraw, _drawID, dstBuffer, TRUE)
#define SET_DBE_SRCBUF(_pDraw, _drawID) \
SET_DBE_BUF(_pDraw, _drawID, srcBuffer, FALSE)
#if defined (NEED_DBE_BUF_VALIDATE)
#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
if (_pDraw->type == DRAWABLE_WINDOW)\
{\
int thisbuf = (_pDraw->id == _drawID);\
if (thisbuf != ((WindowPtr)_pDraw)->_whichBuffer)\
{\
((WindowPtr)_pDraw)->_whichBuffer = thisbuf;\
DbeValidateBuffer((WindowPtr)_pDraw, _drawID, _dstbuf);\
}\
}
#else
#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
if (_pDraw->type == DRAWABLE_WINDOW)\
{\
((WindowPtr)_pDraw)->_whichBuffer = (_pDraw->id == _drawID);\
}
#endif
#else
#define SET_DBE_DSTBUF(_pDraw, _drawID)
#define SET_DBE_SRCBUF(_pDraw, _drawID)
#endif
#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
(client->lastDrawableID != drawID))\
{\
SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, SecurityWriteAccess);\
SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);\
if ((pGC->depth != pDraw->depth) ||\
(pGC->pScreen != pDraw->pScreen))\
return (BadMatch);\
client->lastDrawable = pDraw;\
client->lastDrawableID = drawID;\
client->lastGC = pGC;\
client->lastGCID = stuff->gc;\
}\
else\
{\
pGC = client->lastGC;\
pDraw = client->lastDrawable;\
}\
SET_DBE_DSTBUF(pDraw, drawID);\
if (pGC->serialNumber != pDraw->serialNumber)\
ValidateGC(pDraw, pGC);
#define WriteReplyToClient(pClient, size, pReply) { \
if ((pClient)->swapped) \
(*ReplySwapVector[((xReq *)(pClient)->requestBuffer)->reqType]) \
(pClient, (int)(size), pReply); \
else (void) WriteToClient(pClient, (int)(size), (char *)(pReply)); }
#define WriteSwappedDataToClient(pClient, size, pbuf) \
if ((pClient)->swapped) \
(*(pClient)->pSwapReplyFunc)(pClient, (int)(size), pbuf); \
else (void) WriteToClient (pClient, (int)(size), (char *)(pbuf));
typedef struct _TimeStamp *TimeStampPtr;
#ifndef _XTYPEDEF_CLIENTPTR
typedef struct _Client *ClientPtr;
#define _XTYPEDEF_CLIENTPTR
#endif
typedef struct _WorkQueue *WorkQueuePtr;
extern ClientPtr requestingClient;
extern ClientPtr *clients;
extern ClientPtr serverClient;
extern int currentMaxClients;
typedef int HWEventQueueType;
typedef HWEventQueueType* HWEventQueuePtr;
extern HWEventQueuePtr checkForInput[2];
typedef struct _TimeStamp {
CARD32 months;
CARD32 milliseconds;
} TimeStamp;
extern void SetInputCheck(
HWEventQueuePtr ,
HWEventQueuePtr );
extern void CloseDownClient(
ClientPtr );
extern void UpdateCurrentTime(void);
extern void UpdateCurrentTimeIf(void);
extern void InitSelections(void);
extern void FlushClientCaches(XID );
extern int dixDestroyPixmap(
pointer ,
XID );
extern void CloseDownRetainedResources(void);
extern void InitClient(
ClientPtr ,
int ,
pointer );
extern ClientPtr NextAvailableClient(
pointer );
extern void SendErrorToClient(
ClientPtr ,
unsigned int ,
unsigned int ,
XID ,
int );
extern void DeleteWindowFromAnySelections(
WindowPtr );
extern void MarkClientException(
ClientPtr );
extern int GetGeometry(
ClientPtr ,
xGetGeometryReply* );
extern int SendConnSetup(
ClientPtr ,
char* );
extern int DoGetImage(
ClientPtr ,
int ,
Drawable ,
int ,
int ,
int ,
int ,
Mask ,
xGetImageReply **);
#ifdef LBX
extern void IncrementClientCount(void);
#endif
extern void CopyISOLatin1Lowered(
unsigned char * ,
unsigned char * ,
int );
#ifdef XCSECURITY
extern WindowPtr SecurityLookupWindow(
XID ,
ClientPtr ,
Mask );
extern pointer SecurityLookupDrawable(
XID ,
ClientPtr ,
Mask );
extern WindowPtr LookupWindow(
XID ,
ClientPtr );
extern pointer LookupDrawable(
XID ,
ClientPtr );
#else
extern WindowPtr LookupWindow(
XID ,
ClientPtr );
extern pointer LookupDrawable(
XID ,
ClientPtr );
#define SecurityLookupWindow(rid, client, access_mode) \
LookupWindow(rid, client)
#define SecurityLookupDrawable(rid, client, access_mode) \
LookupDrawable(rid, client)
#endif
extern ClientPtr LookupClient(
XID ,
ClientPtr );
extern void NoopDDA(void);
extern int AlterSaveSetForClient(
ClientPtr ,
WindowPtr ,
unsigned );
extern void DeleteWindowFromAnySaveSet(
WindowPtr );
extern void BlockHandler(
pointer ,
pointer );
extern void WakeupHandler(
int ,
pointer );
typedef void (* WakeupHandlerProcPtr)(
pointer ,
int ,
pointer );
extern Bool RegisterBlockAndWakeupHandlers(
BlockHandlerProcPtr ,
WakeupHandlerProcPtr ,
pointer );
extern void RemoveBlockAndWakeupHandlers(
BlockHandlerProcPtr ,
WakeupHandlerProcPtr ,
pointer );
extern void InitBlockAndWakeupHandlers(void);
extern void ProcessWorkQueue(void);
extern void ProcessWorkQueueZombies(void);
extern Bool QueueWorkProc(
Bool (* )(
ClientPtr ,
pointer ),
ClientPtr ,
pointer
);
typedef Bool (* ClientSleepProcPtr)(
ClientPtr ,
pointer );
extern Bool ClientSleep(
ClientPtr ,
ClientSleepProcPtr ,
pointer );
#ifndef ___CLIENTSIGNAL_DEFINED___
#define ___CLIENTSIGNAL_DEFINED___
extern Bool ClientSignal(
ClientPtr );
#endif
extern void ClientWakeup(
ClientPtr );
extern Bool ClientIsAsleep(
ClientPtr );
extern Atom MakeAtom(
char * ,
unsigned ,
Bool );
extern Bool ValidAtom(
Atom );
extern char *NameForAtom(
Atom );
extern void AtomError(void);
extern void FreeAllAtoms(void);
extern void InitAtoms(void);
extern void SetMaskForEvent(
Mask ,
int );
extern Bool IsParent(
WindowPtr ,
WindowPtr );
extern WindowPtr GetCurrentRootWindow(void);
extern WindowPtr GetSpriteWindow(void);
extern void NoticeEventTime(xEventPtr );
extern void EnqueueEvent(
xEventPtr ,
DeviceIntPtr ,
int );
extern void ComputeFreezes(void);
extern void CheckGrabForSyncs(
DeviceIntPtr ,
Bool ,
Bool );
extern void ActivatePointerGrab(
DeviceIntPtr ,
GrabPtr ,
TimeStamp ,
Bool );
extern void DeactivatePointerGrab(
DeviceIntPtr );
extern void ActivateKeyboardGrab(
DeviceIntPtr ,
GrabPtr ,
TimeStamp ,
Bool );
extern void DeactivateKeyboardGrab(
DeviceIntPtr );
extern void AllowSome(
ClientPtr ,
TimeStamp ,
DeviceIntPtr ,
int );
extern void ReleaseActiveGrabs(
ClientPtr client);
extern int DeliverEventsToWindow(
WindowPtr ,
xEventPtr ,
int ,
Mask ,
GrabPtr ,
int );
extern int DeliverDeviceEvents(
WindowPtr ,
xEventPtr ,
GrabPtr ,
WindowPtr ,
DeviceIntPtr ,
int );
extern void DefineInitialRootWindow(
WindowPtr );
extern void WindowHasNewCursor(
WindowPtr );
extern Bool CheckDeviceGrabs(
DeviceIntPtr ,
xEventPtr ,
int ,
int );
extern void DeliverFocusedEvent(
DeviceIntPtr ,
xEventPtr ,
WindowPtr ,
int );
extern void DeliverGrabbedEvent(
xEventPtr ,
DeviceIntPtr ,
Bool ,
int );
#ifdef XKB
extern void FixKeyState(
xEvent * ,
DeviceIntPtr );
#endif
extern void RecalculateDeliverableEvents(
WindowPtr );
extern int OtherClientGone(
pointer ,
XID );
extern void DoFocusEvents(
DeviceIntPtr ,
WindowPtr ,
WindowPtr ,
int );
extern int SetInputFocus(
ClientPtr ,
DeviceIntPtr ,
Window ,
CARD8 ,
Time ,
Bool );
extern int GrabDevice(
ClientPtr ,
DeviceIntPtr ,
unsigned ,
unsigned ,
Window ,
unsigned ,
Time ,
Mask ,
CARD8 * );
extern void InitEvents(void);
extern void CloseDownEvents(void);
extern void DeleteWindowFromAnyEvents(
WindowPtr ,
Bool );
extern Mask EventMaskForClient(
WindowPtr ,
ClientPtr );
extern int DeliverEvents(
WindowPtr ,
xEventPtr ,
int ,
WindowPtr );
extern void WriteEventsToClient(
ClientPtr ,
int ,
xEventPtr );
extern int TryClientEvents(
ClientPtr ,
xEventPtr ,
int ,
Mask ,
Mask ,
GrabPtr );
extern void WindowsRestructured(void);
#ifdef RANDR
void
ScreenRestructured (ScreenPtr pScreen);
#endif
extern void ResetClientPrivates(void);
extern int AllocateClientPrivateIndex(void);
extern Bool AllocateClientPrivate(
int ,
unsigned );
#ifndef _XTYPEDEF_CALLBACKLISTPTR
typedef struct _CallbackList *CallbackListPtr;
#define _XTYPEDEF_CALLBACKLISTPTR
#endif
typedef void (*CallbackProcPtr) (
CallbackListPtr *, pointer, pointer);
typedef Bool (*AddCallbackProcPtr) (
CallbackListPtr *, CallbackProcPtr, pointer);
typedef Bool (*DeleteCallbackProcPtr) (
CallbackListPtr *, CallbackProcPtr, pointer);
typedef void (*CallCallbacksProcPtr) (
CallbackListPtr *, pointer);
typedef void (*DeleteCallbackListProcPtr) (
CallbackListPtr *);
typedef struct _CallbackProcs {
AddCallbackProcPtr AddCallback;
DeleteCallbackProcPtr DeleteCallback;
CallCallbacksProcPtr CallCallbacks;
DeleteCallbackListProcPtr DeleteCallbackList;
} CallbackFuncsRec, *CallbackFuncsPtr;
extern Bool CreateCallbackList(
CallbackListPtr * ,
CallbackFuncsPtr );
extern Bool AddCallback(
CallbackListPtr * ,
CallbackProcPtr ,
pointer );
extern Bool DeleteCallback(
CallbackListPtr * ,
CallbackProcPtr ,
pointer );
extern void CallCallbacks(
CallbackListPtr * ,
pointer );
extern void DeleteCallbackList(
CallbackListPtr * );
extern void InitCallbackManager(void);
extern CallbackListPtr ServerGrabCallback;
typedef enum {SERVER_GRABBED, SERVER_UNGRABBED,
CLIENT_PERVIOUS, CLIENT_IMPERVIOUS } ServerGrabState;
typedef struct {
ClientPtr client;
ServerGrabState grabstate;
} ServerGrabInfoRec;
extern CallbackListPtr EventCallback;
typedef struct {
ClientPtr client;
xEventPtr events;
int count;
} EventInfoRec;
extern CallbackListPtr DeviceEventCallback;
typedef struct {
xEventPtr events;
int count;
} DeviceEventInfoRec;
#endif