First import
[xorg_rtime.git] / xorg-server-1.4 / include / dix.h
blobc1d609a61a67d089c59294ddcc95e5d7115bcaa5
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
9 documentation.
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.
28 All Rights Reserved
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
44 SOFTWARE.
46 ******************************************************************/
48 #ifndef DIX_H
49 #define DIX_H
51 #include "gc.h"
52 #include "window.h"
53 #include "input.h"
55 #define EARLIER -1
56 #define SAMETIME 0
57 #define LATER 1
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)\
66 return(BadLength)
68 #define REQUEST_AT_LEAST_SIZE(req) \
69 if ((sizeof(req) >> 2) > client->req_len )\
70 return(BadLength)
72 #define REQUEST_FIXED_SIZE(req, n)\
73 if (((sizeof(req) >> 2) > client->req_len) || \
74 (((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
75 return(BadLength)
77 #define LEGAL_NEW_RESOURCE(id,client)\
78 if (!LegalNewID(id,client)) \
80 client->errorValue = id;\
81 return(BadIDChoice);\
84 #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
85 if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
86 (client->lastDrawableID != drawID))\
88 int rc;\
89 rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\
90 DixWriteAccess);\
91 if (rc != Success)\
92 return rc;\
93 rc = dixLookupGC(&(pGC), stuff->gc, client, DixReadAccess);\
94 if (rc != Success)\
95 return rc;\
96 if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
97 return (BadMatch);\
98 client->lastDrawable = pDraw;\
99 client->lastDrawableID = drawID;\
100 client->lastGC = pGC;\
101 client->lastGCID = stuff->gc;\
103 else\
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
128 #endif
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 */
145 CARD32 milliseconds;
146 } TimeStamp;
148 /* dispatch.c */
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(
166 pointer /*value*/,
167 XID /*pid*/);
169 extern void InitClient(
170 ClientPtr /*client*/,
171 int /*i*/,
172 pointer /*ospriv*/);
174 extern ClientPtr NextAvailableClient(
175 pointer /*ospriv*/);
177 extern void SendErrorToClient(
178 ClientPtr /*client*/,
179 unsigned int /*majorCode*/,
180 unsigned int /*minorCode*/,
181 XID /*resId*/,
182 int /*errorCode*/);
184 extern void DeleteWindowFromAnySelections(
185 WindowPtr /*pWin*/);
187 extern void MarkClientException(
188 ClientPtr /*client*/);
190 extern int SendConnSetup(
191 ClientPtr /*client*/,
192 char* /*reason*/);
194 #if defined(DDXBEFORERESET)
195 extern void ddxBeforeReset (void);
196 #endif
198 /* dixutils.c */
200 extern void CopyISOLatin1Lowered(
201 unsigned char * /*dest*/,
202 unsigned char * /*source*/,
203 int /*length*/);
205 extern int CompareISOLatin1Lowered(
206 unsigned char * /*a*/,
207 int alen,
208 unsigned char * /*b*/,
209 int blen);
211 extern int dixLookupWindow(
212 WindowPtr *result,
213 XID id,
214 ClientPtr client,
215 Mask access_mode);
217 extern int dixLookupDrawable(
218 DrawablePtr *result,
219 XID id,
220 ClientPtr client,
221 Mask type_mask,
222 Mask access_mode);
224 extern int dixLookupGC(
225 GCPtr *result,
226 XID id,
227 ClientPtr client,
228 Mask access_mode);
230 extern int dixLookupClient(
231 ClientPtr *result,
232 XID id,
233 ClientPtr client,
234 Mask access_mode);
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*/,
251 WindowPtr /*pWin*/,
252 unsigned /*mode*/,
253 Bool /*toRoot*/,
254 Bool /*remap*/);
256 extern void DeleteWindowFromAnySaveSet(
257 WindowPtr /*pWin*/);
259 extern void BlockHandler(
260 pointer /*pTimeout*/,
261 pointer /*pReadmask*/);
263 extern void WakeupHandler(
264 int /*result*/,
265 pointer /*pReadmask*/);
267 typedef void (* WakeupHandlerProcPtr)(
268 pointer /* blockData */,
269 int /* result */,
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*/,
293 pointer /*closure*/
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*/);
317 /* atom.c */
319 extern Atom MakeAtom(
320 char * /*string*/,
321 unsigned /*len*/,
322 Bool /*makeit*/);
324 extern Bool ValidAtom(
325 Atom /*atom*/);
327 extern char *NameForAtom(
328 Atom /*atom*/);
330 extern void AtomError(void);
332 extern void FreeAllAtoms(void);
334 extern void InitAtoms(void);
336 /* main.c */
338 extern void SetVendorRelease(int release);
340 extern void SetVendorString(char *string);
342 /* events.c */
344 extern void SetMaskForEvent(
345 Mask /* mask */,
346 int /* event */);
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(
361 xEventPtr /* xE */,
362 DeviceIntPtr /* device */,
363 int /* count */);
365 extern void ComputeFreezes(void);
367 extern void CheckGrabForSyncs(
368 DeviceIntPtr /* dev */,
369 Bool /* thisMode */,
370 Bool /* otherMode */);
372 extern void ActivatePointerGrab(
373 DeviceIntPtr /* mouse */,
374 GrabPtr /* grab */,
375 TimeStamp /* time */,
376 Bool /* autoGrab */);
378 extern void DeactivatePointerGrab(
379 DeviceIntPtr /* mouse */);
381 extern void ActivateKeyboardGrab(
382 DeviceIntPtr /* keybd */,
383 GrabPtr /* grab */,
384 TimeStamp /* time */,
385 Bool /* passive */);
387 extern void DeactivateKeyboardGrab(
388 DeviceIntPtr /* keybd */);
390 extern void AllowSome(
391 ClientPtr /* client */,
392 TimeStamp /* time */,
393 DeviceIntPtr /* thisDev */,
394 int /* newState */);
396 extern void ReleaseActiveGrabs(
397 ClientPtr client);
399 extern int DeliverEventsToWindow(
400 WindowPtr /* pWin */,
401 xEventPtr /* pEvents */,
402 int /* count */,
403 Mask /* filter */,
404 GrabPtr /* grab */,
405 int /* mskidx */);
407 extern int DeliverDeviceEvents(
408 WindowPtr /* pWin */,
409 xEventPtr /* xE */,
410 GrabPtr /* grab */,
411 WindowPtr /* stopAt */,
412 DeviceIntPtr /* dev */,
413 int /* count */);
415 extern void DefineInitialRootWindow(
416 WindowPtr /* win */);
418 extern void WindowHasNewCursor(
419 WindowPtr /* pWin */);
421 extern Bool CheckDeviceGrabs(
422 DeviceIntPtr /* device */,
423 xEventPtr /* xE */,
424 int /* checkFirst */,
425 int /* count */);
427 extern void DeliverFocusedEvent(
428 DeviceIntPtr /* keybd */,
429 xEventPtr /* xE */,
430 WindowPtr /* window */,
431 int /* count */);
433 extern void DeliverGrabbedEvent(
434 xEventPtr /* xE */,
435 DeviceIntPtr /* thisDev */,
436 Bool /* deactivateGrab */,
437 int /* count */);
439 #ifdef XKB
440 extern void FixKeyState(
441 xEvent * /* xE */,
442 DeviceIntPtr /* keybd */);
443 #endif /* XKB */
445 extern void RecalculateDeliverableEvents(
446 WindowPtr /* pWin */);
448 extern int OtherClientGone(
449 pointer /* value */,
450 XID /* id */);
452 extern void DoFocusEvents(
453 DeviceIntPtr /* dev */,
454 WindowPtr /* fromWin */,
455 WindowPtr /* toWin */,
456 int /* mode */);
458 extern int SetInputFocus(
459 ClientPtr /* client */,
460 DeviceIntPtr /* dev */,
461 Window /* focusID */,
462 CARD8 /* revertTo */,
463 Time /* ctime */,
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 */,
473 Time /* ctime */,
474 Mask /* mask */,
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(
493 WindowPtr /*pWin*/,
494 xEventPtr /*xE*/,
495 int /*count*/,
496 WindowPtr /*otherParent*/);
499 extern void WriteEventsToClient(
500 ClientPtr /*pClient*/,
501 int /*count*/,
502 xEventPtr /*events*/);
504 extern int TryClientEvents(
505 ClientPtr /*client*/,
506 xEventPtr /*pEvents*/,
507 int /*count*/,
508 Mask /*mask*/,
509 Mask /*filter*/,
510 GrabPtr /*grab*/);
512 extern void WindowsRestructured(void);
514 #ifdef PANORAMIX
515 extern void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff);
516 #endif
518 #ifdef RANDR
519 void
520 ScreenRestructured (ScreenPtr pScreen);
521 #endif
523 extern void ResetClientPrivates(void);
525 extern int AllocateClientPrivateIndex(void);
527 extern Bool AllocateClientPrivate(
528 int /*index*/,
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
540 #endif
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) (
555 CallbackListPtr *);
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*/,
567 pointer /*data*/);
569 extern Bool DeleteCallback(
570 CallbackListPtr * /*pcbl*/,
571 CallbackProcPtr /*callback*/,
572 pointer /*data*/);
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;
592 typedef struct {
593 ClientPtr client;
594 ServerGrabState grabstate;
595 } ServerGrabInfoRec;
598 * EventCallback stuff
601 extern CallbackListPtr EventCallback;
603 typedef struct {
604 ClientPtr client;
605 xEventPtr events;
606 int count;
607 } EventInfoRec;
610 * DeviceEventCallback stuff
613 extern CallbackListPtr DeviceEventCallback;
615 typedef struct {
616 xEventPtr events;
617 int count;
618 } DeviceEventInfoRec;
621 * SelectionCallback stuff
624 extern CallbackListPtr SelectionCallback;
626 typedef enum {
627 SelectionSetOwner,
628 SelectionWindowDestroy,
629 SelectionClientClose
630 } SelectionCallbackKind;
632 typedef struct {
633 struct _Selection *selection;
634 SelectionCallbackKind kind;
635 } SelectionInfoRec;
637 /* strcasecmp.c */
638 #if NEED_STRCASECMP
639 #define strcasecmp xstrcasecmp
640 extern int xstrcasecmp(char *s1, char *s2);
641 #endif
643 #endif /* DIX_H */