From bbc511e80b2a9365f6a1528bc1595772f83be654 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 15 Feb 2010 13:42:04 +0000 Subject: [PATCH] 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 Reviewed-by: Colin Harrison Tested-by: Colin Harrison --- hw/xwin/winwndproc.c | 48 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 27fc840b5..04a3a6b86 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -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;