]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/include/dix.h
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / include / dix.h
1 /***********************************************************
2
3 Copyright (c) 1987  X Consortium
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
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 X CONSORTIUM 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.
21
22 Except as contained in this notice, the name of the X Consortium 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 X Consortium.
25
26
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29                         All Rights Reserved
30
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.  
38
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
45 SOFTWARE.
46
47 ******************************************************************/
48 /* $XConsortium: dix.h /main/44 1996/12/15 21:24:57 rws $ */
49 /* $XFree86: xc/programs/Xserver/include/dix.h,v 3.7 1996/12/31 04:17:46 dawes Exp $ */
50
51 #ifndef DIX_H
52 #define DIX_H
53
54 #include "gc.h"
55 #include "window.h"
56 #include "input.h"
57
58 #define EARLIER -1
59 #define SAMETIME 0
60 #define LATER 1
61
62 #define NullClient ((ClientPtr) 0)
63 #define REQUEST(type) \
64         register type *stuff = (type *)client->requestBuffer
65
66
67 #define REQUEST_SIZE_MATCH(req)\
68     if ((sizeof(req) >> 2) != client->req_len)\
69          return(BadLength)
70
71 #define REQUEST_AT_LEAST_SIZE(req) \
72     if ((sizeof(req) >> 2) > client->req_len )\
73          return(BadLength)
74
75 #define REQUEST_FIXED_SIZE(req, n)\
76     if (((sizeof(req) >> 2) > client->req_len) || \
77         (((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
78          return(BadLength)
79
80 #define LEGAL_NEW_RESOURCE(id,client)\
81     if (!LegalNewID(id,client)) \
82     {\
83         client->errorValue = id;\
84         return(BadIDChoice);\
85     }
86
87 /* XXX if you are using this macro, you are probably not generating Match
88  * errors where appropriate */
89 #define LOOKUP_DRAWABLE(did, client)\
90     ((client->lastDrawableID == did) ? \
91      client->lastDrawable : (DrawablePtr)LookupDrawable(did, client))
92
93 #ifdef XCSECURITY
94
95 #define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
96     if (client->lastDrawableID == did && !client->trustLevel)\
97         pDraw = client->lastDrawable;\
98     else \
99     {\
100         pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
101                                                       RC_DRAWABLE, mode);\
102         if (!pDraw) \
103         {\
104             client->errorValue = did; \
105             return BadDrawable;\
106         }\
107         if (pDraw->type == UNDRAWABLE_WINDOW)\
108             return BadMatch;\
109     }
110
111 #define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
112     if (client->lastDrawableID == did && !client->trustLevel)\
113         pDraw = client->lastDrawable;\
114     else \
115     {\
116         pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
117                                                       RC_DRAWABLE, mode);\
118         if (!pDraw) \
119         {\
120             client->errorValue = did; \
121             return BadDrawable;\
122         }\
123     }
124
125 #define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
126     if (client->lastGCID == rid && !client->trustLevel)\
127         pGC = client->lastGC;\
128     else\
129         pGC = (GC *) SecurityLookupIDByType(client, rid, RT_GC, mode);\
130     if (!pGC)\
131     {\
132         client->errorValue = rid;\
133         return (BadGC);\
134     }
135
136 #define VERIFY_DRAWABLE(pDraw, did, client)\
137         SECURITY_VERIFY_DRAWABLE(pDraw, did, client, SecurityUnknownAccess)
138
139 #define VERIFY_GEOMETRABLE(pDraw, did, client)\
140         SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, SecurityUnknownAccess)
141
142 #define VERIFY_GC(pGC, rid, client)\
143         SECURITY_VERIFY_GC(pGC, rid, client, SecurityUnknownAccess)
144
145 #else /* not XCSECURITY */
146
147 #define VERIFY_DRAWABLE(pDraw, did, client)\
148     if (client->lastDrawableID == did)\
149         pDraw = client->lastDrawable;\
150     else \
151     {\
152         pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
153         if (!pDraw) \
154         {\
155             client->errorValue = did; \
156             return BadDrawable;\
157         }\
158         if (pDraw->type == UNDRAWABLE_WINDOW)\
159             return BadMatch;\
160     }
161
162 #define VERIFY_GEOMETRABLE(pDraw, did, client)\
163     if (client->lastDrawableID == did)\
164         pDraw = client->lastDrawable;\
165     else \
166     {\
167         pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
168         if (!pDraw) \
169         {\
170             client->errorValue = did; \
171             return BadDrawable;\
172         }\
173     }
174
175 #define VERIFY_GC(pGC, rid, client)\
176     if (client->lastGCID == rid)\
177         pGC = client->lastGC;\
178     else\
179         pGC = (GC *)LookupIDByType(rid, RT_GC);\
180     if (!pGC)\
181     {\
182         client->errorValue = rid;\
183         return (BadGC);\
184     }
185
186 #define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
187         VERIFY_DRAWABLE(pDraw, did, client)
188
189 #define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
190         VERIFY_GEOMETRABLE(pDraw, did, client)
191
192 #define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
193         VERIFY_GC(pGC, rid, client)
194
195 #endif /* XCSECURITY */
196
197 /*
198  * We think that most hardware implementations of DBE will want
199  * LookupID*(dbe_back_buffer_id) to return the window structure that the
200  * id is a back buffer for.  Since both front and back buffers will
201  * return the same structure, you need to be able to distinguish
202  * somewhere what kind of buffer (front/back) was being asked for, so
203  * that ddx can render to the right place.  That's the problem that the
204  * following code solves.  Note: we couldn't embed this in the LookupID*
205  * functions because the VALIDATE_DRAWABLE_AND_GC macro often circumvents
206  * those functions by checking a one-element cache.  That's why we're
207  * mucking with VALIDATE_DRAWABLE_AND_GC.
208  * 
209  * If you put -DNEED_DBE_BUF_BITS into PervasiveDBEDefines, the window
210  * structure will have two additional bits defined, srcBuffer and
211  * dstBuffer, and their values will be maintained via the macros
212  * SET_DBE_DSTBUF and SET_DBE_SRCBUF (below).  If you also
213  * put -DNEED_DBE_BUF_VALIDATE into PervasiveDBEDefines, the function
214  * DbeValidateBuffer will be called any time the bits change to give you
215  * a chance to do some setup.  See the DBE code for more details on this
216  * function.  We put in these levels of conditionality so that you can do
217  * just what you need to do, and no more.  If neither of these defines
218  * are used, the bits won't be there, and VALIDATE_DRAWABLE_AND_GC will
219  * be unchanged.        dpw
220  */
221
222 #if defined(NEED_DBE_BUF_BITS)
223 #define SET_DBE_DSTBUF(_pDraw, _drawID) \
224         SET_DBE_BUF(_pDraw, _drawID, dstBuffer, TRUE)
225 #define SET_DBE_SRCBUF(_pDraw, _drawID) \
226         SET_DBE_BUF(_pDraw, _drawID, srcBuffer, FALSE)
227 #if defined (NEED_DBE_BUF_VALIDATE)
228 #define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
229     if (_pDraw->type == DRAWABLE_WINDOW)\
230     {\
231         int thisbuf = (_pDraw->id == _drawID);\
232         if (thisbuf != ((WindowPtr)_pDraw)->_whichBuffer)\
233         {\
234              ((WindowPtr)_pDraw)->_whichBuffer = thisbuf;\
235              DbeValidateBuffer((WindowPtr)_pDraw, _drawID, _dstbuf);\
236         }\
237      }
238 #else /* want buffer bits, but don't need to call DbeValidateBuffer */
239 #define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
240     if (_pDraw->type == DRAWABLE_WINDOW)\
241     {\
242         ((WindowPtr)_pDraw)->_whichBuffer = (_pDraw->id == _drawID);\
243     }
244 #endif /* NEED_DBE_BUF_VALIDATE */
245 #else /* don't want buffer bits in window */
246 #define SET_DBE_DSTBUF(_pDraw, _drawID) /**/
247 #define SET_DBE_SRCBUF(_pDraw, _drawID) /**/
248 #endif /* NEED_DBE_BUF_BITS */
249
250 #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
251     if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
252         (client->lastDrawableID != drawID))\
253     {\
254         SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, SecurityWriteAccess);\
255         SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);\
256         if ((pGC->depth != pDraw->depth) ||\
257             (pGC->pScreen != pDraw->pScreen))\
258             return (BadMatch);\
259         client->lastDrawable = pDraw;\
260         client->lastDrawableID = drawID;\
261         client->lastGC = pGC;\
262         client->lastGCID = stuff->gc;\
263     }\
264     else\
265     {\
266         pGC = client->lastGC;\
267         pDraw = client->lastDrawable;\
268     }\
269     SET_DBE_DSTBUF(pDraw, drawID);\
270     if (pGC->serialNumber != pDraw->serialNumber)\
271         ValidateGC(pDraw, pGC);
272
273
274 #define WriteReplyToClient(pClient, size, pReply) \
275    if ((pClient)->swapped) \
276       (*ReplySwapVector[((xReq *)(pClient)->requestBuffer)->reqType]) \
277            (pClient, (int)(size), pReply); \
278       else (void) WriteToClient(pClient, (int)(size), (char *)(pReply));
279
280 #define WriteSwappedDataToClient(pClient, size, pbuf) \
281    if ((pClient)->swapped) \
282       (*(pClient)->pSwapReplyFunc)(pClient, (int)(size), pbuf); \
283    else (void) WriteToClient (pClient, (int)(size), (char *)(pbuf));
284
285 typedef struct _TimeStamp *TimeStampPtr;
286
287 #ifndef _XTYPEDEF_CLIENTPTR
288 typedef struct _Client *ClientPtr; /* also in misc.h */
289 #define _XTYPEDEF_CLIENTPTR
290 #endif
291
292 typedef struct _WorkQueue       *WorkQueuePtr;
293
294 extern ClientPtr requestingClient;
295 extern ClientPtr *clients;
296 extern ClientPtr serverClient;
297 extern int currentMaxClients;
298
299 #if !(defined(__alpha) || defined(__alpha__))
300 typedef long HWEventQueueType;
301 #else
302 typedef int HWEventQueueType;
303 #endif
304 typedef HWEventQueueType* HWEventQueuePtr;
305
306 extern HWEventQueuePtr checkForInput[2];
307
308 typedef struct _TimeStamp {
309     CARD32 months;      /* really ~49.7 days */
310     CARD32 milliseconds;
311 }           TimeStamp;
312
313 /* dispatch.c */
314
315 extern void SetInputCheck(
316 #if NeedFunctionPrototypes
317     HWEventQueuePtr /*c0*/,
318     HWEventQueuePtr /*c1*/
319 #endif
320 );
321
322 extern void CloseDownClient(
323 #if NeedFunctionPrototypes
324     ClientPtr /*client*/
325 #endif
326 );
327
328 extern void UpdateCurrentTime(
329 #if NeedFunctionPrototypes
330     void
331 #endif
332 );
333
334 extern void UpdateCurrentTimeIf(
335 #if NeedFunctionPrototypes
336     void
337 #endif
338 );
339
340 extern void InitSelections(
341 #if NeedFunctionPrototypes
342     void
343 #endif
344 );
345
346 extern void FlushClientCaches(
347 #if NeedFunctionPrototypes
348     XID /*id*/
349 #endif
350 );
351
352 extern int dixDestroyPixmap(
353 #if NeedFunctionPrototypes
354     pointer /*value*/,
355     XID /*pid*/
356 #endif
357 );
358
359 extern void CloseDownRetainedResources(
360 #if NeedFunctionPrototypes
361     void
362 #endif
363 );
364
365 extern void InitClient(
366 #if NeedFunctionPrototypes
367     ClientPtr /*client*/,
368     int /*i*/,
369     pointer /*ospriv*/
370 #endif
371 );
372
373 extern ClientPtr NextAvailableClient(
374 #if NeedFunctionPrototypes
375     pointer /*ospriv*/
376 #endif
377 );
378
379 extern void SendErrorToClient(
380 #if NeedFunctionPrototypes
381     ClientPtr /*client*/,
382     unsigned int /*majorCode*/,
383     unsigned int /*minorCode*/,
384     XID /*resId*/,
385     int /*errorCode*/
386 #endif
387 );
388
389 extern void DeleteWindowFromAnySelections(
390 #if NeedFunctionPrototypes
391     WindowPtr /*pWin*/
392 #endif
393 );
394
395 extern void MarkClientException(
396 #if NeedFunctionPrototypes
397     ClientPtr /*client*/
398 #endif
399 );
400
401 extern int GetGeometry(
402 #if NeedFunctionPrototypes
403     ClientPtr /*client*/,
404     xGetGeometryReply* /* wa */
405 #endif
406 );
407
408 /* dixutils.c */
409
410 extern void CopyISOLatin1Lowered(
411 #if NeedFunctionPrototypes
412     unsigned char * /*dest*/,
413     unsigned char * /*source*/,
414     int /*length*/
415 #endif
416 );
417
418 #ifdef XCSECURITY
419
420 extern WindowPtr SecurityLookupWindow(
421 #if NeedFunctionPrototypes
422     XID /*rid*/,
423     ClientPtr /*client*/,
424     Mask /*access_mode*/
425 #endif
426 );
427
428 extern pointer SecurityLookupDrawable(
429 #if NeedFunctionPrototypes
430     XID /*rid*/,
431     ClientPtr /*client*/,
432     Mask /*access_mode*/
433 #endif
434 );
435
436 extern WindowPtr LookupWindow(
437 #if NeedFunctionPrototypes
438     XID /*rid*/,
439     ClientPtr /*client*/
440 #endif
441 );
442
443 extern pointer LookupDrawable(
444 #if NeedFunctionPrototypes
445     XID /*rid*/,
446     ClientPtr /*client*/
447 #endif
448 );
449
450 #else
451
452 extern WindowPtr LookupWindow(
453 #if NeedFunctionPrototypes
454     XID /*rid*/,
455     ClientPtr /*client*/
456 #endif
457 );
458
459 extern pointer LookupDrawable(
460 #if NeedFunctionPrototypes
461     XID /*rid*/,
462     ClientPtr /*client*/
463 #endif
464 );
465
466 #define SecurityLookupWindow(rid, client, access_mode) \
467         LookupWindow(rid, client)
468
469 #define SecurityLookupDrawable(rid, client, access_mode) \
470         LookupDrawable(rid, client)
471
472 #endif /* XCSECURITY */
473
474 extern ClientPtr LookupClient(
475 #if NeedFunctionPrototypes
476     XID /*rid*/,
477     ClientPtr /*client*/
478 #endif
479 );
480
481 extern void NoopDDA(
482 #if NeedVarargsPrototypes
483     void *,
484     ...
485 #endif
486 );
487
488 extern int AlterSaveSetForClient(
489 #if NeedFunctionPrototypes
490     ClientPtr /*client*/,
491     WindowPtr /*pWin*/,
492     unsigned /*mode*/
493 #endif
494 );
495
496 extern void DeleteWindowFromAnySaveSet(
497 #if NeedFunctionPrototypes
498     WindowPtr /*pWin*/
499 #endif
500 );
501
502 extern void BlockHandler(
503 #if NeedFunctionPrototypes
504     pointer /*pTimeout*/,
505     pointer /*pReadmask*/
506 #endif
507 );
508
509 extern void WakeupHandler(
510 #if NeedFunctionPrototypes
511     int /*result*/,
512     pointer /*pReadmask*/
513 #endif
514 );
515
516 typedef struct timeval ** OSTimePtr;
517
518 typedef void (* BlockHandlerProcPtr)(
519 #if NeedNestedPrototypes
520     pointer /* blockData */,
521     OSTimePtr /* pTimeout */,
522     pointer /* pReadmask */
523 #endif
524 );
525
526 typedef void (* WakeupHandlerProcPtr)(
527 #if NeedNestedPrototypes
528     pointer /* blockData */,
529     int /* result */,
530     pointer /* pReadmask */
531 #endif
532 );
533
534 extern Bool RegisterBlockAndWakeupHandlers(
535 #if NeedFunctionPrototypes
536     BlockHandlerProcPtr /*blockHandler*/,
537     WakeupHandlerProcPtr /*wakeupHandler*/,
538     pointer /*blockData*/
539 #endif
540 );
541
542 extern void RemoveBlockAndWakeupHandlers(
543 #if NeedFunctionPrototypes
544     BlockHandlerProcPtr /*blockHandler*/,
545     WakeupHandlerProcPtr /*wakeupHandler*/,
546     pointer /*blockData*/
547 #endif
548 );
549
550 extern void InitBlockAndWakeupHandlers(
551 #if NeedFunctionPrototypes
552     void
553 #endif
554 );
555
556 extern void ProcessWorkQueue(
557 #if NeedFunctionPrototypes
558     void
559 #endif
560 );
561
562 extern Bool QueueWorkProc(
563 #if NeedFunctionPrototypes
564     Bool (* /*function*/)(
565 #if NeedNestedPrototypes
566         ClientPtr /*clientUnused*/,
567         pointer /*closure*/
568 #endif
569         ),
570     ClientPtr /*client*/,
571     pointer /*closure*/
572 #endif
573 );
574
575 typedef Bool (* ClientSleepProcPtr)(
576 #if NeedFunctionPrototypes
577     ClientPtr /*client*/,
578     pointer /*closure*/
579 #endif
580 );
581
582 extern Bool ClientSleep(
583 #if NeedFunctionPrototypes
584     ClientPtr /*client*/,
585     ClientSleepProcPtr /* function */,
586     pointer /*closure*/
587 #endif
588 );
589
590 extern Bool ClientSignal(
591 #if NeedFunctionPrototypes
592     ClientPtr /*client*/
593 #endif
594 );
595
596 extern void ClientWakeup(
597 #if NeedFunctionPrototypes
598     ClientPtr /*client*/
599 #endif
600 );
601
602 extern Bool ClientIsAsleep(
603 #if NeedFunctionPrototypes
604     ClientPtr /*client*/
605 #endif
606 );
607
608 /* atom.c */
609
610 extern Atom MakeAtom(
611 #if NeedFunctionPrototypes
612     char * /*string*/,
613     unsigned /*len*/,
614     Bool /*makeit*/
615 #endif
616 );
617
618 extern Bool ValidAtom(
619 #if NeedFunctionPrototypes
620     Atom /*atom*/
621 #endif
622 );
623
624 extern char *NameForAtom(
625 #if NeedFunctionPrototypes
626     Atom /*atom*/
627 #endif
628 );
629
630 extern void AtomError(
631 #if NeedFunctionPrototypes
632     void
633 #endif
634 );
635
636 extern void FreeAllAtoms(
637 #if NeedFunctionPrototypes
638     void
639 #endif
640 );
641
642 extern void InitAtoms(
643 #if NeedFunctionPrototypes
644     void
645 #endif
646 );
647
648 /* events.c */
649
650 extern void SetMaskForEvent(
651 #if NeedFunctionPrototypes
652     Mask /* mask */,
653     int /* event */
654 #endif
655 );
656
657 extern Bool PointerConfinedToScreen(
658 #if NeedFunctionPrototypes
659     void
660 #endif
661 );
662
663 extern Bool IsParent(
664 #if NeedFunctionPrototypes
665     WindowPtr /* maybeparent */,
666     WindowPtr /* child */
667 #endif
668 );
669
670 extern WindowPtr GetCurrentRootWindow(
671 #if NeedFunctionPrototypes
672     void
673 #endif
674 );
675
676 extern WindowPtr GetSpriteWindow(
677 #if NeedFunctionPrototypes
678     void
679 #endif
680 );
681
682 extern void GetSpritePosition(
683 #if NeedFunctionPrototypes
684     int * /* px */,
685     int * /* py */
686 #endif
687 );
688
689 extern void NoticeEventTime(
690 #if NeedFunctionPrototypes
691     xEventPtr /* xE */
692 #endif
693 );
694
695 extern void EnqueueEvent(
696 #if NeedFunctionPrototypes
697     xEventPtr /* xE */,
698     DeviceIntPtr /* device */,
699     int /* count */
700 #endif
701 );
702
703 extern void ComputeFreezes(
704 #if NeedFunctionPrototypes
705     void
706 #endif
707 );
708
709 extern void CheckGrabForSyncs(
710 #if NeedFunctionPrototypes
711     DeviceIntPtr /* dev */,
712     Bool /* thisMode */,
713     Bool /* otherMode */
714 #endif
715 );
716
717 extern void ActivatePointerGrab(
718 #if NeedFunctionPrototypes
719     DeviceIntPtr /* mouse */,
720     GrabPtr /* grab */,
721     TimeStamp /* time */,
722     Bool /* autoGrab */
723 #endif
724 );
725
726 extern void DeactivatePointerGrab(
727 #if NeedFunctionPrototypes
728     DeviceIntPtr /* mouse */
729 #endif
730 );
731
732 extern void ActivateKeyboardGrab(
733 #if NeedFunctionPrototypes
734     DeviceIntPtr /* keybd */,
735     GrabPtr /* grab */,
736     TimeStamp /* time */,
737     Bool /* passive */
738 #endif
739 );
740
741 extern void DeactivateKeyboardGrab(
742 #if NeedFunctionPrototypes
743     DeviceIntPtr /* keybd */
744 #endif
745 );
746
747 extern void AllowSome(
748 #if NeedFunctionPrototypes
749     ClientPtr   /* client */,
750     TimeStamp /* time */,
751     DeviceIntPtr /* thisDev */,
752     int /* newState */
753 #endif
754 );
755
756 extern void ReleaseActiveGrabs(
757 #if NeedFunctionPrototypes
758 ClientPtr client
759 #endif
760 );
761
762 extern int DeliverEventsToWindow(
763 #if NeedFunctionPrototypes
764     WindowPtr /* pWin */,
765     xEventPtr /* pEvents */,
766     int /* count */,
767     Mask /* filter */,
768     GrabPtr /* grab */,
769     int /* mskidx */
770 #endif
771 );
772
773 extern int DeliverDeviceEvents(
774 #if NeedFunctionPrototypes
775     WindowPtr /* pWin */,
776     xEventPtr /* xE */,
777     GrabPtr /* grab */,
778     WindowPtr /* stopAt */,
779     DeviceIntPtr /* dev */,
780     int /* count */
781 #endif
782 );
783
784 extern void DefineInitialRootWindow(
785 #if NeedFunctionPrototypes
786     WindowPtr /* win */
787 #endif
788 );
789
790 extern void WindowHasNewCursor(
791 #if NeedFunctionPrototypes
792     WindowPtr /* pWin */
793 #endif
794 );
795
796 extern Bool CheckDeviceGrabs(
797 #if NeedFunctionPrototypes
798     DeviceIntPtr /* device */,
799     xEventPtr /* xE */,
800     int /* checkFirst */,
801     int /* count */
802 #endif
803 );
804
805 extern void DeliverFocusedEvent(
806 #if NeedFunctionPrototypes
807     DeviceIntPtr /* keybd */,
808     xEventPtr /* xE */,
809     WindowPtr /* window */,
810     int /* count */
811 #endif
812 );
813
814 extern void DeliverGrabbedEvent(
815 #if NeedFunctionPrototypes
816     xEventPtr /* xE */,
817     DeviceIntPtr /* thisDev */,
818     Bool /* deactivateGrab */,
819     int /* count */
820 #endif
821 );
822
823 extern void RecalculateDeliverableEvents(
824 #if NeedFunctionPrototypes
825     WindowPtr /* pWin */
826 #endif
827 );
828
829 extern int OtherClientGone(
830 #if NeedFunctionPrototypes
831     pointer /* value */,
832     XID /* id */
833 #endif
834 );
835
836 extern void DoFocusEvents(
837 #if NeedFunctionPrototypes
838     DeviceIntPtr /* dev */,
839     WindowPtr /* fromWin */,
840     WindowPtr /* toWin */,
841     int /* mode */
842 #endif
843 );
844
845 extern int SetInputFocus(
846 #if NeedFunctionPrototypes
847     ClientPtr /* client */,
848     DeviceIntPtr /* dev */,
849     Window /* focusID */,
850     CARD8 /* revertTo */,
851     Time /* ctime */,
852     Bool /* followOK */
853 #endif
854 );
855
856 extern int GrabDevice(
857 #if NeedFunctionPrototypes
858     ClientPtr /* client */,
859     DeviceIntPtr /* dev */,
860     unsigned /* this_mode */,
861     unsigned /* other_mode */,
862     Window /* grabWindow */,
863     unsigned /* ownerEvents */,
864     Time /* ctime */,
865     Mask /* mask */,
866     CARD8 * /* status */
867 #endif
868 );
869
870 extern void InitEvents(
871 #if NeedFunctionPrototypes
872     void
873 #endif
874 );
875
876 extern void DeleteWindowFromAnyEvents(
877 #if NeedFunctionPrototypes
878     WindowPtr   /* pWin */,
879     Bool /* freeResources */
880 #endif
881 );
882
883 extern void CheckCursorConfinement(
884 #if NeedFunctionPrototypes
885     WindowPtr /* pWin */
886 #endif
887 );
888
889 extern Mask EventMaskForClient(
890 #if NeedFunctionPrototypes
891     WindowPtr /* pWin */,
892     ClientPtr /* client */
893 #endif
894 );
895
896
897
898 extern int DeliverEvents(
899 #if NeedFunctionPrototypes
900     WindowPtr /*pWin*/,
901     xEventPtr /*xE*/,
902     int /*count*/,
903     WindowPtr /*otherParent*/
904 #endif
905 );
906
907 extern void WriteEventsToClient(
908 #if NeedFunctionPrototypes
909     ClientPtr /*pClient*/,
910     int      /*count*/,
911     xEventPtr /*events*/
912 #endif
913 );
914
915 extern int TryClientEvents(
916 #if NeedFunctionPrototypes
917     ClientPtr /*client*/,
918     xEventPtr /*pEvents*/,
919     int /*count*/,
920     Mask /*mask*/,
921     Mask /*filter*/,
922     GrabPtr /*grab*/
923 #endif
924 );
925
926 extern int EventSelectForWindow(
927 #if NeedFunctionPrototypes
928     WindowPtr /*pWin*/,
929     ClientPtr /*client*/,
930     Mask /*mask*/
931 #endif
932 );
933
934 extern int EventSuppressForWindow(
935 #if NeedFunctionPrototypes
936     WindowPtr /*pWin*/,
937     ClientPtr /*client*/,
938     Mask /*mask*/,
939     Bool * /*checkOptional*/
940 #endif
941 );
942
943 extern int MaybeDeliverEventsToClient(
944 #if NeedFunctionPrototypes
945     WindowPtr /*pWin*/,
946     xEventPtr /*pEvents*/,
947     int /*count*/,
948     Mask /*filter*/,
949     ClientPtr /*dontClient*/
950 #endif
951 );
952
953 extern void WindowsRestructured(
954 #if NeedFunctionPrototypes
955     void
956 #endif
957 );
958
959 extern void ResetClientPrivates(
960 #if NeedFunctionPrototypes
961     void
962 #endif
963 );
964
965 extern int AllocateClientPrivateIndex(
966 #if NeedFunctionPrototypes
967     void
968 #endif
969 );
970
971 extern Bool AllocateClientPrivate(
972 #if NeedFunctionPrototypes
973     int /*index*/,
974     unsigned /*amount*/
975 #endif
976 );
977
978 /*
979  *  callback manager stuff
980  */
981
982 #ifndef _XTYPEDEF_CALLBACKLISTPTR
983 typedef struct _CallbackList *CallbackListPtr; /* also in misc.h */
984 #define _XTYPEDEF_CALLBACKLISTPTR
985 #endif
986
987 typedef void (*CallbackProcPtr) (
988 #if NeedNestedPrototypes
989     CallbackListPtr *, pointer, pointer
990 #endif
991 );
992
993 typedef Bool (*AddCallbackProcPtr) (
994 #if NeedNestedPrototypes
995     CallbackListPtr *, CallbackProcPtr, pointer
996 #endif
997 );
998
999 typedef Bool (*DeleteCallbackProcPtr) (
1000 #if NeedNestedPrototypes
1001     CallbackListPtr *, CallbackProcPtr, pointer
1002 #endif
1003 );
1004
1005 typedef void (*CallCallbacksProcPtr) (
1006 #if NeedNestedPrototypes
1007     CallbackListPtr *, pointer
1008 #endif
1009 );
1010
1011 typedef void (*DeleteCallbackListProcPtr) (
1012 #if NeedNestedPrototypes
1013     CallbackListPtr *
1014 #endif
1015 );
1016
1017 typedef struct _CallbackProcs {
1018     AddCallbackProcPtr          AddCallback;
1019     DeleteCallbackProcPtr       DeleteCallback;
1020     CallCallbacksProcPtr        CallCallbacks;
1021     DeleteCallbackListProcPtr   DeleteCallbackList;
1022 } CallbackFuncsRec, *CallbackFuncsPtr;
1023
1024 extern Bool CreateCallbackList(
1025 #if NeedFunctionPrototypes
1026     CallbackListPtr * /*pcbl*/,
1027     CallbackFuncsPtr /*cbfuncs*/
1028 #endif
1029 );
1030
1031 extern Bool AddCallback(
1032 #if NeedFunctionPrototypes
1033     CallbackListPtr * /*pcbl*/,
1034     CallbackProcPtr /*callback*/,
1035     pointer /*data*/
1036 #endif
1037 );
1038
1039 extern Bool DeleteCallback(
1040 #if NeedFunctionPrototypes
1041     CallbackListPtr * /*pcbl*/,
1042     CallbackProcPtr /*callback*/,
1043     pointer /*data*/
1044 #endif
1045 );
1046
1047 extern void CallCallbacks(
1048 #if NeedFunctionPrototypes
1049     CallbackListPtr * /*pcbl*/,
1050     pointer /*call_data*/
1051 #endif
1052 );
1053
1054 extern void DeleteCallbackList(
1055 #if NeedFunctionPrototypes
1056     CallbackListPtr * /*pcbl*/
1057 #endif
1058 );
1059
1060 extern void InitCallbackManager(
1061 #if NeedFunctionPrototypes
1062     void
1063 #endif
1064 );
1065
1066 /*
1067  *  ServerGrabCallback stuff
1068  */
1069
1070 extern CallbackListPtr ServerGrabCallback;
1071
1072 typedef enum {SERVER_GRABBED, SERVER_UNGRABBED,
1073               CLIENT_PERVIOUS, CLIENT_IMPERVIOUS } ServerGrabState;
1074
1075 typedef struct {
1076     ClientPtr client;
1077     ServerGrabState grabstate;
1078 } ServerGrabInfoRec;
1079
1080 /*
1081  *  EventCallback stuff
1082  */
1083
1084 extern CallbackListPtr EventCallback;
1085
1086 typedef struct {
1087     ClientPtr client;
1088     xEventPtr events;
1089     int count;
1090 } EventInfoRec;
1091
1092 /*
1093  *  DeviceEventCallback stuff
1094  */
1095
1096 extern CallbackListPtr DeviceEventCallback;
1097
1098 typedef struct {
1099     xEventPtr events;
1100     int count;
1101 } DeviceEventInfoRec;
1102
1103 #endif /* DIX_H */