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