summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2010-02-15 13:42:04 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2011-01-19 14:02:25 +0000
commitbbc511e80b2a9365f6a1528bc1595772f83be654 (patch)
tree8c52469883d4819b999a7a5939c5f758b45b9e80
parent85c497a8b6c488ef9ea2c6d7b49e6f9b992fb4a2 (diff)
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>
-rw-r--r--hw/xwin/winwndproc.c48
1 files 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;