summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2010-02-12 12:29:30 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2011-01-19 14:02:19 +0000
commit73b02e964787ea9fb2d139dc781c9b2495ccb031 (patch)
treec334ed86bb17183ad37aa0ce574cf92fe00f78fa
parenta46146af5f6c2d96728c43f0df369ea00bcae017 (diff)
Cygwin/X: Remove an attempt at detecting if WM_DISPLAYCHANGE affects the X screen
Remove an attempt at the rather difficult optimization of detecting if WM_DISPLAYCHANGE affects any of the monitors which intersect the native window for the X screen. We'll always act as if it does, which it probably usually the case. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net> Tested-by: Colin Harrison <colin.harrison@virgin.net>
-rw-r--r--hw/xwin/win.h5
-rw-r--r--hw/xwin/windialogs.c13
-rw-r--r--hw/xwin/winscrinit.c12
-rw-r--r--hw/xwin/winwndproc.c70
4 files changed, 31 insertions, 69 deletions
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 8b7b69990..ceb001cd6 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -481,11 +481,6 @@ typedef struct _winPrivScreenRec
/* Handle to icons that must be freed */
HICON hiconNotifyIcon;
- /* Last width, height, and depth of the Windows display */
- DWORD dwLastWindowsWidth;
- DWORD dwLastWindowsHeight;
- DWORD dwLastWindowsBitsPixel;
-
/* Palette management */
ColormapPtr pcmapInstalled;
diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index 679b3fab5..c3a149762 100644
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -482,11 +482,11 @@ winChangeDepthDlgProc (HWND hwndDialog, UINT message,
#if CYGDEBUG
winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
- "last bpp: %d\n",
+ "current bpp: %d\n",
s_pScreenInfo->dwBPP,
- s_pScreenPriv->dwLastWindowsBitsPixel);
+ GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
#endif
-
+
winInitDialog( hwndDialog );
return TRUE;
@@ -494,14 +494,13 @@ winChangeDepthDlgProc (HWND hwndDialog, UINT message,
case WM_DISPLAYCHANGE:
#if CYGDEBUG
winDebug ("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
- "last bpp: %d, new bpp: %d\n",
+ "new bpp: %d\n",
s_pScreenInfo->dwBPP,
- s_pScreenPriv->dwLastWindowsBitsPixel,
- wParam);
+ GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
#endif
/* Dismiss the dialog if the display returns to the original depth */
- if (wParam == s_pScreenInfo->dwBPP)
+ if (GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL) == s_pScreenInfo->dwBPP)
{
ErrorF ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 46f6693bd..74ca11557 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -175,13 +175,9 @@ winScreenInit (int index,
/* Get a device context */
hdc = GetDC (pScreenPriv->hwndScreen);
- /* Store the initial height, width, and depth of the display */
/* Are we using multiple monitors? */
if (pScreenInfo->fMultipleMonitors)
{
- pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
-
/*
* In this case, some of the defaults set in
* winInitializeScreenDefaults() are not correct ...
@@ -192,14 +188,6 @@ winScreenInit (int index,
pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
}
}
- else
- {
- pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
- pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
- }
-
- /* Save the original bits per pixel */
- pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL);
/* Release the device context */
ReleaseDC (pScreenPriv->hwndScreen, hdc);
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 6d2270a20..7983e9aa4 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -148,6 +148,13 @@ winWindowProc (HWND hwnd, UINT message,
return 0;
case WM_DISPLAYCHANGE:
+ /*
+ WM_DISPLAYCHANGE seems to be sent when the monitor layout or
+ any monitor's resolution or depth changes, but it's lParam and
+ wParam always indicate the resolution and bpp for the primary
+ monitor (so ignore that as we could be on any monitor...)
+ */
+
/* We cannot handle a display mode change during initialization */
if (s_pScreenInfo == NULL)
FatalError ("winWindowProc - WM_DISPLAYCHANGE - The display "
@@ -167,22 +174,10 @@ winWindowProc (HWND hwnd, UINT message,
#endif
))
{
- /*
- * Store the new display dimensions and depth.
- * We do this here for future compatibility in case we
- * ever allow switching from fullscreen to windowed mode.
- */
- s_pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
- s_pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
- s_pScreenPriv->dwLastWindowsBitsPixel
- = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
break;
}
-
- ErrorF ("winWindowProc - WM_DISPLAYCHANGE - orig bpp: %d, last bpp: %d, "
- "new bpp: %d\n",
- (int) s_pScreenInfo->dwBPP,
- (int) s_pScreenPriv->dwLastWindowsBitsPixel,
+
+ ErrorF ("winWindowProc - WM_DISPLAYCHANGE - new bpp: %d\n",
wParam);
ErrorF ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
@@ -216,7 +211,11 @@ winWindowProc (HWND hwnd, UINT message,
* We can only display a message for a disruptive depth change,
* we cannot do anything to correct the situation.
*/
- if ((s_pScreenInfo->dwBPP != wParam)
+ /*
+ XXX: maybe we need to check if GetSystemMetrics(SM_SAMEDISPLAYFORMAT)
+ has changed as well...
+ */
+ if ((s_pScreenInfo->dwBPP != GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL))
&& (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
|| s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
#ifdef XWIN_PRIMARYFB
@@ -227,7 +226,7 @@ winWindowProc (HWND hwnd, UINT message,
/* Cannot display the visual until the depth is restored */
ErrorF ("winWindowProc - Disruptive change in depth\n");
- /* Display Exit dialog */
+ /* Display depth change dialog */
winDisplayDepthChangeDialog (s_pScreenPriv);
/* Flag that we have an invalid screen depth */
@@ -241,14 +240,19 @@ winWindowProc (HWND hwnd, UINT message,
/* Flag that we have a valid screen depth */
s_pScreenPriv->fBadDepth = FALSE;
}
-
+
+ /*
+ If we could cheaply check if this WM_DISPLAYCHANGE change
+ affects the monitor(s) which this X screen is displayed on
+ then we should do so here. For the moment, assume it does.
+ (this is probably usually the case so that might be an
+ overoptimization)
+ */
+
/*
- * Check for a change in display dimensions.
* We can simply recreate the same-sized primary surface when
* the display dimensions change.
*/
- if (s_pScreenPriv->dwLastWindowsWidth != LOWORD (lParam)
- || s_pScreenPriv->dwLastWindowsHeight != HIWORD (lParam))
{
/*
* NOTE: The non-DirectDraw engines set the ReleasePrimarySurface
@@ -261,7 +265,7 @@ winWindowProc (HWND hwnd, UINT message,
#if CYGDEBUG
winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions changed\n");
#endif
-
+
/* Release the old primary surface */
(*s_pScreenPriv->pwinReleasePrimarySurface) (s_pScreen);
@@ -286,31 +290,7 @@ winWindowProc (HWND hwnd, UINT message,
}
#endif
}
- else
- {
-#if CYGDEBUG
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions did not "
- "change\n");
-#endif
- }
- /* Store the new display dimensions and depth */
- if (s_pScreenInfo->fMultipleMonitors)
- {
- s_pScreenPriv->dwLastWindowsWidth
- = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- s_pScreenPriv->dwLastWindowsHeight
- = GetSystemMetrics (SM_CYVIRTUALSCREEN);
- }
- else
- {
- s_pScreenPriv->dwLastWindowsWidth
- = GetSystemMetrics (SM_CXSCREEN);
- s_pScreenPriv->dwLastWindowsHeight
- = GetSystemMetrics (SM_CYSCREEN);
- }
- s_pScreenPriv->dwLastWindowsBitsPixel
- = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
break;
case WM_SIZE: