dix.h revision 05b261ec
1/*********************************************************** 2 3Copyright 1987, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25 26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 27 28 All Rights Reserved 29 30Permission to use, copy, modify, and distribute this software and its 31documentation for any purpose and without fee is hereby granted, 32provided that the above copyright notice appear in all copies and that 33both that copyright notice and this permission notice appear in 34supporting documentation, and that the name of Digital not be 35used in advertising or publicity pertaining to distribution of the 36software without specific, written prior permission. 37 38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 44SOFTWARE. 45 46******************************************************************/ 47 48#ifndef DIX_H 49#define DIX_H 50 51#include "gc.h" 52#include "window.h" 53#include "input.h" 54 55#define EARLIER -1 56#define SAMETIME 0 57#define LATER 1 58 59#define NullClient ((ClientPtr) 0) 60#define REQUEST(type) \ 61 register type *stuff = (type *)client->requestBuffer 62 63 64#define REQUEST_SIZE_MATCH(req)\ 65 if ((sizeof(req) >> 2) != client->req_len)\ 66 return(BadLength) 67 68#define REQUEST_AT_LEAST_SIZE(req) \ 69 if ((sizeof(req) >> 2) > client->req_len )\ 70 return(BadLength) 71 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) 76 77#define LEGAL_NEW_RESOURCE(id,client)\ 78 if (!LegalNewID(id,client)) \ 79 {\ 80 client->errorValue = id;\ 81 return(BadIDChoice);\ 82 } 83 84#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\ 85 if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\ 86 (client->lastDrawableID != drawID))\ 87 {\ 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;\ 102 }\ 103 else\ 104 {\ 105 pGC = client->lastGC;\ 106 pDraw = client->lastDrawable;\ 107 }\ 108 if (pGC->serialNumber != pDraw->serialNumber)\ 109 ValidateGC(pDraw, pGC); 110 111 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)); } 117 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)); 122 123typedef struct _TimeStamp *TimeStampPtr; 124 125#ifndef _XTYPEDEF_CLIENTPTR 126typedef struct _Client *ClientPtr; /* also in misc.h */ 127#define _XTYPEDEF_CLIENTPTR 128#endif 129 130typedef struct _WorkQueue *WorkQueuePtr; 131 132extern ClientPtr requestingClient; 133extern ClientPtr *clients; 134extern ClientPtr serverClient; 135extern int currentMaxClients; 136extern char dispatchExceptionAtReset; 137 138typedef int HWEventQueueType; 139typedef HWEventQueueType* HWEventQueuePtr; 140 141extern HWEventQueuePtr checkForInput[2]; 142 143typedef struct _TimeStamp { 144 CARD32 months; /* really ~49.7 days */ 145 CARD32 milliseconds; 146} TimeStamp; 147 148/* dispatch.c */ 149 150extern void SetInputCheck( 151 HWEventQueuePtr /*c0*/, 152 HWEventQueuePtr /*c1*/); 153 154extern void CloseDownClient( 155 ClientPtr /*client*/); 156 157extern void UpdateCurrentTime(void); 158 159extern void UpdateCurrentTimeIf(void); 160 161extern void InitSelections(void); 162 163extern void FlushClientCaches(XID /*id*/); 164 165extern int dixDestroyPixmap( 166 pointer /*value*/, 167 XID /*pid*/); 168 169extern void InitClient( 170 ClientPtr /*client*/, 171 int /*i*/, 172 pointer /*ospriv*/); 173 174extern ClientPtr NextAvailableClient( 175 pointer /*ospriv*/); 176 177extern void SendErrorToClient( 178 ClientPtr /*client*/, 179 unsigned int /*majorCode*/, 180 unsigned int /*minorCode*/, 181 XID /*resId*/, 182 int /*errorCode*/); 183 184extern void DeleteWindowFromAnySelections( 185 WindowPtr /*pWin*/); 186 187extern void MarkClientException( 188 ClientPtr /*client*/); 189 190extern int SendConnSetup( 191 ClientPtr /*client*/, 192 char* /*reason*/); 193 194#if defined(DDXBEFORERESET) 195extern void ddxBeforeReset (void); 196#endif 197 198/* dixutils.c */ 199 200extern void CopyISOLatin1Lowered( 201 unsigned char * /*dest*/, 202 unsigned char * /*source*/, 203 int /*length*/); 204 205extern int CompareISOLatin1Lowered( 206 unsigned char * /*a*/, 207 int alen, 208 unsigned char * /*b*/, 209 int blen); 210 211extern int dixLookupWindow( 212 WindowPtr *result, 213 XID id, 214 ClientPtr client, 215 Mask access_mode); 216 217extern int dixLookupDrawable( 218 DrawablePtr *result, 219 XID id, 220 ClientPtr client, 221 Mask type_mask, 222 Mask access_mode); 223 224extern int dixLookupGC( 225 GCPtr *result, 226 XID id, 227 ClientPtr client, 228 Mask access_mode); 229 230extern int dixLookupClient( 231 ClientPtr *result, 232 XID id, 233 ClientPtr client, 234 Mask access_mode); 235 236/* 237 * These are deprecated compatibility functions and will be removed soon! 238 * Please use the new dixLookup*() functions above. 239 */ 240extern WindowPtr SecurityLookupWindow(XID, ClientPtr, Mask); 241extern WindowPtr LookupWindow(XID, ClientPtr); 242extern pointer SecurityLookupDrawable(XID, ClientPtr, Mask); 243extern pointer LookupDrawable(XID, ClientPtr); 244extern ClientPtr LookupClient(XID, ClientPtr); 245/* end deprecated functions */ 246 247extern void NoopDDA(void); 248 249extern int AlterSaveSetForClient( 250 ClientPtr /*client*/, 251 WindowPtr /*pWin*/, 252 unsigned /*mode*/, 253 Bool /*toRoot*/, 254 Bool /*remap*/); 255 256extern void DeleteWindowFromAnySaveSet( 257 WindowPtr /*pWin*/); 258 259extern void BlockHandler( 260 pointer /*pTimeout*/, 261 pointer /*pReadmask*/); 262 263extern void WakeupHandler( 264 int /*result*/, 265 pointer /*pReadmask*/); 266 267typedef void (* WakeupHandlerProcPtr)( 268 pointer /* blockData */, 269 int /* result */, 270 pointer /* pReadmask */); 271 272extern Bool RegisterBlockAndWakeupHandlers( 273 BlockHandlerProcPtr /*blockHandler*/, 274 WakeupHandlerProcPtr /*wakeupHandler*/, 275 pointer /*blockData*/); 276 277extern void RemoveBlockAndWakeupHandlers( 278 BlockHandlerProcPtr /*blockHandler*/, 279 WakeupHandlerProcPtr /*wakeupHandler*/, 280 pointer /*blockData*/); 281 282extern void InitBlockAndWakeupHandlers(void); 283 284extern void ProcessWorkQueue(void); 285 286extern void ProcessWorkQueueZombies(void); 287 288extern Bool QueueWorkProc( 289 Bool (* /*function*/)( 290 ClientPtr /*clientUnused*/, 291 pointer /*closure*/), 292 ClientPtr /*client*/, 293 pointer /*closure*/ 294); 295 296typedef Bool (* ClientSleepProcPtr)( 297 ClientPtr /*client*/, 298 pointer /*closure*/); 299 300extern Bool ClientSleep( 301 ClientPtr /*client*/, 302 ClientSleepProcPtr /* function */, 303 pointer /*closure*/); 304 305#ifndef ___CLIENTSIGNAL_DEFINED___ 306#define ___CLIENTSIGNAL_DEFINED___ 307extern Bool ClientSignal( 308 ClientPtr /*client*/); 309#endif /* ___CLIENTSIGNAL_DEFINED___ */ 310 311extern void ClientWakeup( 312 ClientPtr /*client*/); 313 314extern Bool ClientIsAsleep( 315 ClientPtr /*client*/); 316 317/* atom.c */ 318 319extern Atom MakeAtom( 320 char * /*string*/, 321 unsigned /*len*/, 322 Bool /*makeit*/); 323 324extern Bool ValidAtom( 325 Atom /*atom*/); 326 327extern char *NameForAtom( 328 Atom /*atom*/); 329 330extern void AtomError(void); 331 332extern void FreeAllAtoms(void); 333 334extern void InitAtoms(void); 335 336/* main.c */ 337 338extern void SetVendorRelease(int release); 339 340extern void SetVendorString(char *string); 341 342/* events.c */ 343 344extern void SetMaskForEvent( 345 Mask /* mask */, 346 int /* event */); 347 348 349extern Bool IsParent( 350 WindowPtr /* maybeparent */, 351 WindowPtr /* child */); 352 353extern WindowPtr GetCurrentRootWindow(void); 354 355extern WindowPtr GetSpriteWindow(void); 356 357 358extern void NoticeEventTime(xEventPtr /* xE */); 359 360extern void EnqueueEvent( 361 xEventPtr /* xE */, 362 DeviceIntPtr /* device */, 363 int /* count */); 364 365extern void ComputeFreezes(void); 366 367extern void CheckGrabForSyncs( 368 DeviceIntPtr /* dev */, 369 Bool /* thisMode */, 370 Bool /* otherMode */); 371 372extern void ActivatePointerGrab( 373 DeviceIntPtr /* mouse */, 374 GrabPtr /* grab */, 375 TimeStamp /* time */, 376 Bool /* autoGrab */); 377 378extern void DeactivatePointerGrab( 379 DeviceIntPtr /* mouse */); 380 381extern void ActivateKeyboardGrab( 382 DeviceIntPtr /* keybd */, 383 GrabPtr /* grab */, 384 TimeStamp /* time */, 385 Bool /* passive */); 386 387extern void DeactivateKeyboardGrab( 388 DeviceIntPtr /* keybd */); 389 390extern void AllowSome( 391 ClientPtr /* client */, 392 TimeStamp /* time */, 393 DeviceIntPtr /* thisDev */, 394 int /* newState */); 395 396extern void ReleaseActiveGrabs( 397 ClientPtr client); 398 399extern int DeliverEventsToWindow( 400 WindowPtr /* pWin */, 401 xEventPtr /* pEvents */, 402 int /* count */, 403 Mask /* filter */, 404 GrabPtr /* grab */, 405 int /* mskidx */); 406 407extern int DeliverDeviceEvents( 408 WindowPtr /* pWin */, 409 xEventPtr /* xE */, 410 GrabPtr /* grab */, 411 WindowPtr /* stopAt */, 412 DeviceIntPtr /* dev */, 413 int /* count */); 414 415extern void DefineInitialRootWindow( 416 WindowPtr /* win */); 417 418extern void WindowHasNewCursor( 419 WindowPtr /* pWin */); 420 421extern Bool CheckDeviceGrabs( 422 DeviceIntPtr /* device */, 423 xEventPtr /* xE */, 424 int /* checkFirst */, 425 int /* count */); 426 427extern void DeliverFocusedEvent( 428 DeviceIntPtr /* keybd */, 429 xEventPtr /* xE */, 430 WindowPtr /* window */, 431 int /* count */); 432 433extern void DeliverGrabbedEvent( 434 xEventPtr /* xE */, 435 DeviceIntPtr /* thisDev */, 436 Bool /* deactivateGrab */, 437 int /* count */); 438 439#ifdef XKB 440extern void FixKeyState( 441 xEvent * /* xE */, 442 DeviceIntPtr /* keybd */); 443#endif /* XKB */ 444 445extern void RecalculateDeliverableEvents( 446 WindowPtr /* pWin */); 447 448extern int OtherClientGone( 449 pointer /* value */, 450 XID /* id */); 451 452extern void DoFocusEvents( 453 DeviceIntPtr /* dev */, 454 WindowPtr /* fromWin */, 455 WindowPtr /* toWin */, 456 int /* mode */); 457 458extern int SetInputFocus( 459 ClientPtr /* client */, 460 DeviceIntPtr /* dev */, 461 Window /* focusID */, 462 CARD8 /* revertTo */, 463 Time /* ctime */, 464 Bool /* followOK */); 465 466extern 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 */); 476 477extern void InitEvents(void); 478 479extern void CloseDownEvents(void); 480 481extern void DeleteWindowFromAnyEvents( 482 WindowPtr /* pWin */, 483 Bool /* freeResources */); 484 485 486extern Mask EventMaskForClient( 487 WindowPtr /* pWin */, 488 ClientPtr /* client */); 489 490 491 492extern int DeliverEvents( 493 WindowPtr /*pWin*/, 494 xEventPtr /*xE*/, 495 int /*count*/, 496 WindowPtr /*otherParent*/); 497 498 499extern void WriteEventsToClient( 500 ClientPtr /*pClient*/, 501 int /*count*/, 502 xEventPtr /*events*/); 503 504extern int TryClientEvents( 505 ClientPtr /*client*/, 506 xEventPtr /*pEvents*/, 507 int /*count*/, 508 Mask /*mask*/, 509 Mask /*filter*/, 510 GrabPtr /*grab*/); 511 512extern void WindowsRestructured(void); 513 514#ifdef PANORAMIX 515extern void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff); 516#endif 517 518#ifdef RANDR 519void 520ScreenRestructured (ScreenPtr pScreen); 521#endif 522 523extern void ResetClientPrivates(void); 524 525extern int AllocateClientPrivateIndex(void); 526 527extern Bool AllocateClientPrivate( 528 int /*index*/, 529 unsigned /*amount*/); 530 531extern int ffs(int i); 532 533/* 534 * callback manager stuff 535 */ 536 537#ifndef _XTYPEDEF_CALLBACKLISTPTR 538typedef struct _CallbackList *CallbackListPtr; /* also in misc.h */ 539#define _XTYPEDEF_CALLBACKLISTPTR 540#endif 541 542typedef void (*CallbackProcPtr) ( 543 CallbackListPtr *, pointer, pointer); 544 545typedef Bool (*AddCallbackProcPtr) ( 546 CallbackListPtr *, CallbackProcPtr, pointer); 547 548typedef Bool (*DeleteCallbackProcPtr) ( 549 CallbackListPtr *, CallbackProcPtr, pointer); 550 551typedef void (*CallCallbacksProcPtr) ( 552 CallbackListPtr *, pointer); 553 554typedef void (*DeleteCallbackListProcPtr) ( 555 CallbackListPtr *); 556 557typedef struct _CallbackProcs { 558 AddCallbackProcPtr AddCallback; 559 DeleteCallbackProcPtr DeleteCallback; 560 CallCallbacksProcPtr CallCallbacks; 561 DeleteCallbackListProcPtr DeleteCallbackList; 562} CallbackFuncsRec, *CallbackFuncsPtr; 563 564extern Bool AddCallback( 565 CallbackListPtr * /*pcbl*/, 566 CallbackProcPtr /*callback*/, 567 pointer /*data*/); 568 569extern Bool DeleteCallback( 570 CallbackListPtr * /*pcbl*/, 571 CallbackProcPtr /*callback*/, 572 pointer /*data*/); 573 574extern void CallCallbacks( 575 CallbackListPtr * /*pcbl*/, 576 pointer /*call_data*/); 577 578extern void DeleteCallbackList( 579 CallbackListPtr * /*pcbl*/); 580 581extern void InitCallbackManager(void); 582 583/* 584 * ServerGrabCallback stuff 585 */ 586 587extern CallbackListPtr ServerGrabCallback; 588 589typedef enum {SERVER_GRABBED, SERVER_UNGRABBED, 590 CLIENT_PERVIOUS, CLIENT_IMPERVIOUS } ServerGrabState; 591 592typedef struct { 593 ClientPtr client; 594 ServerGrabState grabstate; 595} ServerGrabInfoRec; 596 597/* 598 * EventCallback stuff 599 */ 600 601extern CallbackListPtr EventCallback; 602 603typedef struct { 604 ClientPtr client; 605 xEventPtr events; 606 int count; 607} EventInfoRec; 608 609/* 610 * DeviceEventCallback stuff 611 */ 612 613extern CallbackListPtr DeviceEventCallback; 614 615typedef struct { 616 xEventPtr events; 617 int count; 618} DeviceEventInfoRec; 619 620/* 621 * SelectionCallback stuff 622 */ 623 624extern CallbackListPtr SelectionCallback; 625 626typedef enum { 627 SelectionSetOwner, 628 SelectionWindowDestroy, 629 SelectionClientClose 630} SelectionCallbackKind; 631 632typedef struct { 633 struct _Selection *selection; 634 SelectionCallbackKind kind; 635} SelectionInfoRec; 636 637/* strcasecmp.c */ 638#if NEED_STRCASECMP 639#define strcasecmp xstrcasecmp 640extern int xstrcasecmp(char *s1, char *s2); 641#endif 642 643#endif /* DIX_H */ 644