1 /* $XFree86: xc/programs/Xserver/include/dix.h,v 3.26 2003/01/12 02:44:27 dawes Exp $ */
2 /***********************************************************
4 Copyright 1987, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from The Open Group.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 ******************************************************************/
48 /* $Xorg: dix.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
61 #define NullClient ((ClientPtr) 0)
62 #define REQUEST(type) \
63 register type *stuff = (type *)client->requestBuffer
66 #define REQUEST_SIZE_MATCH(req)\
67 if ((sizeof(req) >> 2) != client->req_len)\
70 #define REQUEST_AT_LEAST_SIZE(req) \
71 if ((sizeof(req) >> 2) > client->req_len )\
74 #define REQUEST_FIXED_SIZE(req, n)\
75 if (((sizeof(req) >> 2) > client->req_len) || \
76 (((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
79 #define LEGAL_NEW_RESOURCE(id,client)\
80 if (!LegalNewID(id,client)) \
82 client->errorValue = id;\
86 /* XXX if you are using this macro, you are probably not generating Match
87 * errors where appropriate */
88 #define LOOKUP_DRAWABLE(did, client)\
89 ((client->lastDrawableID == did) ? \
90 client->lastDrawable : (DrawablePtr)LookupDrawable(did, client))
94 #define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
95 if (client->lastDrawableID == did && !client->trustLevel)\
96 pDraw = client->lastDrawable;\
99 pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
103 client->errorValue = did; \
106 if (pDraw->type == UNDRAWABLE_WINDOW)\
110 #define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
111 if (client->lastDrawableID == did && !client->trustLevel)\
112 pDraw = client->lastDrawable;\
115 pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
119 client->errorValue = did; \
124 #define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
125 if (client->lastGCID == rid && !client->trustLevel)\
126 pGC = client->lastGC;\
128 pGC = (GC *) SecurityLookupIDByType(client, rid, RT_GC, mode);\
131 client->errorValue = rid;\
135 #define VERIFY_DRAWABLE(pDraw, did, client)\
136 SECURITY_VERIFY_DRAWABLE(pDraw, did, client, SecurityUnknownAccess)
138 #define VERIFY_GEOMETRABLE(pDraw, did, client)\
139 SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, SecurityUnknownAccess)
141 #define VERIFY_GC(pGC, rid, client)\
142 SECURITY_VERIFY_GC(pGC, rid, client, SecurityUnknownAccess)
144 #else /* not XCSECURITY */
146 #define VERIFY_DRAWABLE(pDraw, did, client)\
147 if (client->lastDrawableID == did)\
148 pDraw = client->lastDrawable;\
151 pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
154 client->errorValue = did; \
157 if (pDraw->type == UNDRAWABLE_WINDOW)\
161 #define VERIFY_GEOMETRABLE(pDraw, did, client)\
162 if (client->lastDrawableID == did)\
163 pDraw = client->lastDrawable;\
166 pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
169 client->errorValue = did; \
174 #define VERIFY_GC(pGC, rid, client)\
175 if (client->lastGCID == rid)\
176 pGC = client->lastGC;\
178 pGC = (GC *)LookupIDByType(rid, RT_GC);\
181 client->errorValue = rid;\
185 #define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
186 VERIFY_DRAWABLE(pDraw, did, client)
188 #define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
189 VERIFY_GEOMETRABLE(pDraw, did, client)
191 #define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
192 VERIFY_GC(pGC, rid, client)
194 #endif /* XCSECURITY */
197 * We think that most hardware implementations of DBE will want
198 * LookupID*(dbe_back_buffer_id) to return the window structure that the
199 * id is a back buffer for. Since both front and back buffers will
200 * return the same structure, you need to be able to distinguish
201 * somewhere what kind of buffer (front/back) was being asked for, so
202 * that ddx can render to the right place. That's the problem that the
203 * following code solves. Note: we couldn't embed this in the LookupID*
204 * functions because the VALIDATE_DRAWABLE_AND_GC macro often circumvents
205 * those functions by checking a one-element cache. That's why we're
206 * mucking with VALIDATE_DRAWABLE_AND_GC.
208 * If you put -DNEED_DBE_BUF_BITS into PervasiveDBEDefines, the window
209 * structure will have two additional bits defined, srcBuffer and
210 * dstBuffer, and their values will be maintained via the macros
211 * SET_DBE_DSTBUF and SET_DBE_SRCBUF (below). If you also
212 * put -DNEED_DBE_BUF_VALIDATE into PervasiveDBEDefines, the function
213 * DbeValidateBuffer will be called any time the bits change to give you
214 * a chance to do some setup. See the DBE code for more details on this
215 * function. We put in these levels of conditionality so that you can do
216 * just what you need to do, and no more. If neither of these defines
217 * are used, the bits won't be there, and VALIDATE_DRAWABLE_AND_GC will
221 #if defined(NEED_DBE_BUF_BITS)
222 #define SET_DBE_DSTBUF(_pDraw, _drawID) \
223 SET_DBE_BUF(_pDraw, _drawID, dstBuffer, TRUE)
224 #define SET_DBE_SRCBUF(_pDraw, _drawID) \
225 SET_DBE_BUF(_pDraw, _drawID, srcBuffer, FALSE)
226 #if defined (NEED_DBE_BUF_VALIDATE)
227 #define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
228 if (_pDraw->type == DRAWABLE_WINDOW)\
230 int thisbuf = (_pDraw->id == _drawID);\
231 if (thisbuf != ((WindowPtr)_pDraw)->_whichBuffer)\
233 ((WindowPtr)_pDraw)->_whichBuffer = thisbuf;\
234 DbeValidateBuffer((WindowPtr)_pDraw, _drawID, _dstbuf);\
237 #else /* want buffer bits, but don't need to call DbeValidateBuffer */
238 #define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
239 if (_pDraw->type == DRAWABLE_WINDOW)\
241 ((WindowPtr)_pDraw)->_whichBuffer = (_pDraw->id == _drawID);\
243 #endif /* NEED_DBE_BUF_VALIDATE */
244 #else /* don't want buffer bits in window */
245 #define SET_DBE_DSTBUF(_pDraw, _drawID) /**/
246 #define SET_DBE_SRCBUF(_pDraw, _drawID) /**/
247 #endif /* NEED_DBE_BUF_BITS */
249 #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
250 if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
251 (client->lastDrawableID != drawID))\
253 SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, SecurityWriteAccess);\
254 SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);\
255 if ((pGC->depth != pDraw->depth) ||\
256 (pGC->pScreen != pDraw->pScreen))\
258 client->lastDrawable = pDraw;\
259 client->lastDrawableID = drawID;\
260 client->lastGC = pGC;\
261 client->lastGCID = stuff->gc;\
265 pGC = client->lastGC;\
266 pDraw = client->lastDrawable;\
268 SET_DBE_DSTBUF(pDraw, drawID);\
269 if (pGC->serialNumber != pDraw->serialNumber)\
270 ValidateGC(pDraw, pGC);
273 #define WriteReplyToClient(pClient, size, pReply) { \
274 if ((pClient)->swapped) \
275 (*ReplySwapVector[((xReq *)(pClient)->requestBuffer)->reqType]) \
276 (pClient, (int)(size), pReply); \
277 else (void) WriteToClient(pClient, (int)(size), (char *)(pReply)); }
279 #define WriteSwappedDataToClient(pClient, size, pbuf) \
280 if ((pClient)->swapped) \
281 (*(pClient)->pSwapReplyFunc)(pClient, (int)(size), pbuf); \
282 else (void) WriteToClient (pClient, (int)(size), (char *)(pbuf));
284 typedef struct _TimeStamp *TimeStampPtr;
286 #ifndef _XTYPEDEF_CLIENTPTR
287 typedef struct _Client *ClientPtr; /* also in misc.h */
288 #define _XTYPEDEF_CLIENTPTR
291 typedef struct _WorkQueue *WorkQueuePtr;
293 extern ClientPtr requestingClient;
294 extern ClientPtr *clients;
295 extern ClientPtr serverClient;
296 extern int currentMaxClients;
298 typedef int HWEventQueueType;
299 typedef HWEventQueueType* HWEventQueuePtr;
301 extern HWEventQueuePtr checkForInput[2];
303 typedef struct _TimeStamp {
304 CARD32 months; /* really ~49.7 days */
310 extern void SetInputCheck(
311 HWEventQueuePtr /*c0*/,
312 HWEventQueuePtr /*c1*/);
314 extern void CloseDownClient(
315 ClientPtr /*client*/);
317 extern void UpdateCurrentTime(void);
319 extern void UpdateCurrentTimeIf(void);
321 extern void InitSelections(void);
323 extern void FlushClientCaches(XID /*id*/);
325 extern int dixDestroyPixmap(
329 extern void CloseDownRetainedResources(void);
331 extern void InitClient(
332 ClientPtr /*client*/,
336 extern ClientPtr NextAvailableClient(
339 extern void SendErrorToClient(
340 ClientPtr /*client*/,
341 unsigned int /*majorCode*/,
342 unsigned int /*minorCode*/,
346 extern void DeleteWindowFromAnySelections(
349 extern void MarkClientException(
350 ClientPtr /*client*/);
352 extern int GetGeometry(
353 ClientPtr /*client*/,
354 xGetGeometryReply* /* wa */);
356 extern int SendConnSetup(
357 ClientPtr /*client*/,
360 extern int DoGetImage(
361 ClientPtr /*client*/,
363 Drawable /*drawable*/,
369 xGetImageReply ** /*im_return*/);
372 extern void IncrementClientCount(void);
375 #if defined(DDXBEFORERESET)
376 extern void ddxBeforeReset (void);
381 extern void CopyISOLatin1Lowered(
382 unsigned char * /*dest*/,
383 unsigned char * /*source*/,
386 extern int CompareISOLatin1Lowered(
387 unsigned char * /*a*/,
389 unsigned char * /*b*/,
394 extern WindowPtr SecurityLookupWindow(
396 ClientPtr /*client*/,
397 Mask /*access_mode*/);
399 extern pointer SecurityLookupDrawable(
401 ClientPtr /*client*/,
402 Mask /*access_mode*/);
404 extern WindowPtr LookupWindow(
406 ClientPtr /*client*/);
408 extern pointer LookupDrawable(
410 ClientPtr /*client*/);
414 extern WindowPtr LookupWindow(
416 ClientPtr /*client*/);
418 extern pointer LookupDrawable(
420 ClientPtr /*client*/);
422 #define SecurityLookupWindow(rid, client, access_mode) \
423 LookupWindow(rid, client)
425 #define SecurityLookupDrawable(rid, client, access_mode) \
426 LookupDrawable(rid, client)
428 #endif /* XCSECURITY */
430 extern ClientPtr LookupClient(
432 ClientPtr /*client*/);
434 extern void NoopDDA(void);
436 extern int AlterSaveSetForClient(
437 ClientPtr /*client*/,
443 extern void DeleteWindowFromAnySaveSet(
446 extern void BlockHandler(
447 pointer /*pTimeout*/,
448 pointer /*pReadmask*/);
450 extern void WakeupHandler(
452 pointer /*pReadmask*/);
454 typedef void (* WakeupHandlerProcPtr)(
455 pointer /* blockData */,
457 pointer /* pReadmask */);
459 extern Bool RegisterBlockAndWakeupHandlers(
460 BlockHandlerProcPtr /*blockHandler*/,
461 WakeupHandlerProcPtr /*wakeupHandler*/,
462 pointer /*blockData*/);
464 extern void RemoveBlockAndWakeupHandlers(
465 BlockHandlerProcPtr /*blockHandler*/,
466 WakeupHandlerProcPtr /*wakeupHandler*/,
467 pointer /*blockData*/);
469 extern void InitBlockAndWakeupHandlers(void);
471 extern void ProcessWorkQueue(void);
473 extern void ProcessWorkQueueZombies(void);
475 extern Bool QueueWorkProc(
476 Bool (* /*function*/)(
477 ClientPtr /*clientUnused*/,
478 pointer /*closure*/),
479 ClientPtr /*client*/,
483 typedef Bool (* ClientSleepProcPtr)(
484 ClientPtr /*client*/,
485 pointer /*closure*/);
487 extern Bool ClientSleep(
488 ClientPtr /*client*/,
489 ClientSleepProcPtr /* function */,
490 pointer /*closure*/);
492 #ifndef ___CLIENTSIGNAL_DEFINED___
493 #define ___CLIENTSIGNAL_DEFINED___
494 extern Bool ClientSignal(
495 ClientPtr /*client*/);
496 #endif /* ___CLIENTSIGNAL_DEFINED___ */
498 extern void ClientWakeup(
499 ClientPtr /*client*/);
501 extern Bool ClientIsAsleep(
502 ClientPtr /*client*/);
506 extern Atom MakeAtom(
511 extern Bool ValidAtom(
514 extern char *NameForAtom(
517 extern void AtomError(void);
519 extern void FreeAllAtoms(void);
521 extern void InitAtoms(void);
525 extern void SetMaskForEvent(
530 extern Bool IsParent(
531 WindowPtr /* maybeparent */,
532 WindowPtr /* child */);
534 extern WindowPtr GetCurrentRootWindow(void);
536 extern WindowPtr GetSpriteWindow(void);
539 extern void NoticeEventTime(xEventPtr /* xE */);
541 extern void EnqueueEvent(
543 DeviceIntPtr /* device */,
546 extern void ComputeFreezes(void);
548 extern void CheckGrabForSyncs(
549 DeviceIntPtr /* dev */,
551 Bool /* otherMode */);
553 extern void ActivatePointerGrab(
554 DeviceIntPtr /* mouse */,
556 TimeStamp /* time */,
557 Bool /* autoGrab */);
559 extern void DeactivatePointerGrab(
560 DeviceIntPtr /* mouse */);
562 extern void ActivateKeyboardGrab(
563 DeviceIntPtr /* keybd */,
565 TimeStamp /* time */,
568 extern void DeactivateKeyboardGrab(
569 DeviceIntPtr /* keybd */);
571 extern void AllowSome(
572 ClientPtr /* client */,
573 TimeStamp /* time */,
574 DeviceIntPtr /* thisDev */,
577 extern void ReleaseActiveGrabs(
580 extern int DeliverEventsToWindow(
581 WindowPtr /* pWin */,
582 xEventPtr /* pEvents */,
588 extern int DeliverDeviceEvents(
589 WindowPtr /* pWin */,
592 WindowPtr /* stopAt */,
593 DeviceIntPtr /* dev */,
596 extern void DefineInitialRootWindow(
597 WindowPtr /* win */);
599 extern void WindowHasNewCursor(
600 WindowPtr /* pWin */);
602 extern Bool CheckDeviceGrabs(
603 DeviceIntPtr /* device */,
605 int /* checkFirst */,
608 extern void DeliverFocusedEvent(
609 DeviceIntPtr /* keybd */,
611 WindowPtr /* window */,
614 extern void DeliverGrabbedEvent(
616 DeviceIntPtr /* thisDev */,
617 Bool /* deactivateGrab */,
621 extern void FixKeyState(
623 DeviceIntPtr /* keybd */);
626 extern void RecalculateDeliverableEvents(
627 WindowPtr /* pWin */);
629 extern int OtherClientGone(
633 extern void DoFocusEvents(
634 DeviceIntPtr /* dev */,
635 WindowPtr /* fromWin */,
636 WindowPtr /* toWin */,
639 extern int SetInputFocus(
640 ClientPtr /* client */,
641 DeviceIntPtr /* dev */,
642 Window /* focusID */,
643 CARD8 /* revertTo */,
645 Bool /* followOK */);
647 extern int GrabDevice(
648 ClientPtr /* client */,
649 DeviceIntPtr /* dev */,
650 unsigned /* this_mode */,
651 unsigned /* other_mode */,
652 Window /* grabWindow */,
653 unsigned /* ownerEvents */,
656 CARD8 * /* status */);
658 extern void InitEvents(void);
660 extern void CloseDownEvents(void);
662 extern void DeleteWindowFromAnyEvents(
663 WindowPtr /* pWin */,
664 Bool /* freeResources */);
667 extern Mask EventMaskForClient(
668 WindowPtr /* pWin */,
669 ClientPtr /* client */);
673 extern int DeliverEvents(
677 WindowPtr /*otherParent*/);
680 extern void WriteEventsToClient(
681 ClientPtr /*pClient*/,
683 xEventPtr /*events*/);
685 extern int TryClientEvents(
686 ClientPtr /*client*/,
687 xEventPtr /*pEvents*/,
693 extern void WindowsRestructured(void);
698 ScreenRestructured (ScreenPtr pScreen);
701 extern void ResetClientPrivates(void);
703 extern int AllocateClientPrivateIndex(void);
705 extern Bool AllocateClientPrivate(
707 unsigned /*amount*/);
710 * callback manager stuff
713 #ifndef _XTYPEDEF_CALLBACKLISTPTR
714 typedef struct _CallbackList *CallbackListPtr; /* also in misc.h */
715 #define _XTYPEDEF_CALLBACKLISTPTR
718 typedef void (*CallbackProcPtr) (
719 CallbackListPtr *, pointer, pointer);
721 typedef Bool (*AddCallbackProcPtr) (
722 CallbackListPtr *, CallbackProcPtr, pointer);
724 typedef Bool (*DeleteCallbackProcPtr) (
725 CallbackListPtr *, CallbackProcPtr, pointer);
727 typedef void (*CallCallbacksProcPtr) (
728 CallbackListPtr *, pointer);
730 typedef void (*DeleteCallbackListProcPtr) (
733 typedef struct _CallbackProcs {
734 AddCallbackProcPtr AddCallback;
735 DeleteCallbackProcPtr DeleteCallback;
736 CallCallbacksProcPtr CallCallbacks;
737 DeleteCallbackListProcPtr DeleteCallbackList;
738 } CallbackFuncsRec, *CallbackFuncsPtr;
740 extern Bool CreateCallbackList(
741 CallbackListPtr * /*pcbl*/,
742 CallbackFuncsPtr /*cbfuncs*/);
744 extern Bool AddCallback(
745 CallbackListPtr * /*pcbl*/,
746 CallbackProcPtr /*callback*/,
749 extern Bool DeleteCallback(
750 CallbackListPtr * /*pcbl*/,
751 CallbackProcPtr /*callback*/,
754 extern void CallCallbacks(
755 CallbackListPtr * /*pcbl*/,
756 pointer /*call_data*/);
758 extern void DeleteCallbackList(
759 CallbackListPtr * /*pcbl*/);
761 extern void InitCallbackManager(void);
764 * ServerGrabCallback stuff
767 extern CallbackListPtr ServerGrabCallback;
769 typedef enum {SERVER_GRABBED, SERVER_UNGRABBED,
770 CLIENT_PERVIOUS, CLIENT_IMPERVIOUS } ServerGrabState;
774 ServerGrabState grabstate;
778 * EventCallback stuff
781 extern CallbackListPtr EventCallback;
790 * DeviceEventCallback stuff
793 extern CallbackListPtr DeviceEventCallback;
798 } DeviceEventInfoRec;
801 * SelectionCallback stuff
804 extern CallbackListPtr SelectionCallback;
808 SelectionWindowDestroy,
810 } SelectionCallbackKind;
813 struct _Selection *selection;
814 SelectionCallbackKind kind;