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