Cygwin/X: Make WM_SIZE use RandR resizing when -resize=randr

To avoid recursion, WM_SIZE requests shouldn't generate XRANDR requests
when no change is neeeded.

We do the actual resize on WM_EXITSIZEMOVE, as resizing occurs in
a modal loop, to avoid a backlog of resize events building up as
the X server doesn't get a change to process anything until the resize
is completed.

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-15 13:42:04 +00:00
parent 85c497a8b6
commit bbc511e80b

View File

@ -303,7 +303,7 @@ winWindowProc (HWND hwnd, UINT message,
winDebug ("winWindowProc - WM_SIZE\n");
#endif
/* Break if we do not use scrollbars */
/* Break if we do not allow resizing */
if ((s_pScreenInfo->iResizeMode == notAllowed)
|| !s_pScreenInfo->fDecoration
#ifdef XWIN_MULTIWINDOWEXTWM
@ -320,6 +320,17 @@ winWindowProc (HWND hwnd, UINT message,
if (wParam == SIZE_MINIMIZED)
return 0;
ErrorF ("winWindowProc - WM_SIZE - new client area w: %d h: %d\n",
LOWORD (lParam), HIWORD (lParam));
if (s_pScreenInfo->iResizeMode == resizeWithRandr)
{
/* Actual resizing is done on WM_EXITSIZEMOVE */
return 0;
}
/* Otherwise iResizeMode == resizeWithScrollbars */
/*
* Get the size of the whole window, including client area,
* scrollbars, and non-client area decorations (caption, borders).
@ -337,10 +348,6 @@ winWindowProc (HWND hwnd, UINT message,
iWidth = rcWindow.right - rcWindow.left;
iHeight = rcWindow.bottom - rcWindow.top;
ErrorF ("winWindowProc - WM_SIZE - window w: %d h: %d, "
"new client area w: %d h: %d\n",
iWidth, iHeight, LOWORD (lParam), HIWORD (lParam));
/* Subtract the frame size from the window size. */
iWidth -= 2 * GetSystemMetrics (SM_CXSIZEFRAME);
iHeight -= (2 * GetSystemMetrics (SM_CYSIZEFRAME)
@ -396,6 +403,37 @@ winWindowProc (HWND hwnd, UINT message,
}
return 0;
case WM_ENTERSIZEMOVE:
ErrorF("winWindowProc - WM_ENTERSIZEMOVE\n");
break;
case WM_EXITSIZEMOVE:
ErrorF("winWindowProc - WM_EXITSIZEMOVE\n");
if (s_pScreenInfo->iResizeMode == resizeWithRandr)
{
/* Set screen size to match new client area, if it is different to current */
RECT rcClient;
DWORD dwWidth, dwHeight;
GetClientRect (hwnd, &rcClient);
dwWidth = rcClient.right - rcClient.left;
dwHeight = rcClient.bottom - rcClient.top;
if ((s_pScreenInfo->dwWidth != dwWidth) ||
(s_pScreenInfo->dwHeight != dwHeight))
{
/* mm = dots * (25.4 mm / inch) / (dots / inch) */
winDoRandRScreenSetSize(s_pScreen,
dwWidth,
dwHeight,
(dwWidth * 25.4) / monitorResolution,
(dwHeight * 25.4) / monitorResolution);
}
}
break;
case WM_VSCROLL:
{
SCROLLINFO si;