1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
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
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
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.
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.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
59 #define NullClient ((ClientPtr) 0)
60 #define REQUEST(type) \
61 register type *stuff = (type *)client->requestBuffer
64 #define REQUEST_SIZE_MATCH(req)\
65 if ((sizeof(req) >> 2) != client->req_len)\
68 #define REQUEST_AT_LEAST_SIZE(req) \
69 if ((sizeof(req) >> 2) > client->req_len )\
72 #define REQUEST_FIXED_SIZE(req, n)\
73 if (((sizeof(req) >> 2) > client->req_len) || \
74 (((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
77 #define LEGAL_NEW_RESOURCE(id,client)\
78 if (!LegalNewID(id,client)) \
80 client->errorValue = id;\
84 #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
85 if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
86 (client->lastDrawableID != drawID))\
89 rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\
93 rc = dixLookupGC(&(pGC), stuff->gc, client, DixReadAccess);\
96 if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
98 client->lastDrawable = pDraw;\
99 client->lastDrawableID = drawID;\
100 client->lastGC = pGC;\
101 client->lastGCID = stuff->gc;\
105 pGC = client->lastGC;\
106 pDraw = client->lastDrawable;\
108 if (pGC->serialNumber != pDraw->serialNumber)\
109 ValidateGC(pDraw, pGC);
112 #define WriteReplyToClient(pClient, size, pReply) { \
113 if ((pClient)->swapped) \
114 (*ReplySwapVector[((xReq *)(pClient)->requestBuffer)->reqType]) \
115 (pClient, (int)(size), pReply); \
116 else (void) WriteToClient(pClient, (int)(size), (char *)(pReply)); }
118 #define WriteSwappedDataToClient(pClient, size, pbuf) \
119 if ((pClient)->swapped) \
120 (*(pClient)->pSwapReplyFunc)(pClient, (int)(size), pbuf); \
121 else (void) WriteToClient (pClient, (int)(size), (char *)(pbuf));
123 typedef struct _TimeStamp
*TimeStampPtr
;
125 #ifndef _XTYPEDEF_CLIENTPTR
126 typedef struct _Client
*ClientPtr
; /* also in misc.h */
127 #define _XTYPEDEF_CLIENTPTR
130 typedef struct _WorkQueue
*WorkQueuePtr
;
132 extern ClientPtr requestingClient
;
133 extern ClientPtr
*clients
;
134 extern ClientPtr serverClient
;
135 extern int currentMaxClients
;
136 extern char dispatchExceptionAtReset
;
138 typedef int HWEventQueueType
;
139 typedef HWEventQueueType
* HWEventQueuePtr
;
141 extern HWEventQueuePtr checkForInput
[2];
143 typedef struct _TimeStamp
{
144 CARD32 months
; /* really ~49.7 days */
150 extern void SetInputCheck(
151 HWEventQueuePtr
/*c0*/,
152 HWEventQueuePtr
/*c1*/);
154 extern void CloseDownClient(
155 ClientPtr
/*client*/);
157 extern void UpdateCurrentTime(void);
159 extern void UpdateCurrentTimeIf(void);
161 extern void InitSelections(void);
163 extern void FlushClientCaches(XID
/*id*/);
165 extern int dixDestroyPixmap(
169 extern void InitClient(
170 ClientPtr
/*client*/,
174 extern ClientPtr
NextAvailableClient(
177 extern void SendErrorToClient(
178 ClientPtr
/*client*/,
179 unsigned int /*majorCode*/,
180 unsigned int /*minorCode*/,
184 extern void DeleteWindowFromAnySelections(
187 extern void MarkClientException(
188 ClientPtr
/*client*/);
190 extern int SendConnSetup(
191 ClientPtr
/*client*/,
194 #if defined(DDXBEFORERESET)
195 extern void ddxBeforeReset (void);
200 extern void CopyISOLatin1Lowered(
201 unsigned char * /*dest*/,
202 unsigned char * /*source*/,
205 extern int CompareISOLatin1Lowered(
206 unsigned char * /*a*/,
208 unsigned char * /*b*/,
211 extern int dixLookupWindow(
217 extern int dixLookupDrawable(
224 extern int dixLookupGC(
230 extern int dixLookupClient(
237 * These are deprecated compatibility functions and will be removed soon!
238 * Please use the new dixLookup*() functions above.
240 extern WindowPtr
SecurityLookupWindow(XID
, ClientPtr
, Mask
);
241 extern WindowPtr
LookupWindow(XID
, ClientPtr
);
242 extern pointer
SecurityLookupDrawable(XID
, ClientPtr
, Mask
);
243 extern pointer
LookupDrawable(XID
, ClientPtr
);
244 extern ClientPtr
LookupClient(XID
, ClientPtr
);
245 /* end deprecated functions */
247 extern void NoopDDA(void);
249 extern int AlterSaveSetForClient(
250 ClientPtr
/*client*/,
256 extern void DeleteWindowFromAnySaveSet(
259 extern void BlockHandler(
260 pointer
/*pTimeout*/,
261 pointer
/*pReadmask*/);
263 extern void WakeupHandler(
265 pointer
/*pReadmask*/);
267 typedef void (* WakeupHandlerProcPtr
)(
268 pointer
/* blockData */,
270 pointer
/* pReadmask */);
272 extern Bool
RegisterBlockAndWakeupHandlers(
273 BlockHandlerProcPtr
/*blockHandler*/,
274 WakeupHandlerProcPtr
/*wakeupHandler*/,
275 pointer
/*blockData*/);
277 extern void RemoveBlockAndWakeupHandlers(
278 BlockHandlerProcPtr
/*blockHandler*/,
279 WakeupHandlerProcPtr
/*wakeupHandler*/,
280 pointer
/*blockData*/);
282 extern void InitBlockAndWakeupHandlers(void);
284 extern void ProcessWorkQueue(void);
286 extern void ProcessWorkQueueZombies(void);
288 extern Bool
QueueWorkProc(
289 Bool (* /*function*/)(
290 ClientPtr
/*clientUnused*/,
291 pointer
/*closure*/),
292 ClientPtr
/*client*/,
296 typedef Bool (* ClientSleepProcPtr
)(
297 ClientPtr
/*client*/,
298 pointer
/*closure*/);
300 extern Bool
ClientSleep(
301 ClientPtr
/*client*/,
302 ClientSleepProcPtr
/* function */,
303 pointer
/*closure*/);
305 #ifndef ___CLIENTSIGNAL_DEFINED___
306 #define ___CLIENTSIGNAL_DEFINED___
307 extern Bool
ClientSignal(
308 ClientPtr
/*client*/);
309 #endif /* ___CLIENTSIGNAL_DEFINED___ */
311 extern void ClientWakeup(
312 ClientPtr
/*client*/);
314 extern Bool
ClientIsAsleep(
315 ClientPtr
/*client*/);
319 extern Atom
MakeAtom(
324 extern Bool
ValidAtom(
327 extern char *NameForAtom(
330 extern void AtomError(void);
332 extern void FreeAllAtoms(void);
334 extern void InitAtoms(void);
338 extern void SetVendorRelease(int release
);
340 extern void SetVendorString(char *string
);
344 extern void SetMaskForEvent(
349 extern Bool
IsParent(
350 WindowPtr
/* maybeparent */,
351 WindowPtr
/* child */);
353 extern WindowPtr
GetCurrentRootWindow(void);
355 extern WindowPtr
GetSpriteWindow(void);
358 extern void NoticeEventTime(xEventPtr
/* xE */);
360 extern void EnqueueEvent(
362 DeviceIntPtr
/* device */,
365 extern void ComputeFreezes(void);
367 extern void CheckGrabForSyncs(
368 DeviceIntPtr
/* dev */,
370 Bool
/* otherMode */);
372 extern void ActivatePointerGrab(
373 DeviceIntPtr
/* mouse */,
375 TimeStamp
/* time */,
376 Bool
/* autoGrab */);
378 extern void DeactivatePointerGrab(
379 DeviceIntPtr
/* mouse */);
381 extern void ActivateKeyboardGrab(
382 DeviceIntPtr
/* keybd */,
384 TimeStamp
/* time */,
387 extern void DeactivateKeyboardGrab(
388 DeviceIntPtr
/* keybd */);
390 extern void AllowSome(
391 ClientPtr
/* client */,
392 TimeStamp
/* time */,
393 DeviceIntPtr
/* thisDev */,
396 extern void ReleaseActiveGrabs(
399 extern int DeliverEventsToWindow(
400 WindowPtr
/* pWin */,
401 xEventPtr
/* pEvents */,
407 extern int DeliverDeviceEvents(
408 WindowPtr
/* pWin */,
411 WindowPtr
/* stopAt */,
412 DeviceIntPtr
/* dev */,
415 extern void DefineInitialRootWindow(
416 WindowPtr
/* win */);
418 extern void WindowHasNewCursor(
419 WindowPtr
/* pWin */);
421 extern Bool
CheckDeviceGrabs(
422 DeviceIntPtr
/* device */,
424 int /* checkFirst */,
427 extern void DeliverFocusedEvent(
428 DeviceIntPtr
/* keybd */,
430 WindowPtr
/* window */,
433 extern void DeliverGrabbedEvent(
435 DeviceIntPtr
/* thisDev */,
436 Bool
/* deactivateGrab */,
440 extern void FixKeyState(
442 DeviceIntPtr
/* keybd */);
445 extern void RecalculateDeliverableEvents(
446 WindowPtr
/* pWin */);
448 extern int OtherClientGone(
452 extern void DoFocusEvents(
453 DeviceIntPtr
/* dev */,
454 WindowPtr
/* fromWin */,
455 WindowPtr
/* toWin */,
458 extern int SetInputFocus(
459 ClientPtr
/* client */,
460 DeviceIntPtr
/* dev */,
461 Window
/* focusID */,
462 CARD8
/* revertTo */,
464 Bool
/* followOK */);
466 extern int GrabDevice(
467 ClientPtr
/* client */,
468 DeviceIntPtr
/* dev */,
469 unsigned /* this_mode */,
470 unsigned /* other_mode */,
471 Window
/* grabWindow */,
472 unsigned /* ownerEvents */,
475 CARD8
* /* status */);
477 extern void InitEvents(void);
479 extern void CloseDownEvents(void);
481 extern void DeleteWindowFromAnyEvents(
482 WindowPtr
/* pWin */,
483 Bool
/* freeResources */);
486 extern Mask
EventMaskForClient(
487 WindowPtr
/* pWin */,
488 ClientPtr
/* client */);
492 extern int DeliverEvents(
496 WindowPtr
/*otherParent*/);
499 extern void WriteEventsToClient(
500 ClientPtr
/*pClient*/,
502 xEventPtr
/*events*/);
504 extern int TryClientEvents(
505 ClientPtr
/*client*/,
506 xEventPtr
/*pEvents*/,
512 extern void WindowsRestructured(void);
515 extern void ReinitializeRootWindow(WindowPtr win
, int xoff
, int yoff
);
520 ScreenRestructured (ScreenPtr pScreen
);
523 extern void ResetClientPrivates(void);
525 extern int AllocateClientPrivateIndex(void);
527 extern Bool
AllocateClientPrivate(
529 unsigned /*amount*/);
531 extern int ffs(int i
);
534 * callback manager stuff
537 #ifndef _XTYPEDEF_CALLBACKLISTPTR
538 typedef struct _CallbackList
*CallbackListPtr
; /* also in misc.h */
539 #define _XTYPEDEF_CALLBACKLISTPTR
542 typedef void (*CallbackProcPtr
) (
543 CallbackListPtr
*, pointer
, pointer
);
545 typedef Bool (*AddCallbackProcPtr
) (
546 CallbackListPtr
*, CallbackProcPtr
, pointer
);
548 typedef Bool (*DeleteCallbackProcPtr
) (
549 CallbackListPtr
*, CallbackProcPtr
, pointer
);
551 typedef void (*CallCallbacksProcPtr
) (
552 CallbackListPtr
*, pointer
);
554 typedef void (*DeleteCallbackListProcPtr
) (
557 typedef struct _CallbackProcs
{
558 AddCallbackProcPtr AddCallback
;
559 DeleteCallbackProcPtr DeleteCallback
;
560 CallCallbacksProcPtr CallCallbacks
;
561 DeleteCallbackListProcPtr DeleteCallbackList
;
562 } CallbackFuncsRec
, *CallbackFuncsPtr
;
564 extern Bool
AddCallback(
565 CallbackListPtr
* /*pcbl*/,
566 CallbackProcPtr
/*callback*/,
569 extern Bool
DeleteCallback(
570 CallbackListPtr
* /*pcbl*/,
571 CallbackProcPtr
/*callback*/,
574 extern void CallCallbacks(
575 CallbackListPtr
* /*pcbl*/,
576 pointer
/*call_data*/);
578 extern void DeleteCallbackList(
579 CallbackListPtr
* /*pcbl*/);
581 extern void InitCallbackManager(void);
584 * ServerGrabCallback stuff
587 extern CallbackListPtr ServerGrabCallback
;
589 typedef enum {SERVER_GRABBED
, SERVER_UNGRABBED
,
590 CLIENT_PERVIOUS
, CLIENT_IMPERVIOUS
} ServerGrabState
;
594 ServerGrabState grabstate
;
598 * EventCallback stuff
601 extern CallbackListPtr EventCallback
;
610 * DeviceEventCallback stuff
613 extern CallbackListPtr DeviceEventCallback
;
618 } DeviceEventInfoRec
;
621 * SelectionCallback stuff
624 extern CallbackListPtr SelectionCallback
;
628 SelectionWindowDestroy
,
630 } SelectionCallbackKind
;
633 struct _Selection
*selection
;
634 SelectionCallbackKind kind
;
639 #define strcasecmp xstrcasecmp
640 extern int xstrcasecmp(char *s1
, char *s2
);