win.h revision 6747b715
1/* 2 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 3 * 4 *Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 *"Software"), to deal in the Software without restriction, including 7 *without limitation the rights to use, copy, modify, merge, publish, 8 *distribute, sublicense, and/or sell copies of the Software, and to 9 *permit persons to whom the Software is furnished to do so, subject to 10 *the following conditions: 11 * 12 *The above copyright notice and this permission notice shall be 13 *included in all copies or substantial portions of the Software. 14 * 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR 19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 *Except as contained in this notice, the name of the XFree86 Project 24 *shall not be used in advertising or otherwise to promote the sale, use 25 *or other dealings in this Software without prior written authorization 26 *from the XFree86 Project. 27 * 28 * Authors: Dakshinamurthy Karra 29 * Suhaib M Siddiqi 30 * Peter Busch 31 * Harold L Hunt II 32 * Kensuke Matsuzaki 33 */ 34 35#ifndef _WIN_H_ 36#define _WIN_H_ 37 38#ifndef NO 39#define NO 0 40#endif 41#ifndef YES 42#define YES 1 43#endif 44 45/* Turn debug messages on or off */ 46#ifndef CYGDEBUG 47#define CYGDEBUG NO 48#endif 49 50/* WM_XBUTTON Messages. They should go into w32api. */ 51#ifndef WM_XBUTTONDOWN 52# define WM_XBUTTONDOWN 523 53#endif 54#ifndef WM_XBUTTONUP 55# define WM_XBUTTONUP 524 56#endif 57#ifndef WM_XBUTTONDBLCLK 58# define WM_XBUTTONDBLCLK 525 59#endif 60 61 62#define WIN_DEFAULT_BPP 0 63#define WIN_DEFAULT_WHITEPIXEL 255 64#define WIN_DEFAULT_BLACKPIXEL 0 65#define WIN_DEFAULT_LINEBIAS 0 66#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */ 67#define WIN_DEFAULT_DPI 75 68#define WIN_DEFAULT_REFRESH 0 69#define WIN_DEFAULT_WIN_KILL TRUE 70#define WIN_DEFAULT_UNIX_KILL FALSE 71#define WIN_DEFAULT_CLIP_UPDATES_NBOXES 0 72#ifdef XWIN_EMULATEPSEUDO 73#define WIN_DEFAULT_EMULATE_PSEUDO FALSE 74#endif 75#define WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH FALSE 76 77#define WIN_DIB_MAXIMUM_SIZE 0x08000000 /* 16 MB on Windows 95, 98, Me */ 78#define WIN_DIB_MAXIMUM_SIZE_MB (WIN_DIB_MAXIMUM_SIZE / 8 / 1024 / 1024) 79 80/* 81 * Windows only supports 256 color palettes 82 */ 83#define WIN_NUM_PALETTE_ENTRIES 256 84 85/* 86 * Number of times to call Restore in an attempt to restore the primary surface 87 */ 88#define WIN_REGAIN_SURFACE_RETRIES 1 89 90/* 91 * Build a supported display depths mask by shifting one to the left 92 * by the number of bits in the supported depth. 93 */ 94#define WIN_SUPPORTED_BPPS ( (1 << (32 - 1)) | (1 << (24 - 1)) \ 95 | (1 << (16 - 1)) | (1 << (15 - 1)) \ 96 | (1 << ( 8 - 1))) 97#define WIN_CHECK_DEPTH YES 98 99/* 100 * Timer IDs for WM_TIMER 101 */ 102#define WIN_E3B_TIMER_ID 1 103#define WIN_POLLING_MOUSE_TIMER_ID 2 104 105#define MOUSE_POLLING_INTERVAL 50 106 107#define WIN_E3B_OFF -1 108#define WIN_FD_INVALID -1 109 110#define WIN_SERVER_NONE 0x0L /* 0 */ 111#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */ 112#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */ 113#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */ 114#ifdef XWIN_PRIMARYFB 115#define WIN_SERVER_PRIMARY_DD 0x8L /* 8 */ 116#endif 117#ifdef XWIN_NATIVEGDI 118# define WIN_SERVER_NATIVE_GDI 0x10L /* 16 */ 119#endif 120 121#define AltMapIndex Mod1MapIndex 122#define NumLockMapIndex Mod2MapIndex 123#define AltLangMapIndex Mod3MapIndex 124#define KanaMapIndex Mod4MapIndex 125#define ScrollLockMapIndex Mod5MapIndex 126 127#define WIN_MOD_LALT 0x00000001 128#define WIN_MOD_RALT 0x00000002 129#define WIN_MOD_LCONTROL 0x00000004 130#define WIN_MOD_RCONTROL 0x00000008 131 132#define WIN_24BPP_MASK_RED 0x00FF0000 133#define WIN_24BPP_MASK_GREEN 0x0000FF00 134#define WIN_24BPP_MASK_BLUE 0x000000FF 135 136#define WIN_MAX_KEYS_PER_KEY 4 137 138#include <sys/types.h> 139#include <sys/stat.h> 140#include <stdio.h> 141 142#include <errno.h> 143#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 144#define HANDLE void * 145#include <pthread.h> 146#undef HANDLE 147#endif 148 149#ifdef HAS_MMAP 150#include <sys/mman.h> 151#ifndef MAP_FILE 152#define MAP_FILE 0 153#endif /* MAP_FILE */ 154#endif /* HAS_MMAP */ 155 156#include <X11/X.h> 157#include <X11/Xproto.h> 158#include <X11/Xos.h> 159#include <X11/Xprotostr.h> 160#include "scrnintstr.h" 161#include "pixmapstr.h" 162#include "pixmap.h" 163#include "region.h" 164#include "gcstruct.h" 165#include "colormap.h" 166#include "colormapst.h" 167#include "miscstruct.h" 168#include "servermd.h" 169#include "windowstr.h" 170#include "mi.h" 171#include "micmap.h" 172#include "mifillarc.h" 173#include "mifpoly.h" 174#include "mibstore.h" 175#include "input.h" 176#include "mipointer.h" 177#include "X11/keysym.h" 178#include "mibstore.h" 179#include "micoord.h" 180#include "dix.h" 181#include "miline.h" 182#include "shadow.h" 183#include "fb.h" 184#include "rootless.h" 185 186#include "mipict.h" 187#include "picturestr.h" 188 189#ifdef RANDR 190#include "randrstr.h" 191#endif 192 193/* 194 * Windows headers 195 */ 196#include "winms.h" 197#include "winresource.h" 198 199 200/* 201 * Define Windows constants 202 */ 203 204#define WM_TRAYICON (WM_USER + 1000) 205#define WM_INIT_SYS_MENU (WM_USER + 1001) 206#define WM_GIVEUP (WM_USER + 1002) 207 208 209/* Local includes */ 210#include "winwindow.h" 211#include "winmsg.h" 212 213 214/* 215 * Debugging macros 216 */ 217 218#if CYGDEBUG 219#define DEBUG_MSG(str,...) \ 220if (fDebugProcMsg) \ 221{ \ 222 char *pszTemp; \ 223 int iLength; \ 224 pszTemp = Xprintf (str, ##__VA_ARGS__); \ 225 MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \ 226 free(pszTemp); \ 227} 228#else 229#define DEBUG_MSG(str,...) 230#endif 231 232#if CYGDEBUG 233#define DEBUG_FN_NAME(str) PTSTR szFunctionName = str 234#else 235#define DEBUG_FN_NAME(str) 236#endif 237 238#if CYGDEBUG || YES 239#define DEBUGVARS BOOL fDebugProcMsg = FALSE 240#else 241#define DEBUGVARS 242#endif 243 244#if CYGDEBUG || YES 245#define DEBUGPROC_MSG fDebugProcMsg = TRUE 246#else 247#define DEBUGPROC_MSG 248#endif 249 250#define PROFILEPOINT(point,thresh)\ 251{\ 252static unsigned int PROFPT##point = 0;\ 253if (++PROFPT##point % thresh == 0)\ 254ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\ 255} 256 257 258/* We use xor this macro for detecting toggle key state changes */ 259#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b))) 260 261#define DEFINE_ATOM_HELPER(func,atom_name) \ 262static Atom func (void) { \ 263 static int generation; \ 264 static Atom atom; \ 265 if (generation != serverGeneration) { \ 266 generation = serverGeneration; \ 267 atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \ 268 } \ 269 return atom; \ 270} 271 272/* 273 * Typedefs for engine dependent function pointers 274 */ 275 276typedef Bool (*winAllocateFBProcPtr)(ScreenPtr); 277 278typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr); 279 280typedef Bool (*winCloseScreenProcPtr)(int, ScreenPtr); 281 282typedef Bool (*winInitVisualsProcPtr)(ScreenPtr); 283 284typedef Bool (*winAdjustVideoModeProcPtr)(ScreenPtr); 285 286typedef Bool (*winCreateBoundingWindowProcPtr)(ScreenPtr); 287 288typedef Bool (*winFinishScreenInitProcPtr)(int, ScreenPtr, int, char **); 289 290typedef Bool (*winBltExposedRegionsProcPtr)(ScreenPtr); 291 292typedef Bool (*winActivateAppProcPtr)(ScreenPtr); 293 294typedef Bool (*winRedrawScreenProcPtr)(ScreenPtr pScreen); 295 296typedef Bool (*winRealizeInstalledPaletteProcPtr)(ScreenPtr pScreen); 297 298typedef Bool (*winInstallColormapProcPtr)(ColormapPtr pColormap); 299 300typedef Bool (*winStoreColorsProcPtr)(ColormapPtr pmap, 301 int ndef, xColorItem *pdefs); 302 303typedef Bool (*winCreateColormapProcPtr)(ColormapPtr pColormap); 304 305typedef Bool (*winDestroyColormapProcPtr)(ColormapPtr pColormap); 306 307typedef Bool (*winHotKeyAltTabProcPtr)(ScreenPtr); 308 309typedef Bool (*winCreatePrimarySurfaceProcPtr)(ScreenPtr); 310 311typedef Bool (*winReleasePrimarySurfaceProcPtr)(ScreenPtr); 312 313typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin); 314 315typedef Bool (*winCreateScreenResourcesProc)(ScreenPtr); 316 317/* Typedef for DIX wrapper functions */ 318typedef int (*winDispatchProcPtr) (ClientPtr); 319 320 321/* 322 * GC (graphics context) privates 323 */ 324 325typedef struct 326{ 327 HDC hdc; 328 HDC hdcMem; 329} winPrivGCRec, *winPrivGCPtr; 330 331 332/* 333 * Pixmap privates 334 */ 335 336typedef struct 337{ 338 HDC hdcSelected; 339 HBITMAP hBitmap; 340 BYTE *pbBits; 341 DWORD dwScanlineBytes; 342 BITMAPINFOHEADER *pbmih; 343} winPrivPixmapRec, *winPrivPixmapPtr; 344 345 346/* 347 * Colormap privates 348 */ 349 350typedef struct 351{ 352 HPALETTE hPalette; 353 LPDIRECTDRAWPALETTE lpDDPalette; 354 RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES]; 355 PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES]; 356} winPrivCmapRec, *winPrivCmapPtr; 357 358/* 359 * Windows Cursor handling. 360 */ 361 362typedef struct { 363 /* from GetSystemMetrics */ 364 int sm_cx; 365 int sm_cy; 366 367 BOOL visible; 368 HCURSOR handle; 369 QueryBestSizeProcPtr QueryBestSize; 370 miPointerSpriteFuncPtr spriteFuncs; 371} winCursorRec; 372 373/* 374 * Screen information structure that we need before privates are available 375 * in the server startup sequence. 376 */ 377 378typedef struct 379{ 380 ScreenPtr pScreen; 381 382 /* Did the user specify a height and width? */ 383 Bool fUserGaveHeightAndWidth; 384 385 DWORD dwScreen; 386 DWORD dwUserWidth; 387 DWORD dwUserHeight; 388 DWORD dwWidth; 389 DWORD dwHeight; 390 DWORD dwWidth_mm; 391 DWORD dwHeight_mm; 392 DWORD dwPaddedWidth; 393 394 /* Did the user specify a screen position? */ 395 Bool fUserGavePosition; 396 DWORD dwInitialX; 397 DWORD dwInitialY; 398 399 /* 400 * dwStride is the number of whole pixels that occupy a scanline, 401 * including those pixels that are not displayed. This is basically 402 * a rounding up of the width. 403 */ 404 DWORD dwStride; 405 406 /* Offset of the screen in the window when using scrollbars */ 407 DWORD dwXOffset; 408 DWORD dwYOffset; 409 410 DWORD dwBPP; 411 DWORD dwDepth; 412 DWORD dwRefreshRate; 413 char *pfb; 414 DWORD dwEngine; 415 DWORD dwEnginePreferred; 416 DWORD dwClipUpdatesNBoxes; 417#ifdef XWIN_EMULATEPSEUDO 418 Bool fEmulatePseudo; 419#endif 420 Bool fFullScreen; 421 Bool fDecoration; 422#ifdef XWIN_MULTIWINDOWEXTWM 423 Bool fMWExtWM; 424 Bool fInternalWM; 425 Bool fAnotherWMRunning; 426#endif 427 Bool fRootless; 428#ifdef XWIN_MULTIWINDOW 429 Bool fMultiWindow; 430#endif 431#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 432 Bool fMultiMonitorOverride; 433#endif 434 Bool fMultipleMonitors; 435 Bool fLessPointer; 436 Bool fScrollbars; 437 Bool fNoTrayIcon; 438 int iE3BTimeout; 439 /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */ 440 Bool fUseWinKillKey; 441 Bool fUseUnixKillKey; 442 Bool fIgnoreInput; 443 444 /* Did the user explicitly set this screen? */ 445 Bool fExplicitScreen; 446} winScreenInfo, *winScreenInfoPtr; 447 448 449/* 450 * Screen privates 451 */ 452 453typedef struct _winPrivScreenRec 454{ 455 winScreenInfoPtr pScreenInfo; 456 457 Bool fEnabled; 458 Bool fClosed; 459 Bool fActive; 460 Bool fBadDepth; 461 462 int iDeltaZ; 463 464 int iConnectedClients; 465 466 CloseScreenProcPtr CloseScreen; 467 468 DWORD dwRedMask; 469 DWORD dwGreenMask; 470 DWORD dwBlueMask; 471 DWORD dwBitsPerRGB; 472 473 DWORD dwModeKeyStates; 474 475 /* Handle to icons that must be freed */ 476 HICON hiconNotifyIcon; 477 478 /* Last width, height, and depth of the Windows display */ 479 DWORD dwLastWindowsWidth; 480 DWORD dwLastWindowsHeight; 481 DWORD dwLastWindowsBitsPixel; 482 483 /* Palette management */ 484 ColormapPtr pcmapInstalled; 485 486 /* Pointer to the root visual so we only have to look it up once */ 487 VisualPtr pRootVisual; 488 489 /* 3 button emulation variables */ 490 int iE3BCachedPress; 491 Bool fE3BFakeButton2Sent; 492 493 /* Privates used by shadow fb GDI server */ 494 HBITMAP hbmpShadow; 495 HDC hdcScreen; 496 HDC hdcShadow; 497 HWND hwndScreen; 498 499 /* Privates used by shadow fb and primary fb DirectDraw servers */ 500 LPDIRECTDRAW pdd; 501 LPDIRECTDRAWSURFACE2 pddsPrimary; 502 LPDIRECTDRAW2 pdd2; 503 504 /* Privates used by shadow fb DirectDraw server */ 505 LPDIRECTDRAWSURFACE2 pddsShadow; 506 LPDDSURFACEDESC pddsdShadow; 507 508 /* Privates used by primary fb DirectDraw server */ 509 LPDIRECTDRAWSURFACE2 pddsOffscreen; 510 LPDDSURFACEDESC pddsdOffscreen; 511 LPDDSURFACEDESC pddsdPrimary; 512 513 /* Privates used by shadow fb DirectDraw Nonlocking server */ 514 LPDIRECTDRAW4 pdd4; 515 LPDIRECTDRAWSURFACE4 pddsShadow4; 516 LPDIRECTDRAWSURFACE4 pddsPrimary4; 517 BOOL fRetryCreateSurface; 518 519 /* Privates used by both shadow fb DirectDraw servers */ 520 LPDIRECTDRAWCLIPPER pddcPrimary; 521 522#ifdef XWIN_MULTIWINDOWEXTWM 523 /* Privates used by multi-window external window manager */ 524 RootlessFrameID widTop; 525 Bool fRestacking; 526#endif 527 528#ifdef XWIN_MULTIWINDOW 529 /* Privates used by multi-window */ 530 pthread_t ptWMProc; 531 pthread_t ptXMsgProc; 532 void *pWMInfo; 533#endif 534 535#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 536 /* Privates used by both multi-window and rootless */ 537 Bool fRootWindowShown; 538#endif 539 540#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 541 /* Privates used for any module running in a seperate thread */ 542 pthread_mutex_t pmServerStarted; 543 Bool fServerStarted; 544#endif 545 546 /* Engine specific functions */ 547 winAllocateFBProcPtr pwinAllocateFB; 548 winShadowUpdateProcPtr pwinShadowUpdate; 549 winCloseScreenProcPtr pwinCloseScreen; 550 winInitVisualsProcPtr pwinInitVisuals; 551 winAdjustVideoModeProcPtr pwinAdjustVideoMode; 552 winCreateBoundingWindowProcPtr pwinCreateBoundingWindow; 553 winFinishScreenInitProcPtr pwinFinishScreenInit; 554 winBltExposedRegionsProcPtr pwinBltExposedRegions; 555 winActivateAppProcPtr pwinActivateApp; 556 winRedrawScreenProcPtr pwinRedrawScreen; 557 winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette; 558 winInstallColormapProcPtr pwinInstallColormap; 559 winStoreColorsProcPtr pwinStoreColors; 560 winCreateColormapProcPtr pwinCreateColormap; 561 winDestroyColormapProcPtr pwinDestroyColormap; 562 winHotKeyAltTabProcPtr pwinHotKeyAltTab; 563 winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface; 564 winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface; 565 566 winCreateScreenResourcesProc pwinCreateScreenResources; 567 568#ifdef XWIN_MULTIWINDOW 569 /* Window Procedures for MultiWindow mode */ 570 winFinishCreateWindowsWindowProcPtr pwinFinishCreateWindowsWindow; 571#endif 572 573 /* Window Procedures for Rootless mode */ 574 CreateWindowProcPtr CreateWindow; 575 DestroyWindowProcPtr DestroyWindow; 576 PositionWindowProcPtr PositionWindow; 577 ChangeWindowAttributesProcPtr ChangeWindowAttributes; 578 RealizeWindowProcPtr RealizeWindow; 579 UnrealizeWindowProcPtr UnrealizeWindow; 580 ValidateTreeProcPtr ValidateTree; 581 PostValidateTreeProcPtr PostValidateTree; 582 WindowExposuresProcPtr WindowExposures; 583 CopyWindowProcPtr CopyWindow; 584 ClearToBackgroundProcPtr ClearToBackground; 585 ClipNotifyProcPtr ClipNotify; 586 RestackWindowProcPtr RestackWindow; 587 ReparentWindowProcPtr ReparentWindow; 588 ResizeWindowProcPtr ResizeWindow; 589 MoveWindowProcPtr MoveWindow; 590 SetShapeProcPtr SetShape; 591 592 winCursorRec cursor; 593} winPrivScreenRec; 594 595 596#ifdef XWIN_MULTIWINDOWEXTWM 597typedef struct { 598 RootlessWindowPtr pFrame; 599 HWND hWnd; 600 int dwWidthBytes; 601 BITMAPINFOHEADER *pbmihShadow; 602 HBITMAP hbmpShadow; 603 HDC hdcShadow; 604 HDC hdcScreen; 605 BOOL fResized; 606 BOOL fRestackingNow; 607 BOOL fClose; 608 BOOL fMovingOrSizing; 609 BOOL fDestroyed;//for debug 610 char *pfb; 611} win32RootlessWindowRec, *win32RootlessWindowPtr; 612#endif 613 614 615typedef struct { 616 pointer value; 617 XID id; 618} WindowIDPairRec, *WindowIDPairPtr; 619 620 621/* 622 * Extern declares for general global variables 623 */ 624 625extern winScreenInfo * g_ScreenInfo; 626extern miPointerScreenFuncRec g_winPointerCursorFuncs; 627extern DWORD g_dwEvents; 628#ifdef HAS_DEVWINDOWS 629extern int g_fdMessageQueue; 630#endif 631extern DevPrivateKeyRec g_iScreenPrivateKeyRec; 632#define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec) 633extern DevPrivateKeyRec g_iCmapPrivateKeyRec; 634#define g_iCmapPrivateKey (&g_iCmapPrivateKeyRec) 635extern DevPrivateKeyRec g_iGCPrivateKeyRec; 636#define g_iGCPrivateKey (&g_iGCPrivateKeyRec) 637extern DevPrivateKeyRec g_iPixmapPrivateKeyRec; 638#define g_iPixmapPrivateKey (&g_iPixmapPrivateKeyRec) 639extern DevPrivateKeyRec g_iWindowPrivateKeyRec; 640#define g_iWindowPrivateKey (&g_iWindowPrivateKeyRec) 641 642extern unsigned long g_ulServerGeneration; 643extern DWORD g_dwEnginesSupported; 644extern HINSTANCE g_hInstance; 645extern int g_copyROP[]; 646extern int g_patternROP[]; 647extern const char * g_pszQueryHost; 648extern DeviceIntPtr g_pwinPointer; 649extern DeviceIntPtr g_pwinKeyboard; 650 651 652/* 653 * Extern declares for dynamically loaded libraries and function pointers 654 */ 655 656extern HMODULE g_hmodDirectDraw; 657extern FARPROC g_fpDirectDrawCreate; 658extern FARPROC g_fpDirectDrawCreateClipper; 659 660extern HMODULE g_hmodCommonControls; 661extern FARPROC g_fpTrackMouseEvent; 662 663 664/* 665 * Screen privates macros 666 */ 667 668#define winGetScreenPriv(pScreen) ((winPrivScreenPtr) \ 669 dixLookupPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey)) 670 671#define winSetScreenPriv(pScreen,v) \ 672 dixSetPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey, v) 673 674#define winScreenPriv(pScreen) \ 675 winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen) 676 677 678/* 679 * Colormap privates macros 680 */ 681 682#define winGetCmapPriv(pCmap) ((winPrivCmapPtr) \ 683 dixLookupPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey)) 684 685#define winSetCmapPriv(pCmap,v) \ 686 dixSetPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey, v) 687 688#define winCmapPriv(pCmap) \ 689 winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap) 690 691 692/* 693 * GC privates macros 694 */ 695 696#define winGetGCPriv(pGC) ((winPrivGCPtr) \ 697 dixLookupPrivate(&(pGC)->devPrivates, g_iGCPrivateKey)) 698 699#define winSetGCPriv(pGC,v) \ 700 dixSetPrivate(&(pGC)->devPrivates, g_iGCPrivateKey, v) 701 702#define winGCPriv(pGC) \ 703 winPrivGCPtr pGCPriv = winGetGCPriv(pGC) 704 705 706/* 707 * Pixmap privates macros 708 */ 709 710#define winGetPixmapPriv(pPixmap) ((winPrivPixmapPtr) \ 711 dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey)) 712 713#define winSetPixmapPriv(pPixmap,v) \ 714 dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey, v) 715 716#define winPixmapPriv(pPixmap) \ 717 winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap) 718 719 720/* 721 * Window privates macros 722 */ 723 724#define winGetWindowPriv(pWin) ((winPrivWinPtr) \ 725 dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey)) 726 727#define winSetWindowPriv(pWin,v) \ 728 dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey, v) 729 730#define winWindowPriv(pWin) \ 731 winPrivWinPtr pWinPriv = winGetWindowPriv(pWin) 732 733/* 734 * wrapper macros 735 */ 736#define _WIN_WRAP(priv, real, mem, func) {\ 737 priv->mem = real->mem; \ 738 real->mem = func; \ 739} 740 741#define _WIN_UNWRAP(priv, real, mem) {\ 742 real->mem = priv->mem; \ 743} 744 745#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func) 746 747#define WIN_UNWRAP(mem) _WIN_UNWRAP(pScreenPriv, pScreen, mem) 748 749/* 750 * BEGIN DDX and DIX Function Prototypes 751 */ 752 753 754/* 755 * winallpriv.c 756 */ 757 758Bool 759winAllocatePrivates (ScreenPtr pScreen); 760 761Bool 762winInitCmapPrivates (ColormapPtr pCmap, int index); 763 764Bool 765winAllocateCmapPrivates (ColormapPtr pCmap); 766 767 768/* 769 * winauth.c 770 */ 771 772#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 773Bool 774winGenerateAuthorization (void); 775void winSetAuthorization(void); 776#endif 777 778 779/* 780 * winblock.c 781 */ 782 783void 784winBlockHandler (int nScreen, 785 pointer pBlockData, 786 pointer pTimeout, 787 pointer pReadMask); 788 789 790#ifdef XWIN_NATIVEGDI 791/* 792 * winclip.c 793 */ 794 795RegionPtr 796winPixmapToRegionNativeGDI (PixmapPtr pPix); 797#endif 798 799 800#ifdef XWIN_CLIPBOARD 801/* 802 * winclipboardinit.c 803 */ 804 805Bool 806winInitClipboard (void); 807 808void 809winFixClipboardChain (void); 810#endif 811 812 813/* 814 * wincmap.c 815 */ 816 817void 818winSetColormapFunctions (ScreenPtr pScreen); 819 820Bool 821winCreateDefColormap (ScreenPtr pScreen); 822 823 824/* 825 * wincreatewnd.c 826 */ 827 828Bool 829winCreateBoundingWindowFullScreen (ScreenPtr pScreen); 830 831Bool 832winCreateBoundingWindowWindowed (ScreenPtr pScreen); 833 834 835/* 836 * windialogs.c 837 */ 838 839void 840winDisplayExitDialog (winPrivScreenPtr pScreenPriv); 841 842void 843winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv); 844 845void 846winDisplayAboutDialog (winPrivScreenPtr pScreenPriv); 847 848 849/* 850 * winengine.c 851 */ 852 853void 854winDetectSupportedEngines (void); 855 856Bool 857winSetEngine (ScreenPtr pScreen); 858 859Bool 860winGetDDProcAddresses (void); 861 862 863/* 864 * winerror.c 865 */ 866 867#ifdef DDXOSVERRORF 868void 869OSVenderVErrorF (const char *pszFormat, va_list va_args); 870#endif 871 872void 873winMessageBoxF (const char *pszError, UINT uType, ...); 874 875 876#ifdef XWIN_NATIVEGDI 877/* 878 * winfillsp.c 879 */ 880 881void 882winFillSpansNativeGDI (DrawablePtr pDrawable, 883 GCPtr pGC, 884 int nSpans, 885 DDXPointPtr pPoints, 886 int *pWidths, 887 int fSorted); 888#endif 889 890 891#ifdef XWIN_NATIVEGDI 892/* 893 * winfont.c 894 */ 895 896Bool 897winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont); 898 899Bool 900winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont); 901#endif 902 903 904#ifdef XWIN_NATIVEGDI 905/* 906 * wingc.c 907 */ 908 909Bool 910winCreateGCNativeGDI (GCPtr pGC); 911#endif 912 913 914#ifdef XWIN_NATIVEGDI 915/* 916 * wingetsp.c 917 */ 918 919void 920winGetSpansNativeGDI (DrawablePtr pDrawable, 921 int wMax, 922 DDXPointPtr pPoints, 923 int *pWidths, 924 int nSpans, 925 char *pDst); 926#endif 927 928 929/* 930 * winglobals.c 931 */ 932 933void 934winInitializeGlobals (void); 935 936 937/* 938 * winkeybd.c 939 */ 940 941void 942winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode); 943 944int 945winKeybdProc (DeviceIntPtr pDeviceInt, int iState); 946 947void 948winInitializeModeKeyStates (void); 949 950void 951winRestoreModeKeyStates (void); 952 953Bool 954winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam); 955 956void 957winKeybdReleaseKeys (void); 958 959void 960winSendKeyEvent (DWORD dwKey, Bool fDown); 961 962BOOL 963winCheckKeyPressed(WPARAM wParam, LPARAM lParam); 964 965void 966winFixShiftKeys (int iScanCode); 967 968/* 969 * winkeyhook.c 970 */ 971 972Bool 973winInstallKeyboardHookLL (void); 974 975void 976winRemoveKeyboardHookLL (void); 977 978 979/* 980 * winmisc.c 981 */ 982 983#ifdef XWIN_NATIVEGDI 984void 985winQueryBestSizeNativeGDI (int class, unsigned short *pWidth, 986 unsigned short *pHeight, ScreenPtr pScreen); 987#endif 988 989CARD8 990winCountBits (DWORD dw); 991 992Bool 993winUpdateFBPointer (ScreenPtr pScreen, void *pbits); 994 995#ifdef XWIN_NATIVEGDI 996BOOL 997winPaintBackground (HWND hwnd, COLORREF colorref); 998#endif 999 1000 1001/* 1002 * winmouse.c 1003 */ 1004 1005int 1006winMouseProc (DeviceIntPtr pDeviceInt, int iState); 1007 1008int 1009winMouseWheel (ScreenPtr pScreen, int iDeltaZ); 1010 1011void 1012winMouseButtonsSendEvent (int iEventType, int iButton); 1013 1014int 1015winMouseButtonsHandle (ScreenPtr pScreen, 1016 int iEventType, int iButton, 1017 WPARAM wParam); 1018 1019void 1020winEnqueueMotion(int x, int y); 1021 1022#ifdef XWIN_NATIVEGDI 1023/* 1024 * winnativegdi.c 1025 */ 1026 1027HBITMAP 1028winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth, 1029 BYTE **ppbBits, BITMAPINFO **ppbmi); 1030 1031Bool 1032winSetEngineFunctionsNativeGDI (ScreenPtr pScreen); 1033#endif 1034 1035 1036#ifdef XWIN_PRIMARYFB 1037/* 1038 * winpfbddd.c 1039 */ 1040 1041Bool 1042winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen); 1043#endif 1044 1045 1046#ifdef XWIN_NATIVEGDI 1047/* 1048 * winpixmap.c 1049 */ 1050 1051PixmapPtr 1052winCreatePixmapNativeGDI (ScreenPtr pScreen, int width, int height, int depth, 1053 unsigned usage_hint); 1054 1055Bool 1056winDestroyPixmapNativeGDI (PixmapPtr pPixmap); 1057 1058Bool 1059winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap, 1060 int iWidth, int iHeight, 1061 int iDepth, 1062 int iBitsPerPixel, 1063 int devKind, 1064 pointer pPixData); 1065#endif 1066 1067#ifdef XWIN_NATIVEGDI 1068/* 1069 * winpolyline.c 1070 */ 1071 1072void 1073winPolyLineNativeGDI (DrawablePtr pDrawable, 1074 GCPtr pGC, 1075 int mode, 1076 int npt, 1077 DDXPointPtr ppt); 1078#endif 1079 1080 1081#ifdef XWIN_NATIVEGDI 1082/* 1083 * winpushpxl.c 1084 */ 1085 1086void 1087winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, 1088 int dx, int dy, int xOrg, int yOrg); 1089#endif 1090 1091 1092/* 1093 * winscrinit.c 1094 */ 1095 1096Bool 1097winScreenInit (int index, 1098 ScreenPtr pScreen, 1099 int argc, char **argv); 1100 1101Bool 1102winFinishScreenInitFB (int index, 1103 ScreenPtr pScreen, 1104 int argc, char **argv); 1105 1106#if defined(XWIN_NATIVEGDI) 1107Bool 1108winFinishScreenInitNativeGDI (int index, 1109 ScreenPtr pScreen, 1110 int argc, char **argv); 1111#endif 1112 1113 1114#ifdef XWIN_NATIVEGDI 1115/* 1116 * winsetsp.c 1117 */ 1118 1119void 1120winSetSpansNativeGDI (DrawablePtr pDrawable, 1121 GCPtr pGC, 1122 char *pSrc, 1123 DDXPointPtr pPoints, 1124 int *pWidth, 1125 int nSpans, 1126 int fSorted); 1127#endif 1128 1129 1130/* 1131 * winshaddd.c 1132 */ 1133 1134Bool 1135winSetEngineFunctionsShadowDD (ScreenPtr pScreen); 1136 1137 1138/* 1139 * winshadddnl.c 1140 */ 1141 1142Bool 1143winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen); 1144 1145 1146/* 1147 * winshadgdi.c 1148 */ 1149 1150Bool 1151winSetEngineFunctionsShadowGDI (ScreenPtr pScreen); 1152 1153 1154/* 1155 * winwakeup.c 1156 */ 1157 1158void 1159winWakeupHandler (int nScreen, 1160 pointer pWakeupData, 1161 unsigned long ulResult, 1162 pointer pReadmask); 1163 1164 1165/* 1166 * winwindow.c 1167 */ 1168 1169#ifdef XWIN_NATIVEGDI 1170Bool 1171winCreateWindowNativeGDI (WindowPtr pWin); 1172 1173Bool 1174winDestroyWindowNativeGDI (WindowPtr pWin); 1175 1176Bool 1177winPositionWindowNativeGDI (WindowPtr pWin, int x, int y); 1178 1179void 1180winCopyWindowNativeGDI (WindowPtr pWin, 1181 DDXPointRec ptOldOrg, 1182 RegionPtr prgnSrc); 1183 1184Bool 1185winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask); 1186 1187Bool 1188winUnmapWindowNativeGDI (WindowPtr pWindow); 1189 1190Bool 1191winMapWindowNativeGDI (WindowPtr pWindow); 1192#endif 1193 1194Bool 1195winCreateWindowRootless (WindowPtr pWindow); 1196 1197Bool 1198winDestroyWindowRootless (WindowPtr pWindow); 1199 1200Bool 1201winPositionWindowRootless (WindowPtr pWindow, int x, int y); 1202 1203Bool 1204winChangeWindowAttributesRootless (WindowPtr pWindow, unsigned long mask); 1205 1206Bool 1207winUnmapWindowRootless (WindowPtr pWindow); 1208 1209Bool 1210winMapWindowRootless (WindowPtr pWindow); 1211 1212void 1213winSetShapeRootless (WindowPtr pWindow, int kind); 1214 1215 1216/* 1217 * winmultiwindowicons.c - Used by both multi-window and Win32Rootless 1218 */ 1219 1220HICON 1221winXIconToHICON (WindowPtr pWin, int iconSize); 1222 1223void 1224winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon); 1225 1226#ifdef XWIN_MULTIWINDOW 1227/* 1228 * winmultiwindowshape.c 1229 */ 1230 1231void 1232winReshapeMultiWindow (WindowPtr pWin); 1233 1234void 1235winSetShapeMultiWindow (WindowPtr pWindow, int kind); 1236 1237void 1238winUpdateRgnMultiWindow (WindowPtr pWindow); 1239#endif 1240 1241 1242#ifdef XWIN_MULTIWINDOW 1243/* 1244 * winmultiwindowwindow.c 1245 */ 1246 1247Bool 1248winCreateWindowMultiWindow (WindowPtr pWindow); 1249 1250Bool 1251winDestroyWindowMultiWindow (WindowPtr pWindow); 1252 1253Bool 1254winPositionWindowMultiWindow (WindowPtr pWindow, int x, int y); 1255 1256Bool 1257winChangeWindowAttributesMultiWindow (WindowPtr pWindow, unsigned long mask); 1258 1259Bool 1260winUnmapWindowMultiWindow (WindowPtr pWindow); 1261 1262Bool 1263winMapWindowMultiWindow (WindowPtr pWindow); 1264 1265void 1266winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent); 1267 1268void 1269winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib); 1270 1271void 1272winReorderWindowsMultiWindow (void); 1273 1274void 1275winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w, 1276 unsigned int h, WindowPtr pSib); 1277void 1278winMoveWindowMultiWindow (WindowPtr pWin, int x, int y, 1279 WindowPtr pSib, VTKind kind); 1280 1281void 1282winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt, 1283 RegionPtr oldRegion); 1284 1285XID 1286winGetWindowID (WindowPtr pWin); 1287 1288int 1289winAdjustXWindow (WindowPtr pWin, HWND hwnd); 1290#endif 1291 1292 1293#ifdef XWIN_MULTIWINDOW 1294/* 1295 * winmultiwindowwndproc.c 1296 */ 1297 1298LRESULT CALLBACK 1299winTopLevelWindowProc (HWND hwnd, UINT message, 1300 WPARAM wParam, LPARAM lParam); 1301#endif 1302 1303 1304/* 1305 * wintrayicon.c 1306 */ 1307 1308void 1309winInitNotifyIcon (winPrivScreenPtr pScreenPriv); 1310 1311void 1312winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv); 1313 1314LRESULT 1315winHandleIconMessage (HWND hwnd, UINT message, 1316 WPARAM wParam, LPARAM lParam, 1317 winPrivScreenPtr pScreenPriv); 1318 1319 1320/* 1321 * winwndproc.c 1322 */ 1323 1324LRESULT CALLBACK 1325winWindowProc (HWND hWnd, UINT message, 1326 WPARAM wParam, LPARAM lParam); 1327 1328 1329#ifdef XWIN_MULTIWINDOWEXTWM 1330/* 1331 * winwin32rootless.c 1332 */ 1333 1334Bool 1335winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen, 1336 int newX, int newY, RegionPtr pShape); 1337 1338void 1339winMWExtWMDestroyFrame (RootlessFrameID wid); 1340 1341void 1342winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY); 1343 1344void 1345winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen, 1346 int newX, int newY, unsigned int newW, unsigned int newH, 1347 unsigned int gravity); 1348 1349void 1350winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid); 1351 1352void 1353winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape); 1354 1355void 1356winMWExtWMUnmapFrame (RootlessFrameID wid); 1357 1358void 1359winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow); 1360 1361void 1362winMWExtWMStopDrawing (RootlessFrameID wid, Bool flush); 1363 1364void 1365winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage); 1366 1367void 1368winMWExtWMDamageRects (RootlessFrameID wid, int count, const BoxRec *rects, 1369 int shift_x, int shift_y); 1370 1371void 1372winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin); 1373 1374void 1375winMWExtWMCopyBytes (unsigned int width, unsigned int height, 1376 const void *src, unsigned int srcRowBytes, 1377 void *dst, unsigned int dstRowBytes); 1378 1379void 1380winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value, 1381 void *dst, unsigned int dstRowBytes); 1382 1383int 1384winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function, 1385 void *src[2], unsigned int srcRowBytes[2], 1386 void *mask, unsigned int maskRowBytes, 1387 void *dst[2], unsigned int dstRowBytes[2]); 1388 1389void 1390winMWExtWMCopyWindow (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, 1391 int dx, int dy); 1392#endif 1393 1394 1395#ifdef XWIN_MULTIWINDOWEXTWM 1396/* 1397 * winwin32rootlesswindow.c 1398 */ 1399 1400void 1401winMWExtWMReorderWindows (ScreenPtr pScreen); 1402 1403void 1404winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y); 1405 1406void 1407winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h); 1408 1409void 1410winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h); 1411 1412void 1413winMWExtWMUpdateIcon (Window id); 1414 1415void 1416winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv, 1417 winScreenInfoPtr pScreenInfo); 1418 1419wBOOL CALLBACK 1420winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam); 1421 1422Bool 1423winIsInternalWMRunning (winScreenInfoPtr pScreenInfo); 1424 1425void 1426winMWExtWMRestackWindows (ScreenPtr pScreen); 1427#endif 1428 1429 1430#ifdef XWIN_MULTIWINDOWEXTWM 1431/* 1432 * winwin32rootlesswndproc.c 1433 */ 1434 1435LRESULT CALLBACK 1436winMWExtWMWindowProc (HWND hwnd, UINT message, 1437 WPARAM wParam, LPARAM lParam); 1438#endif 1439 1440 1441/* 1442 * winwindowswm.c 1443 */ 1444 1445void 1446winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg, 1447 Window window, int x, int y, int w, int h); 1448 1449void 1450winWindowsWMExtensionInit (void); 1451 1452/* 1453 * wincursor.c 1454 */ 1455 1456Bool 1457winInitCursor (ScreenPtr pScreen); 1458 1459/* 1460 * winprocarg.c 1461 */ 1462void 1463winInitializeScreens(int maxscreens); 1464 1465/* 1466 * END DDX and DIX Function Prototypes 1467 */ 1468 1469#endif /* _WIN_H_ */ 1470 1471