winglobals.c revision 4642e01f
1/*
2 *Copyright (C) 2003-2004 Harold L Hunt II 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 HAROLD L HUNT II 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 Harold L Hunt II
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 Harold L Hunt II.
27 *
28 * Authors:	Harold L Hunt II
29 */
30
31#ifdef HAVE_XWIN_CONFIG_H
32#include <xwin-config.h>
33#endif
34#include "win.h"
35
36
37/*
38 * General global variables
39 */
40
41int		g_iNumScreens = 0;
42winScreenInfo	g_ScreenInfo[MAXSCREENS];
43int		g_iLastScreen = -1;
44#ifdef HAS_DEVWINDOWS
45int		g_fdMessageQueue = WIN_FD_INVALID;
46#endif
47static int	g_iScreenPrivateKeyIndex;
48DevPrivateKey	g_iScreenPrivateKey = &g_iScreenPrivateKeyIndex;
49static int	g_iCmapPrivateKeyIndex;
50DevPrivateKey	g_iCmapPrivateKey = &g_iCmapPrivateKeyIndex;
51static int	g_iGCPrivateKeyIndex;
52DevPrivateKey	g_iGCPrivateKey = &g_iGCPrivateKeyIndex;
53static int	g_iPixmapPrivateKeyIndex;
54DevPrivateKey	g_iPixmapPrivateKey = &g_iPixmapPrivateKeyIndex;
55static int	g_iWindowPrivateKeyIndex;
56DevPrivateKey	g_iWindowPrivateKey = &g_iWindowPrivateKeyIndex;
57unsigned long	g_ulServerGeneration = 0;
58Bool		g_fInitializedDefaultScreens = FALSE;
59DWORD		g_dwEnginesSupported = 0;
60HINSTANCE	g_hInstance = 0;
61HWND		g_hDlgDepthChange = NULL;
62HWND		g_hDlgExit = NULL;
63HWND		g_hDlgAbout = NULL;
64const char *	g_pszQueryHost = NULL;
65Bool		g_fXdmcpEnabled = FALSE;
66HICON		g_hIconX = NULL;
67HICON		g_hSmallIconX = NULL;
68#ifndef RELOCATE_PROJECTROOT
69char *		g_pszLogFile = "/tmp/XWin.log";
70#else
71char *		g_pszLogFile = "XWin.log";
72Bool		g_fLogFileChanged = FALSE;
73#endif
74int		g_iLogVerbose = 2;
75Bool		g_fLogInited = FALSE;
76char *		g_pszCommandLine = NULL;
77Bool		g_fSilentFatalError = FALSE;
78DWORD		g_dwCurrentThreadID = 0;
79Bool		g_fKeyboardHookLL = FALSE;
80HHOOK		g_hhookKeyboardLL = NULL;
81HWND		g_hwndKeyboardFocus = NULL;
82Bool		g_fNoHelpMessageBox = FALSE;
83Bool		g_fSoftwareCursor = FALSE;
84Bool		g_fSilentDupError = FALSE;
85
86
87/*
88 * Global variables for dynamically loaded libraries and
89 * their function pointers
90 */
91
92HMODULE		g_hmodDirectDraw = NULL;
93FARPROC		g_fpDirectDrawCreate = NULL;
94FARPROC		g_fpDirectDrawCreateClipper = NULL;
95
96HMODULE		g_hmodCommonControls = NULL;
97FARPROC		g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
98
99
100#ifdef XWIN_CLIPBOARD
101/*
102 * Wrapped DIX functions
103 */
104winDispatchProcPtr	winProcEstablishConnectionOrig = NULL;
105winDispatchProcPtr	winProcQueryTreeOrig = NULL;
106winDispatchProcPtr	winProcSetSelectionOwnerOrig = NULL;
107
108
109/*
110 * Clipboard variables
111 */
112
113Bool			g_fUnicodeClipboard = TRUE;
114Bool			g_fClipboard = FALSE;
115Bool			g_fClipboardLaunched = FALSE;
116Bool			g_fClipboardStarted = FALSE;
117pthread_t		g_ptClipboardProc;
118HWND			g_hwndClipboard = NULL;
119void			*g_pClipboardDisplay = NULL;
120Window			g_iClipboardWindow = None;
121Atom			g_atomLastOwnedSelection = None;
122#endif
123
124
125/*
126 * Re-initialize global variables that are invalidated
127 * by a server reset.
128 */
129
130void
131winInitializeGlobals (void)
132{
133  g_dwCurrentThreadID = GetCurrentThreadId ();
134  g_hwndKeyboardFocus = NULL;
135#ifdef XWIN_CLIPBOARD
136  g_fClipboardLaunched = FALSE;
137  g_fClipboardStarted = FALSE;
138  g_iClipboardWindow = None;
139  g_pClipboardDisplay = NULL;
140  g_atomLastOwnedSelection = None;
141  g_hwndClipboard = NULL;
142#endif
143}
144