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>
This commit is contained in:
Jon TURNEY 2010-02-12 12:29:30 +00:00
parent a46146af5f
commit 73b02e9647
4 changed files with 31 additions and 69 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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);
@ -284,33 +288,9 @@ winWindowProc (HWND hwnd, UINT message,
{
RRSetScreenConfig ();
}
#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: