aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin')
-rw-r--r--xorg-server/hw/xwin/InitOutput.c66
-rw-r--r--xorg-server/hw/xwin/XWin.exe.manifest37
-rw-r--r--xorg-server/hw/xwin/win.h3
-rw-r--r--xorg-server/hw/xwin/winclipboardwndproc.c2
-rw-r--r--xorg-server/hw/xwin/winglobals.c253
-rw-r--r--xorg-server/hw/xwin/winmonitors.c4
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwndproc.c4
-rw-r--r--xorg-server/hw/xwin/winprocarg.c32
-rw-r--r--xorg-server/hw/xwin/winwin32rootlesswndproc.c2650
-rw-r--r--xorg-server/hw/xwin/winwindowswm.c4
-rw-r--r--xorg-server/hw/xwin/winwndproc.c4
11 files changed, 1507 insertions, 1552 deletions
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index 41e6a57c0..5941a2116 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -69,12 +69,6 @@ extern HWND g_hwndClipboard;
extern Bool g_fClipboard;
#endif
-
-/*
- module handle for dynamically loaded comctl32 library
-*/
-static HMODULE g_hmodCommonControls = NULL;
-
/*
* Function prototypes
*/
@@ -219,14 +213,6 @@ ddxGiveUp (enum ExitCode error)
* we are guaranteed to not need the DirectDraw functions.
*/
winReleaseDDProcAddresses();
-
- /* Unload our TrackMouseEvent function pointer */
- if (g_hmodCommonControls != NULL)
- {
- FreeLibrary (g_hmodCommonControls);
- g_hmodCommonControls = NULL;
- g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
- }
/* Free concatenated command line */
free(g_pszCommandLine);
@@ -604,34 +590,17 @@ winFixupPaths (void)
}
if (getenv("HOME") == NULL)
{
- HMODULE shfolder;
- SHGETFOLDERPATHPROC shgetfolderpath = NULL;
char buffer[MAX_PATH + 5];
strncpy(buffer, "HOME=", 5);
- /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
-
- shfolder = LoadLibrary("shfolder.dll");
- /* fallback to shell32.dll */
- if (shfolder == NULL)
- shfolder = LoadLibrary("shell32.dll");
-
- /* resolve SHGetFolderPath */
- if (shfolder != NULL)
- shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
-
/* query appdata directory */
- if (shgetfolderpath &&
- shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
- buffer + 5) == 0)
- {
+ if (SHGetFolderPathA(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, buffer + 5) == 0)
+ {
putenv(buffer);
} else
{
ErrorF ("Can not determine HOME directory\n");
- }
- if (shfolder != NULL)
- FreeLibrary(shfolder);
+ }
}
if (!g_fLogFileChanged) {
static char buffer[MAX_PATH];
@@ -846,10 +815,10 @@ winUseMsg (void)
"\theight and initial position for that screen. Additionally\n"
"\ta monitor number can be specified to start the server on,\n"
"\tat which point, all coordinates become relative to that\n"
- "\tmonitor (Not for Windows NT4 and 95). Examples:\n"
- "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
- "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
- "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
+ "\tmonitor. Examples:\n"
+ "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
+ "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
+ "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
ErrorF ("-silent-dup-error\n"
"\tIf another instance of " EXECUTABLE_NAME " with the same display number is running\n"
@@ -982,27 +951,6 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
/* Detect supported engines */
winDetectSupportedEngines ();
- /* Load common controls library */
- g_hmodCommonControls = LoadLibraryEx ("comctl32.dll", NULL, 0);
-
- /* Load TrackMouseEvent function pointer */
- g_fpTrackMouseEvent = GetProcAddress (g_hmodCommonControls,
- "_TrackMouseEvent");
- if (g_fpTrackMouseEvent == NULL)
- {
- ErrorF ("InitOutput - Could not get pointer to function\n"
- "\t_TrackMouseEvent in comctl32.dll. Try installing\n"
- "\tInternet Explorer 3.0 or greater if you have not\n"
- "\talready.\n");
-
- /* Free the library since we won't need it */
- FreeLibrary (g_hmodCommonControls);
- g_hmodCommonControls = NULL;
-
- /* Set function pointer to point to no operation function */
- g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
- }
-
/* Store the instance handle */
g_hInstance = GetModuleHandle (NULL);
diff --git a/xorg-server/hw/xwin/XWin.exe.manifest b/xorg-server/hw/xwin/XWin.exe.manifest
index 5668383a9..a0d4d7dae 100644
--- a/xorg-server/hw/xwin/XWin.exe.manifest
+++ b/xorg-server/hw/xwin/XWin.exe.manifest
@@ -1,16 +1,21 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <description>The XWin X Windows server for Cygwin.</description>
- <dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
- </dependency>
-</assembly>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <description>The XWin X Windows server for Cygwin.</description>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="X86"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>
+ <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+ <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+ <dpiAware>true</dpiAware>
+ </asmv3:windowsSettings>
+ </asmv3:application>
+</assembly>
diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h
index a71635d67..d05a024a0 100644
--- a/xorg-server/hw/xwin/win.h
+++ b/xorg-server/hw/xwin/win.h
@@ -59,7 +59,7 @@
#define WIN_DEFAULT_BLACKPIXEL 0
#define WIN_DEFAULT_LINEBIAS 0
#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
-#define WIN_DEFAULT_DPI 75
+#define WIN_DEFAULT_DPI 96
#define WIN_DEFAULT_REFRESH 0
#define WIN_DEFAULT_WIN_KILL TRUE
#define WIN_DEFAULT_UNIX_KILL FALSE
@@ -637,7 +637,6 @@ extern DeviceIntPtr g_pwinKeyboard;
extern FARPROC g_fpDirectDrawCreate;
extern FARPROC g_fpDirectDrawCreateClipper;
-extern FARPROC g_fpTrackMouseEvent;
/*
diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c
index 1dbee9b6f..e410dd6d9 100644
--- a/xorg-server/hw/xwin/winclipboardwndproc.c
+++ b/xorg-server/hw/xwin/winclipboardwndproc.c
@@ -58,8 +58,6 @@ extern void *g_pClipboardDisplay;
extern Window g_iClipboardWindow;
extern Atom g_atomLastOwnedSelection;
extern Bool g_fClipboardStarted;
-/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
-extern HWND g_hwndClipboard;
extern Bool g_fClipboardPrimary;
/*
diff --git a/xorg-server/hw/xwin/winglobals.c b/xorg-server/hw/xwin/winglobals.c
index 044cbb1cd..0bf658293 100644
--- a/xorg-server/hw/xwin/winglobals.c
+++ b/xorg-server/hw/xwin/winglobals.c
@@ -1,130 +1,123 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/*
- * General global variables
- */
-
-int g_iNumScreens = 0;
-winScreenInfo * g_ScreenInfo = 0;
-#ifdef HAS_DEVWINDOWS
-int g_fdMessageQueue = WIN_FD_INVALID;
-#endif
-DevPrivateKeyRec g_iScreenPrivateKeyRec;
-DevPrivateKeyRec g_iCmapPrivateKeyRec;
-DevPrivateKeyRec g_iGCPrivateKeyRec;
-DevPrivateKeyRec g_iPixmapPrivateKeyRec;
-DevPrivateKeyRec g_iWindowPrivateKeyRec;
-unsigned long g_ulServerGeneration = 0;
-DWORD g_dwEnginesSupported = 0;
-HINSTANCE g_hInstance = 0;
-HWND g_hDlgDepthChange = NULL;
-HWND g_hDlgExit = NULL;
-HWND g_hDlgAbout = NULL;
-const char * g_pszQueryHost = NULL;
-Bool g_fXdmcpEnabled = FALSE;
-Bool g_fAuthEnabled = FALSE;
-HICON g_hIconX = NULL;
-HICON g_hSmallIconX = NULL;
-#ifndef RELOCATE_PROJECTROOT
-const char * g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log";
-#else
-const char * g_pszLogFile = "XWin.log";
-Bool g_fLogFileChanged = FALSE;
-#endif
-int g_iLogVerbose = 2;
-Bool g_fLogInited = FALSE;
-char * g_pszCommandLine = NULL;
-Bool g_fSilentFatalError = FALSE;
-DWORD g_dwCurrentThreadID = 0;
-Bool g_fKeyboardHookLL = FALSE;
-Bool g_fNoHelpMessageBox = FALSE;
-Bool g_fSoftwareCursor = FALSE;
-Bool g_fSilentDupError = FALSE;
-Bool g_fNativeGl = FALSE;
-Bool g_fswrastwgl = FALSE;
-
-/*
- * Global variables for dynamically loaded libraries and
- * their function pointers
- */
-
-FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-
-
-#ifdef XWIN_CLIPBOARD
-/*
- * Wrapped DIX functions
- */
-winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
-winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
-
-
-/*
- * Clipboard variables
- */
-
-Bool g_fUnicodeClipboard = TRUE;
-Bool g_fClipboard = TRUE;
-Bool g_fClipboardPrimary = TRUE;
-Bool g_fClipboardLaunched = FALSE;
-Bool g_fClipboardStarted = FALSE;
-pthread_t g_ptClipboardProc;
-HWND g_hwndClipboard = NULL;
-void *g_pClipboardDisplay = NULL;
-Window g_iClipboardWindow = None;
-Atom g_atomLastOwnedSelection = None;
-#endif
-
-
-/*
- * Re-initialize global variables that are invalidated
- * by a server reset.
- */
-
-void
-winInitializeGlobals (void)
-{
- g_dwCurrentThreadID = GetCurrentThreadId ();
-#ifdef XWIN_CLIPBOARD
- g_iClipboardWindow = None;
- g_pClipboardDisplay = NULL;
- g_atomLastOwnedSelection = None;
- g_hwndClipboard = NULL;
-#endif
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * General global variables
+ */
+
+int g_iNumScreens = 0;
+winScreenInfo * g_ScreenInfo = 0;
+#ifdef HAS_DEVWINDOWS
+int g_fdMessageQueue = WIN_FD_INVALID;
+#endif
+DevPrivateKeyRec g_iScreenPrivateKeyRec;
+DevPrivateKeyRec g_iCmapPrivateKeyRec;
+DevPrivateKeyRec g_iGCPrivateKeyRec;
+DevPrivateKeyRec g_iPixmapPrivateKeyRec;
+DevPrivateKeyRec g_iWindowPrivateKeyRec;
+unsigned long g_ulServerGeneration = 0;
+DWORD g_dwEnginesSupported = 0;
+HINSTANCE g_hInstance = 0;
+HWND g_hDlgDepthChange = NULL;
+HWND g_hDlgExit = NULL;
+HWND g_hDlgAbout = NULL;
+const char * g_pszQueryHost = NULL;
+Bool g_fXdmcpEnabled = FALSE;
+Bool g_fAuthEnabled = FALSE;
+HICON g_hIconX = NULL;
+HICON g_hSmallIconX = NULL;
+#ifndef RELOCATE_PROJECTROOT
+const char * g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log";
+#else
+const char * g_pszLogFile = "XWin.log";
+Bool g_fLogFileChanged = FALSE;
+#endif
+int g_iLogVerbose = 2;
+Bool g_fLogInited = FALSE;
+char * g_pszCommandLine = NULL;
+Bool g_fSilentFatalError = FALSE;
+DWORD g_dwCurrentThreadID = 0;
+Bool g_fKeyboardHookLL = FALSE;
+Bool g_fNoHelpMessageBox = FALSE;
+Bool g_fSoftwareCursor = FALSE;
+Bool g_fSilentDupError = FALSE;
+Bool g_fNativeGl = FALSE;
+Bool g_fswrastwgl = FALSE;
+
+
+#ifdef XWIN_CLIPBOARD
+/*
+ * Wrapped DIX functions
+ */
+winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
+winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
+
+
+/*
+ * Clipboard variables
+ */
+
+Bool g_fUnicodeClipboard = TRUE;
+Bool g_fClipboard = TRUE;
+Bool g_fClipboardPrimary = TRUE;
+Bool g_fClipboardLaunched = FALSE;
+Bool g_fClipboardStarted = FALSE;
+pthread_t g_ptClipboardProc;
+HWND g_hwndClipboard = NULL;
+void *g_pClipboardDisplay = NULL;
+Window g_iClipboardWindow = None;
+Atom g_atomLastOwnedSelection = None;
+#endif
+
+
+/*
+ * Re-initialize global variables that are invalidated
+ * by a server reset.
+ */
+
+void
+winInitializeGlobals (void)
+{
+ g_dwCurrentThreadID = GetCurrentThreadId ();
+#ifdef XWIN_CLIPBOARD
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_atomLastOwnedSelection = None;
+ g_hwndClipboard = NULL;
+#endif
+}
diff --git a/xorg-server/hw/xwin/winmonitors.c b/xorg-server/hw/xwin/winmonitors.c
index 876d23437..7b9bdc09e 100644
--- a/xorg-server/hw/xwin/winmonitors.c
+++ b/xorg-server/hw/xwin/winmonitors.c
@@ -67,7 +67,5 @@ Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
data->requestedMonitor = index;
/* query information */
- xEnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
-
- return TRUE;
+ return EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
}
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c
index 8ff7422b2..4e836fa06 100644
--- a/xorg-server/hw/xwin/winmultiwindowwndproc.c
+++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c
@@ -528,8 +528,8 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
tme.hwndTrack = hwnd;
/* Call the tracking function */
- if (!(*g_fpTrackMouseEvent) (&tme))
- ErrorF ("winTopLevelWindowProc - _TrackMouseEvent failed\n");
+ if (!TrackMouseEvent(&tme))
+ ErrorF ("winTopLevelWindowProc - TrackMouseEvent failed\n");
/* Flag that we are tracking now */
s_fTracking = TRUE;
diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c
index 306dce79f..683605ad7 100644
--- a/xorg-server/hw/xwin/winprocarg.c
+++ b/xorg-server/hw/xwin/winprocarg.c
@@ -89,12 +89,27 @@ winInitializeScreenDefaults(void)
dwWidth = GetSystemMetrics (SM_CXSCREEN);
dwHeight = GetSystemMetrics (SM_CYSCREEN);
- winDebug ("winInitializeScreenDefaults - w %d h %d\n",
- (int) dwWidth, (int) dwHeight);
+ winDebug ("winInitializeScreenDefaults - primary monitor w %d h %d\n", (int) dwWidth, (int) dwHeight);
- /* Set a default DPI, if no parameter was passed */
+ /* Set a default DPI, if no '-dpi' option was used */
if (monitorResolution == 0)
- monitorResolution = WIN_DEFAULT_DPI;
+ {
+ HDC hdc = GetDC(NULL);
+ if (hdc)
+ {
+ int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+ int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+
+ winErrorFVerb(2, "winInitializeDefaultScreens - native DPI x %d y %d\n", dpiX, dpiY);
+ monitorResolution = dpiY;
+ ReleaseDC(NULL, hdc);
+ }
+ else
+ {
+ winErrorFVerb(1, "winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n", WIN_DEFAULT_DPI);
+ monitorResolution = WIN_DEFAULT_DPI;
+ }
+ }
defaultScreenInfo.iMonitor = 1;
defaultScreenInfo.dwWidth = dwWidth;
@@ -310,8 +325,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
struct GetMonitorInfoData data;
if (!QueryMonitor(iMonitor, &data))
{
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
+ ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
} else if (data.bMonitorSpecifiedExists == TRUE)
{
winDebug("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
@@ -367,8 +381,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
struct GetMonitorInfoData data;
if (!QueryMonitor(iMonitor, &data))
{
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
+ ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
} else if (data.bMonitorSpecifiedExists == TRUE)
{
g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
@@ -395,8 +408,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
struct GetMonitorInfoData data;
if (!QueryMonitor(iMonitor, &data))
{
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
+ ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
} else if (data.bMonitorSpecifiedExists == TRUE)
{
winDebug ("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
diff --git a/xorg-server/hw/xwin/winwin32rootlesswndproc.c b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
index c8a6e66c3..c47719701 100644
--- a/xorg-server/hw/xwin/winwin32rootlesswndproc.c
+++ b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
@@ -1,1325 +1,1325 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Kensuke Matsuzaki
- * Earle F. Philhower, III
- * Harold L Hunt II
- */
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include <winuser.h>
-#define _WINDOWSWM_SERVER_
-#include <X11/extensions/windowswmstr.h>
-#include "dixevents.h"
-#include "propertyst.h"
-#include <X11/Xatom.h>
-#include "winmultiwindowclass.h"
-#include "winmsg.h"
-#include "inputstr.h"
-
-
-/*
- * Constant defines
- */
-
-#define MOUSE_ACTIVATE_DEFAULT TRUE
-#define RAISE_ON_CLICK_DEFAULT FALSE
-
-
-/*
- * Local globals
- */
-
-static UINT_PTR g_uipMousePollingTimerID = 0;
-
-
-/*
- * Local function
- */
-
-DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
-DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
-/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
-
-/*
- * ConstrainSize - Taken from TWM sources - Respects hints for sizing
- */
-#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
-static void
-ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
-{
- int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
- int baseWidth, baseHeight;
- int dwidth = *widthp, dheight = *heightp;
-
- if (hints.flags & PMinSize)
- {
- minWidth = hints.min_width;
- minHeight = hints.min_height;
- }
- else if (hints.flags & PBaseSize)
- {
- minWidth = hints.base_width;
- minHeight = hints.base_height;
- }
- else
- minWidth = minHeight = 1;
-
- if (hints.flags & PBaseSize)
- {
- baseWidth = hints.base_width;
- baseHeight = hints.base_height;
- }
- else if (hints.flags & PMinSize)
- {
- baseWidth = hints.min_width;
- baseHeight = hints.min_height;
- }
- else
- baseWidth = baseHeight = 0;
-
- if (hints.flags & PMaxSize)
- {
- maxWidth = hints.max_width;
- maxHeight = hints.max_height;
- }
- else
- {
- maxWidth = MAXINT;
- maxHeight = MAXINT;
- }
-
- if (hints.flags & PResizeInc)
- {
- xinc = hints.width_inc;
- yinc = hints.height_inc;
- }
- else
- xinc = yinc = 1;
-
- /*
- * First, clamp to min and max values
- */
- if (dwidth < minWidth)
- dwidth = minWidth;
- if (dheight < minHeight)
- dheight = minHeight;
-
- if (dwidth > maxWidth)
- dwidth = maxWidth;
- if (dheight > maxHeight)
- dheight = maxHeight;
-
- /*
- * Second, fit to base + N * inc
- */
- dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
- dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
-
- /*
- * Third, adjust for aspect ratio
- */
-
- /*
- * The math looks like this:
- *
- * minAspectX dwidth maxAspectX
- * ---------- <= ------- <= ----------
- * minAspectY dheight maxAspectY
- *
- * If that is multiplied out, then the width and height are
- * invalid in the following situations:
- *
- * minAspectX * dheight > minAspectY * dwidth
- * maxAspectX * dheight < maxAspectY * dwidth
- *
- */
-
- if (hints.flags & PAspect)
- {
- if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
- {
- delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
- if (dwidth + delta <= maxWidth)
- dwidth += delta;
- else
- {
- delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
- if (dheight - delta >= minHeight)
- dheight -= delta;
- }
- }
-
- if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
- {
- delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
- if (dheight + delta <= maxHeight)
- dheight += delta;
- else
- {
- delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
- if (dwidth - delta >= minWidth)
- dwidth -= delta;
- }
- }
- }
-
- /* Return computed values */
- *widthp = dwidth;
- *heightp = dheight;
-}
-#undef makemult
-
-
-
-/*
- * ValidateSizing - Ensures size request respects hints
- */
-static int
-ValidateSizing (HWND hwnd, WindowPtr pWin,
- WPARAM wParam, LPARAM lParam)
-{
- WinXSizeHints sizeHints;
- RECT *rect;
- int iWidth, iHeight, iTopBorder;
- POINT pt;
-
- /* Invalid input checking */
- if (pWin==NULL || lParam==0)
- {
- ErrorF ("Invalid input checking\n");
- return FALSE;
- }
-
- /* No size hints, no checking */
- if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
- {
- ErrorF ("No size hints, no checking\n");
- return FALSE;
- }
-
- /* Avoid divide-by-zero */
- if (sizeHints.flags & PResizeInc)
- {
- if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
- if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
- }
-
- rect = (RECT*)lParam;
-
- iWidth = rect->right - rect->left;
- iHeight = rect->bottom - rect->top;
-
- /* Get title bar height, there must be an easier way?! */
- pt.x = pt.y = 0;
- ClientToScreen(hwnd, &pt);
- iTopBorder = pt.y - rect->top;
-
- /* Now remove size of any borders */
- iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
-
- /* Constrain the size to legal values */
- ConstrainSize (sizeHints, &iWidth, &iHeight);
-
- /* Add back the borders */
- iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
-
- /* Adjust size according to where we're dragging from */
- switch(wParam) {
- case WMSZ_TOP:
- case WMSZ_TOPRIGHT:
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_RIGHT:
- rect->right = rect->left + iWidth;
- break;
- default:
- rect->left = rect->right - iWidth;
- break;
- }
- switch(wParam) {
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_BOTTOMLEFT:
- case WMSZ_RIGHT:
- case WMSZ_LEFT:
- rect->bottom = rect->top + iHeight;
- break;
- default:
- rect->top = rect->bottom - iHeight;
- break;
- }
- return TRUE;
-}
-
-
-/*
- * IsRaiseOnClick
- */
-
-static Bool
-IsRaiseOnClick (WindowPtr pWin)
-{
-
- struct _Window *pwin;
- struct _Property *prop;
- /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
- * Which pointer's current window do we want? */
- WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
-
- if (!pWin)
- {
- ErrorF ("IsRaiseOnClick - no prop use default value:%d\n",
- RAISE_ON_CLICK_DEFAULT);
- return RAISE_ON_CLICK_DEFAULT;
- }
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- while (prop)
- {
- if (prop->propertyName == AtmWindowsWmRaiseOnClick ()
- && prop->type == XA_INTEGER
- && prop->format == 32)
- {
- return *(int*)prop->data;
- }
- else
- prop = prop->next;
- }
-
- if (pWin != pRoot)
- {
- return IsRaiseOnClick (pRoot);
- }
- else
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("IsRaiseOnClick - no prop use default value:%d\n",
- RAISE_ON_CLICK_DEFAULT);
-#endif
- return RAISE_ON_CLICK_DEFAULT;
- }
-}
-
-
-/*
- * IsMouseActive
- */
-
-static Bool
-IsMouseActive (WindowPtr pWin)
-{
-
- struct _Window *pwin;
- struct _Property *prop;
- /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
- * Which pointer's current window do we want? */
- WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
-
- if (!pWin)
- {
- ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
- MOUSE_ACTIVATE_DEFAULT);
- return MOUSE_ACTIVATE_DEFAULT;
- }
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- while (prop)
- {
- if (prop->propertyName == AtmWindowsWMMouseActivate ()
- && prop->type == XA_INTEGER
- && prop->format == 32)
- {
- return *(int*)prop->data;
- }
- else
- prop = prop->next;
- }
-
- if (pWin != pRoot)
- {
- return IsMouseActive (pRoot);
- }
- else
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("IsMouseActive - no prop use default value:%d\n",
- MOUSE_ACTIVATE_DEFAULT);
-#endif
- return MOUSE_ACTIVATE_DEFAULT;
- }
-}
-
-
-/*
- * winMWExtWMWindowProc - Window procedure
- */
-
-LRESULT CALLBACK
-winMWExtWMWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- WindowPtr pWin = NULL;
- win32RootlessWindowPtr pRLWinPriv = NULL;
- ScreenPtr pScreen = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
- HWND hwndScreen = NULL;
- POINT ptMouse;
- static Bool s_fTracking = FALSE;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- LPWINDOWPOS pWinPos = NULL;
- RECT rcClient;
- winWMMessageRec wmMsg;
- Bool fWMMsgInitialized = FALSE;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- pWin = pRLWinPriv->pFrame->win;
- pScreen = pWin->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
- if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
-
- wmMsg.msg = 0;
- wmMsg.hwndWindow = hwnd;
- wmMsg.iWindow = (Window)pWin->drawable.id;
-
- wmMsg.iX = pRLWinPriv->pFrame->x;
- wmMsg.iY = pRLWinPriv->pFrame->y;
- wmMsg.iWidth = pRLWinPriv->pFrame->width;
- wmMsg.iHeight = pRLWinPriv->pFrame->height;
-
- fWMMsgInitialized = TRUE;
- winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
-
- winDebug ("\thWnd %08X\n", hwnd);
- winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
- winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
- winDebug ("\thwndScreen %08X\n", hwndScreen);
- winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
- pRLWinPriv, message, wParam, lParam);
- }
- /* Branch on message type */
- switch (message)
- {
- case WM_CREATE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_CREATE\n");
-#endif
- /* */
- SetProp (hwnd,
- WIN_WINDOW_PROP,
- (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
- return 0;
-
- case WM_CLOSE:
- winDebug ("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
-
- /* Tell window-manager to close window */
- if (pRLWinPriv->fClose)
- {
- DestroyWindow (hwnd);
- }
- else
- {
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMCloseWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- }
- return 0;
-
- case WM_DESTROY:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_DESTROY\n");
-#endif
- /* Free the shaodw DC; which allows the bitmap to be freed */
- DeleteDC (pRLWinPriv->hdcShadow);
- pRLWinPriv->hdcShadow = NULL;
-
- /* Free the shadow bitmap */
- DeleteObject (pRLWinPriv->hbmpShadow);
- pRLWinPriv->hbmpShadow = NULL;
-
- /* Free the screen DC */
- ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
- pRLWinPriv->hdcScreen = NULL;
-
- /* Free shadow buffer info header */
- free (pRLWinPriv->pbmihShadow);
- pRLWinPriv->pbmihShadow = NULL;
-
- pRLWinPriv->fResized = FALSE;
- pRLWinPriv->pfb = NULL;
- free (pRLWinPriv);
- RemoveProp (hwnd, WIN_WINDOW_PROP);
- break;
-
- case WM_MOUSEMOVE:
-#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
-#endif
- /* Unpack the client area mouse coordinates */
- ptMouse.x = GET_X_LPARAM(lParam);
- ptMouse.y = GET_Y_LPARAM(lParam);
-
- /* Translate the client area mouse coordinates to screen coordinates */
- ClientToScreen (hwnd, &ptMouse);
-
- /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
- ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* We can't do anything without privates */
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
-
- /* Has the mouse pointer crossed screens? */
- if (pScreen != miPointerGetScreen(inputInfo.pointer))
- miPointerSetScreen (inputInfo.pointer, pScreenInfo->dwScreen,
- ptMouse.x - pScreenInfo->dwXOffset,
- ptMouse.y - pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!(*g_fpTrackMouseEvent) (&tme))
- ErrorF ("winMWExtWMWindowProc - _TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Kill the timer used to poll mouse events */
- if (g_uipMousePollingTimerID != 0)
- {
- KillTimer (pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
- g_uipMousePollingTimerID = 0;
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
- ptMouse.y - pScreenInfo->dwYOffset);
-
- return 0;
-
- case WM_NCMOUSEMOVE:
-#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
-#endif
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * Timer to poll mouse events. This is needed to make
- * programs like xeyes follow the mouse properly.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
- break;
-
- case WM_MOUSELEAVE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
-#endif
- /* Mouse has left our client area */
-
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
-
- /*
- * Timer to poll mouse events. This is needed to make
- * programs like xeyes follow the mouse properly.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
- return 0;
-
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
-
- case WM_LBUTTONUP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_LBUTTONUP\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
-
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
-
- case WM_MBUTTONUP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MBUTTONUP\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
-
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
-
- case WM_RBUTTONUP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_RBUTTONUP\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
-
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
- case WM_XBUTTONUP:
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
-
- case WM_MOUSEWHEEL:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
-#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_MOUSEACTIVATE:
- winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
-
-#ifdef XWIN_MULTIWINDOWINTWM
- /* Check if this window needs to be made active when clicked */
- if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
- {
- winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
- "MA_NOACTIVATE\n");
-
- /* */
- return MA_NOACTIVATE;
- }
-#endif
- if (
-#ifdef XWIN_MULTIWINDOWINTWM
- !winIsInternalWMRunning(pScreenInfo) &&
-#endif
- !IsMouseActive (pWin))
- return MA_NOACTIVATE;
-
- break;
-
- case WM_KILLFOCUS:
- /* Pop any pressed keys since we are losing keyboard focus */
- winKeybdReleaseKeys ();
- return 0;
-
- case WM_SYSDEADCHAR:
- case WM_DEADCHAR:
- /*
- * NOTE: We do nothing with WM_*CHAR messages,
- * nor does the root window, so we can just toss these messages.
- */
- return 0;
-
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_*KEYDOWN\n");
-#endif
-
- /*
- * Don't pass Alt-F4 key combo to root window,
- * let Windows translate to WM_CLOSE and close this top-level window.
- *
- * NOTE: We purposely don't check the fUseWinKillKey setting because
- * it should only apply to the key handling for the root window,
- * not for top-level window-manager windows.
- *
- * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
- * because that is a key combo that no X app should be expecting to
- * receive, since it has historically been used to shutdown the X server.
- * Passing Ctrl-Alt-Backspace to the root window preserves that
- * behavior, assuming that -unixkill has been passed as a parameter.
- */
- if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
- break;
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_SYSKEYUP:
- case WM_KEYUP:
-
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_*KEYUP\n");
-#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_HOTKEY:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_HOTKEY\n");
-#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_ERASEBKGND:
- winDebug ("winMWExtWMWindowProc - WM_ERASEBKGND\n");
- /*
- * Pretend that we did erase the background but we don't care,
- * since we repaint the entire region anyhow
- * This avoids some flickering when resizing.
- */
- return TRUE;
-
- case WM_PAINT:
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (hwnd, &ps);
-
- /* Try to copy from the shadow buffer */
- if (!BitBlt (hdcUpdate,
- ps.rcPaint.left, ps.rcPaint.top,
- ps.rcPaint.right - ps.rcPaint.left,
- ps.rcPaint.bottom - ps.rcPaint.top,
- pRLWinPriv->hdcShadow,
- ps.rcPaint.left, ps.rcPaint.top,
- SRCCOPY))
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
-
- ErrorF ("winMWExtWMWindowProc - BitBlt failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
- }
-
- /* EndPaint frees the DC */
- EndPaint (hwnd, &ps);
- break;
-
- case WM_ACTIVATE:
- winDebug ("winMWExtWMWindowProc - WM_ACTIVATE\n");
- if (LOWORD(wParam) != WA_INACTIVE)
- {
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
-#if 0
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
-#endif
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized)
- if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMActivateWindow,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- return 0;
-
-#if 1
- case WM_WINDOWPOSCHANGING:
- pWinPos = (LPWINDOWPOS)lParam;
- if (!(pWinPos->flags & SWP_NOZORDER))
- {
- if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
- {
- winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
- break;
- }
-
- if (
-#ifdef XWIN_MULTIWINDOWINTWM
- winIsInternalWMRunning(pScreenInfo) ||
-#endif
- IsRaiseOnClick (pWin))
- {
- winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
- break;
- }
-
- winDebug ("Win %08x forbid to change z order (%08x).\n",
- (unsigned int)pRLWinPriv, (unsigned int)pWinPos->hwndInsertAfter);
-
- pWinPos->flags |= SWP_NOZORDER;
- }
- break;
-#endif
-
- case WM_MOVE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- if (g_fNoConfigureWindow) break;
-#if 0
- /* Bail if Windows window is not actually moving */
- if (pRLWinPriv->dwX == (short) LOWORD(lParam)
- && pRLWinPriv->dwY == (short) HIWORD(lParam))
- break;
-
- /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
- {
- WINDOWPLACEMENT windPlace;
- windPlace.length = sizeof (WINDOWPLACEMENT);
-
- /* Get current window placement */
- GetWindowPlacement (hwnd, &windPlace);
-
- /* Bail if maximizing */
- if (windPlace.showCmd == SW_MAXIMIZE
- || windPlace.showCmd == SW_SHOWMAXIMIZED)
- break;
- }
-#endif
-
- winDebug ("\t(%d, %d)\n", (short) LOWORD(lParam), (short) HIWORD(lParam));
-
- if (!pRLWinPriv->fMovingOrSizing)
- {
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
- winMWExtWMMoveXWindow (pWin,
- (LOWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN)),
- (HIWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN)));
- }
- return 0;
-
- case WM_SHOWWINDOW:
- winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
- (unsigned int)GetTickCount ());
-
- /* Bail out if the window is being hidden */
- if (!wParam)
- return 0;
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if (!pScreenInfo->fInternalWM)//XXXX
- return 0;
-
- winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
-
- if (winIsInternalWMRunning(pScreenInfo))
- {
- winDebug ("\tMapWindow\n");
-
- /* Tell X to map the window */
- MapWindow (pWin, wClient(pWin));
-
- if (!pRLWinPriv->pFrame->win->overrideRedirect)
- /* Bring the Windows window to the foreground */
- SetForegroundWindow (hwnd);
-
- /* Setup the Window Manager message */
- wmMsg.msg = WM_WM_MAP;
- wmMsg.iWidth = pRLWinPriv->pFrame->width;
- wmMsg.iHeight = pRLWinPriv->pFrame->height;
-
- /* Tell our Window Manager thread to map the window */
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#else
- return 0;
-#endif
- break;
-
- case WM_SIZING:
- /* Need to legalize the size according to WM_NORMAL_HINTS */
- /* for applications like xterm */
- return ValidateSizing (hwnd, pWin, wParam, lParam);
-
- case WM_WINDOWPOSCHANGED:
- {
- pWinPos = (LPWINDOWPOS) lParam;
-#ifdef _DEBUG
- winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
- winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
- (pWinPos->flags & SWP_DRAWFRAME)?"SWP_DRAWFRAME ":"",
- (pWinPos->flags & SWP_FRAMECHANGED)?"SWP_FRAMECHANGED ":"",
- (pWinPos->flags & SWP_HIDEWINDOW)?"SWP_HIDEWINDOW ":"",
- (pWinPos->flags & SWP_NOACTIVATE)?"SWP_NOACTIVATE ":"",
- (pWinPos->flags & SWP_NOCOPYBITS)?"SWP_NOCOPYBITS ":"",
- (pWinPos->flags & SWP_NOMOVE)?"SWP_NOMOVE ":"",
- (pWinPos->flags & SWP_NOOWNERZORDER)?"SWP_NOOWNERZORDER ":"",
- (pWinPos->flags & SWP_NOSIZE)?"SWP_NOSIZE ":"",
- (pWinPos->flags & SWP_NOREDRAW)?"SWP_NOREDRAW ":"",
- (pWinPos->flags & SWP_NOSENDCHANGING)?"SWP_NOSENDCHANGING ":"",
- (pWinPos->flags & SWP_NOZORDER)?"SWP_NOZORDER ":"",
- (pWinPos->flags & SWP_SHOWWINDOW)?"SWP_SHOWWINDOW ":"");
- winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow?"Yes":"No"));
- winDebug("\textend: (%d, %d, %d, %d)\n",
- pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
-
-#endif
- if (pWinPos->flags & SWP_HIDEWINDOW) break;
-
-#ifdef XWIN_MULTIWINDOWINTWM
- /* Reorder if window z order was changed */
- if ((pScreenPriv != NULL)
- && !(pWinPos->flags & SWP_NOZORDER)
- && !(pWinPos->flags & SWP_SHOWWINDOW)
- && winIsInternalWMRunning(pScreenInfo))
- {
- winDebug ("\twindow z order was changed\n");
-
- if (pWinPos->hwndInsertAfter == HWND_TOP
- ||pWinPos->hwndInsertAfter == HWND_TOPMOST
- ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
- {
- winDebug ("\traise to top\n");
-
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#if 1
- else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
- {
- }
- else
- {
- /* Check if this window is top of X windows. */
- HWND hWndAbove = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- for (hWndAbove = pWinPos->hwndInsertAfter;
- hWndAbove != NULL;
- hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
- {
- /* Ignore other XWin process's window */
- GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWndAbove, WIN_WINDOW_PROP)
- && !IsWindowVisible (hWndAbove)
- && !IsIconic (hWndAbove) ) /* ignore minimized windows */
- break;
- }
- /* If this is top of X windows in Windows stack,
- raise it in X stack. */
- if (hWndAbove == NULL)
- {
- winDebug ("\traise to top\n");
-
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- }
-#endif
- }
-#endif
-
- if (!(pWinPos->flags & SWP_NOSIZE)) {
- if (IsIconic(hwnd)){
- winDebug ("\tIconic -> MINIMIZED\n");
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_LOWER;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMinimizeWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- } else if (IsZoomed(hwnd)){
- winDebug ("\tZoomed -> MAXIMIZED\n");
-
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMaximizeWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- } else {
- winDebug ("\tnone -> RESTORED\n");
-
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMRestoreWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- }
- }
- if (!g_fNoConfigureWindow ) {
-
- if (!pRLWinPriv->fMovingOrSizing
- /*&& (pWinPos->flags & SWP_SHOWWINDOW)*/) {
- GetClientRect (hwnd, &rcClient);
- MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
-
- if (!(pWinPos->flags & SWP_NOMOVE)
- &&!(pWinPos->flags & SWP_NOSIZE)) {
- winDebug ("\tmove & resize\n");
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- } else if (!(pWinPos->flags & SWP_NOMOVE)) {
- winDebug ("\tmove\n");
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- } else if (!(pWinPos->flags & SWP_NOMOVE)) {
- winDebug ("\tmove\n");
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
- winMWExtWMMoveXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN));
- } else if (!(pWinPos->flags & SWP_NOSIZE)) {
- winDebug ("\tresize\n");
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
- winMWExtWMResizeXWindow (pWin,
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- }
- }
- }
- }
- winDebug ("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
-
- return 0;
-
- case WM_SIZE:
- /* see dix/window.c */
- /* FIXME: Maximize/Restore? */
- winDebug ("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
- (unsigned int)GetTickCount ());
-
- winDebug ("\t(%d, %d) %d\n", (short) LOWORD(lParam), (short) HIWORD(lParam), g_fNoConfigureWindow);
-
- if (g_fNoConfigureWindow) break;
-
- /* Branch on type of resizing occurring */
- switch (wParam)
- {
- case SIZE_MINIMIZED:
- winDebug ("\tSIZE_MINIMIZED\n");
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_LOWER;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMinimizeWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
-
- case SIZE_RESTORED:
- winDebug ("\tSIZE_RESTORED\n");
-
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMRestoreWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
-
- case SIZE_MAXIMIZED:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tSIZE_MAXIMIZED\n");
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMaximizeWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
- }
-
- /* Perform the resize and notify the X client */
- if (!pRLWinPriv->fMovingOrSizing)
- {
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
- winMWExtWMResizeXWindow (pWin,
- (short) LOWORD(lParam)
- - wBorderWidth (pWin)*2,
- (short) HIWORD(lParam)
- - wBorderWidth (pWin)*2);
- }
- break;
-
- case WM_ACTIVATEAPP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- if (wParam)
- {
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- }
- else
- {
- }
-#endif
- winWindowsWMSendEvent(WindowsWMActivationNotify,
- WindowsWMActivationNotifyMask,
- 1,
- WindowsWMIsActive,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- else
- {
- winWindowsWMSendEvent(WindowsWMActivationNotify,
- WindowsWMActivationNotifyMask,
- 1,
- WindowsWMIsInactive,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- break;
-
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
-
- case WM_ENTERSIZEMOVE:
- winDebug ("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
- (unsigned int)GetTickCount ());
-
- pRLWinPriv->fMovingOrSizing = TRUE;
- break;
-
- case WM_EXITSIZEMOVE:
- winDebug ("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
- (unsigned int)GetTickCount ());
-
- pRLWinPriv->fMovingOrSizing = FALSE;
-
- GetClientRect (hwnd, &rcClient);
-
- MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-#endif
-
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- break;
-
- case WM_MANAGE:
- winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
- break;
-
- case WM_UNMANAGE:
- winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
- break;
-
- default:
- break;
- }
-
- return DefWindowProc (hwnd, message, wParam, lParam);
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <winuser.h>
+#define _WINDOWSWM_SERVER_
+#include <X11/extensions/windowswmstr.h>
+#include "dixevents.h"
+#include "propertyst.h"
+#include <X11/Xatom.h>
+#include "winmultiwindowclass.h"
+#include "winmsg.h"
+#include "inputstr.h"
+
+
+/*
+ * Constant defines
+ */
+
+#define MOUSE_ACTIVATE_DEFAULT TRUE
+#define RAISE_ON_CLICK_DEFAULT FALSE
+
+
+/*
+ * Local globals
+ */
+
+static UINT_PTR g_uipMousePollingTimerID = 0;
+
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
+DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
+/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
+
+/*
+ * ConstrainSize - Taken from TWM sources - Respects hints for sizing
+ */
+#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
+static void
+ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+{
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize)
+ {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
+ }
+ else if (hints.flags & PBaseSize)
+ {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
+ }
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize)
+ {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
+ }
+ else if (hints.flags & PMinSize)
+ {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
+
+ if (hints.flags & PMaxSize)
+ {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
+ }
+ else
+ {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
+ }
+
+ if (hints.flags & PResizeInc)
+ {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
+ }
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect)
+ {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
+ {
+ delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else
+ {
+ delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
+ }
+ }
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
+ {
+ delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else
+ {
+ delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
+ }
+ }
+ }
+
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
+
+
+
+/*
+ * ValidateSizing - Ensures size request respects hints
+ */
+static int
+ValidateSizing (HWND hwnd, WindowPtr pWin,
+ WPARAM wParam, LPARAM lParam)
+{
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight, iTopBorder;
+ POINT pt;
+
+ /* Invalid input checking */
+ if (pWin==NULL || lParam==0)
+ {
+ ErrorF ("Invalid input checking\n");
+ return FALSE;
+ }
+
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
+ {
+ ErrorF ("No size hints, no checking\n");
+ return FALSE;
+ }
+
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc)
+ {
+ if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+ }
+
+ rect = (RECT*)lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Get title bar height, there must be an easier way?! */
+ pt.x = pt.y = 0;
+ ClientToScreen(hwnd, &pt);
+ iTopBorder = pt.y - rect->top;
+
+ /* Now remove size of any borders */
+ iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Constrain the size to legal values */
+ ConstrainSize (sizeHints, &iWidth, &iHeight);
+
+ /* Add back the borders */
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Adjust size according to where we're dragging from */
+ switch(wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
+ }
+ switch(wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
+ }
+ return TRUE;
+}
+
+
+/*
+ * IsRaiseOnClick
+ */
+
+static Bool
+IsRaiseOnClick (WindowPtr pWin)
+{
+
+ struct _Window *pwin;
+ struct _Property *prop;
+ /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
+ * Which pointer's current window do we want? */
+ WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
+
+ if (!pWin)
+ {
+ ErrorF ("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+ return RAISE_ON_CLICK_DEFAULT;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == AtmWindowsWmRaiseOnClick ()
+ && prop->type == XA_INTEGER
+ && prop->format == 32)
+ {
+ return *(int*)prop->data;
+ }
+ else
+ prop = prop->next;
+ }
+
+ if (pWin != pRoot)
+ {
+ return IsRaiseOnClick (pRoot);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+#endif
+ return RAISE_ON_CLICK_DEFAULT;
+ }
+}
+
+
+/*
+ * IsMouseActive
+ */
+
+static Bool
+IsMouseActive (WindowPtr pWin)
+{
+
+ struct _Window *pwin;
+ struct _Property *prop;
+ /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
+ * Which pointer's current window do we want? */
+ WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
+
+ if (!pWin)
+ {
+ ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == AtmWindowsWMMouseActivate ()
+ && prop->type == XA_INTEGER
+ && prop->format == 32)
+ {
+ return *(int*)prop->data;
+ }
+ else
+ prop = prop->next;
+ }
+
+ if (pWin != pRoot)
+ {
+ return IsMouseActive (pRoot);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("IsMouseActive - no prop use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+#endif
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
+}
+
+
+/*
+ * winMWExtWMWindowProc - Window procedure
+ */
+
+LRESULT CALLBACK
+winMWExtWMWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ WindowPtr pWin = NULL;
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ POINT ptMouse;
+ static Bool s_fTracking = FALSE;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ LPWINDOWPOS pWinPos = NULL;
+ RECT rcClient;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pWin = pRLWinPriv->pFrame->win;
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
+
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window)pWin->drawable.id;
+
+ wmMsg.iX = pRLWinPriv->pFrame->x;
+ wmMsg.iY = pRLWinPriv->pFrame->y;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ fWMMsgInitialized = TRUE;
+ winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
+
+ winDebug ("\thWnd %08X\n", hwnd);
+ winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
+ winDebug ("\thwndScreen %08X\n", hwndScreen);
+ winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
+ pRLWinPriv, message, wParam, lParam);
+ }
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_CREATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_CREATE\n");
+#endif
+ /* */
+ SetProp (hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
+ return 0;
+
+ case WM_CLOSE:
+ winDebug ("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
+
+ /* Tell window-manager to close window */
+ if (pRLWinPriv->fClose)
+ {
+ DestroyWindow (hwnd);
+ }
+ else
+ {
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMCloseWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ }
+ return 0;
+
+ case WM_DESTROY:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_DESTROY\n");
+#endif
+ /* Free the shaodw DC; which allows the bitmap to be freed */
+ DeleteDC (pRLWinPriv->hdcShadow);
+ pRLWinPriv->hdcShadow = NULL;
+
+ /* Free the shadow bitmap */
+ DeleteObject (pRLWinPriv->hbmpShadow);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Free the screen DC */
+ ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
+ pRLWinPriv->hdcScreen = NULL;
+
+ /* Free shadow buffer info header */
+ free (pRLWinPriv->pbmihShadow);
+ pRLWinPriv->pbmihShadow = NULL;
+
+ pRLWinPriv->fResized = FALSE;
+ pRLWinPriv->pfb = NULL;
+ free (pRLWinPriv);
+ RemoveProp (hwnd, WIN_WINDOW_PROP);
+ break;
+
+ case WM_MOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
+#endif
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen (hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (pScreen != miPointerGetScreen(inputInfo.pointer))
+ miPointerSetScreen (inputInfo.pointer, pScreenInfo->dwScreen,
+ ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!TrackMouseEvent(&tme))
+ ErrorF ("winMWExtWMWindowProc - TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0)
+ {
+ KillTimer (pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
+#endif
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ break;
+
+ case WM_MOUSELEAVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
+#endif
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_LBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_RBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ case WM_XBUTTONUP:
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_MOUSEWHEEL:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_MOUSEACTIVATE:
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ /* Check if this window needs to be made active when clicked */
+ if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
+ {
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
+
+ /* */
+ return MA_NOACTIVATE;
+ }
+#endif
+ if (
+#ifdef XWIN_MULTIWINDOWINTWM
+ !winIsInternalWMRunning(pScreenInfo) &&
+#endif
+ !IsMouseActive (pWin))
+ return MA_NOACTIVATE;
+
+ break;
+
+ case WM_KILLFOCUS:
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys ();
+ return 0;
+
+ case WM_SYSDEADCHAR:
+ case WM_DEADCHAR:
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_*KEYDOWN\n");
+#endif
+
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
+ break;
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_*KEYUP\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_HOTKEY:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_HOTKEY\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_ERASEBKGND:
+ winDebug ("winMWExtWMWindowProc - WM_ERASEBKGND\n");
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * since we repaint the entire region anyhow
+ * This avoids some flickering when resizing.
+ */
+ return TRUE;
+
+ case WM_PAINT:
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (hwnd, &ps);
+
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt (hdcUpdate,
+ ps.rcPaint.left, ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left,
+ ps.rcPaint.bottom - ps.rcPaint.top,
+ pRLWinPriv->hdcShadow,
+ ps.rcPaint.left, ps.rcPaint.top,
+ SRCCOPY))
+ {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError (),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL);
+
+ ErrorF ("winMWExtWMWindowProc - BitBlt failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint (hwnd, &ps);
+ break;
+
+ case WM_ACTIVATE:
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATE\n");
+ if (LOWORD(wParam) != WA_INACTIVE)
+ {
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if 0
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+#endif
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMActivateWindow,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ return 0;
+
+#if 1
+ case WM_WINDOWPOSCHANGING:
+ pWinPos = (LPWINDOWPOS)lParam;
+ if (!(pWinPos->flags & SWP_NOZORDER))
+ {
+ if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
+ {
+ winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
+ break;
+ }
+
+ if (
+#ifdef XWIN_MULTIWINDOWINTWM
+ winIsInternalWMRunning(pScreenInfo) ||
+#endif
+ IsRaiseOnClick (pWin))
+ {
+ winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
+ break;
+ }
+
+ winDebug ("Win %08x forbid to change z order (%08x).\n",
+ (unsigned int)pRLWinPriv, (unsigned int)pWinPos->hwndInsertAfter);
+
+ pWinPos->flags |= SWP_NOZORDER;
+ }
+ break;
+#endif
+
+ case WM_MOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ if (g_fNoConfigureWindow) break;
+#if 0
+ /* Bail if Windows window is not actually moving */
+ if (pRLWinPriv->dwX == (short) LOWORD(lParam)
+ && pRLWinPriv->dwY == (short) HIWORD(lParam))
+ break;
+
+ /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
+ {
+ WINDOWPLACEMENT windPlace;
+ windPlace.length = sizeof (WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement (hwnd, &windPlace);
+
+ /* Bail if maximizing */
+ if (windPlace.showCmd == SW_MAXIMIZE
+ || windPlace.showCmd == SW_SHOWMAXIMIZED)
+ break;
+ }
+#endif
+
+ winDebug ("\t(%d, %d)\n", (short) LOWORD(lParam), (short) HIWORD(lParam));
+
+ if (!pRLWinPriv->fMovingOrSizing)
+ {
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+ winMWExtWMMoveXWindow (pWin,
+ (LOWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN)),
+ (HIWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN)));
+ }
+ return 0;
+
+ case WM_SHOWWINDOW:
+ winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
+ (unsigned int)GetTickCount ());
+
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (!pScreenInfo->fInternalWM)//XXXX
+ return 0;
+
+ winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ winDebug ("\tMapWindow\n");
+
+ /* Tell X to map the window */
+ MapWindow (pWin, wClient(pWin));
+
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ /* Bring the Windows window to the foreground */
+ SetForegroundWindow (hwnd);
+
+ /* Setup the Window Manager message */
+ wmMsg.msg = WM_WM_MAP;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#else
+ return 0;
+#endif
+ break;
+
+ case WM_SIZING:
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing (hwnd, pWin, wParam, lParam);
+
+ case WM_WINDOWPOSCHANGED:
+ {
+ pWinPos = (LPWINDOWPOS) lParam;
+#ifdef _DEBUG
+ winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
+ winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
+ (pWinPos->flags & SWP_DRAWFRAME)?"SWP_DRAWFRAME ":"",
+ (pWinPos->flags & SWP_FRAMECHANGED)?"SWP_FRAMECHANGED ":"",
+ (pWinPos->flags & SWP_HIDEWINDOW)?"SWP_HIDEWINDOW ":"",
+ (pWinPos->flags & SWP_NOACTIVATE)?"SWP_NOACTIVATE ":"",
+ (pWinPos->flags & SWP_NOCOPYBITS)?"SWP_NOCOPYBITS ":"",
+ (pWinPos->flags & SWP_NOMOVE)?"SWP_NOMOVE ":"",
+ (pWinPos->flags & SWP_NOOWNERZORDER)?"SWP_NOOWNERZORDER ":"",
+ (pWinPos->flags & SWP_NOSIZE)?"SWP_NOSIZE ":"",
+ (pWinPos->flags & SWP_NOREDRAW)?"SWP_NOREDRAW ":"",
+ (pWinPos->flags & SWP_NOSENDCHANGING)?"SWP_NOSENDCHANGING ":"",
+ (pWinPos->flags & SWP_NOZORDER)?"SWP_NOZORDER ":"",
+ (pWinPos->flags & SWP_SHOWWINDOW)?"SWP_SHOWWINDOW ":"");
+ winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow?"Yes":"No"));
+ winDebug("\textend: (%d, %d, %d, %d)\n",
+ pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
+
+#endif
+ if (pWinPos->flags & SWP_HIDEWINDOW) break;
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ /* Reorder if window z order was changed */
+ if ((pScreenPriv != NULL)
+ && !(pWinPos->flags & SWP_NOZORDER)
+ && !(pWinPos->flags & SWP_SHOWWINDOW)
+ && winIsInternalWMRunning(pScreenInfo))
+ {
+ winDebug ("\twindow z order was changed\n");
+
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ ||pWinPos->hwndInsertAfter == HWND_TOPMOST
+ ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
+ {
+ winDebug ("\traise to top\n");
+
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#if 1
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
+ {
+ }
+ else
+ {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
+ {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible (hWndAbove)
+ && !IsIconic (hWndAbove) ) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL)
+ {
+ winDebug ("\traise to top\n");
+
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ }
+#endif
+ }
+#endif
+
+ if (!(pWinPos->flags & SWP_NOSIZE)) {
+ if (IsIconic(hwnd)){
+ winDebug ("\tIconic -> MINIMIZED\n");
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ } else if (IsZoomed(hwnd)){
+ winDebug ("\tZoomed -> MAXIMIZED\n");
+
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ } else {
+ winDebug ("\tnone -> RESTORED\n");
+
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ }
+ }
+ if (!g_fNoConfigureWindow ) {
+
+ if (!pRLWinPriv->fMovingOrSizing
+ /*&& (pWinPos->flags & SWP_SHOWWINDOW)*/) {
+ GetClientRect (hwnd, &rcClient);
+ MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+ if (!(pWinPos->flags & SWP_NOMOVE)
+ &&!(pWinPos->flags & SWP_NOSIZE)) {
+ winDebug ("\tmove & resize\n");
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ } else if (!(pWinPos->flags & SWP_NOMOVE)) {
+ winDebug ("\tmove\n");
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ } else if (!(pWinPos->flags & SWP_NOMOVE)) {
+ winDebug ("\tmove\n");
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+ winMWExtWMMoveXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN));
+ } else if (!(pWinPos->flags & SWP_NOSIZE)) {
+ winDebug ("\tresize\n");
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+ winMWExtWMResizeXWindow (pWin,
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ }
+ }
+ }
+ }
+ winDebug ("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
+
+ return 0;
+
+ case WM_SIZE:
+ /* see dix/window.c */
+ /* FIXME: Maximize/Restore? */
+ winDebug ("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
+ (unsigned int)GetTickCount ());
+
+ winDebug ("\t(%d, %d) %d\n", (short) LOWORD(lParam), (short) HIWORD(lParam), g_fNoConfigureWindow);
+
+ if (g_fNoConfigureWindow) break;
+
+ /* Branch on type of resizing occurring */
+ switch (wParam)
+ {
+ case SIZE_MINIMIZED:
+ winDebug ("\tSIZE_MINIMIZED\n");
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_RESTORED:
+ winDebug ("\tSIZE_RESTORED\n");
+
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_MAXIMIZED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_MAXIMIZED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+ }
+
+ /* Perform the resize and notify the X client */
+ if (!pRLWinPriv->fMovingOrSizing)
+ {
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+ winMWExtWMResizeXWindow (pWin,
+ (short) LOWORD(lParam)
+ - wBorderWidth (pWin)*2,
+ (short) HIWORD(lParam)
+ - wBorderWidth (pWin)*2);
+ }
+ break;
+
+ case WM_ACTIVATEAPP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ if (wParam)
+ {
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ }
+ else
+ {
+ }
+#endif
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsActive,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ else
+ {
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsInactive,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ break;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+ case WM_ENTERSIZEMOVE:
+ winDebug ("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+
+ pRLWinPriv->fMovingOrSizing = TRUE;
+ break;
+
+ case WM_EXITSIZEMOVE:
+ winDebug ("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ GetClientRect (hwnd, &rcClient);
+
+ MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+#endif
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ break;
+
+ case WM_MANAGE:
+ winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
+ break;
+
+ case WM_UNMANAGE:
+ winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
+ break;
+
+ default:
+ break;
+ }
+
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c
index 07e928874..05879eb9d 100644
--- a/xorg-server/hw/xwin/winwindowswm.c
+++ b/xorg-server/hw/xwin/winwindowswm.c
@@ -604,9 +604,11 @@ winWindowsWMExtensionInit (void)
NULL,
StandardMinorOpcode)))
{
+ size_t i;
WMReqCode = (unsigned char)extEntry->base;
WMErrorBase = extEntry->errorBase;
WMEventBase = extEntry->eventBase;
- EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+ for (i=0; i < WindowsWMNumberEvents; i++)
+ EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent;
}
}
diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c
index f83717637..1f91eedae 100644
--- a/xorg-server/hw/xwin/winwndproc.c
+++ b/xorg-server/hw/xwin/winwndproc.c
@@ -777,8 +777,8 @@ winWindowProc (HWND hwnd, UINT message,
tme.hwndTrack = hwnd;
/* Call the tracking function */
- if (!(*g_fpTrackMouseEvent) (&tme))
- ErrorF ("winWindowProc - _TrackMouseEvent failed\n");
+ if (!TrackMouseEvent(&tme))
+ ErrorF ("winWindowProc - TrackMouseEvent failed\n");
/* Flag that we are tracking now */
s_fTracking = TRUE;