[PATCH 03/12] Cygwin/X: Correctly allow for the native window frame width in ValidateSizing()

Jon TURNEY jon.turney at dronecode.org.uk
Wed May 20 04:52:21 PDT 2009


Fix internal WM to correctly calculate the native window border when validating window sizing

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 hw/xwin/winmultiwindowwndproc.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index b5e789c..0dd8885 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -207,6 +207,8 @@ ValidateSizing (HWND hwnd, WindowPtr pWin,
   WinXSizeHints sizeHints;
   RECT *rect;
   int iWidth, iHeight;
+  RECT rcClient, rcWindow;
+  int iBorderWidthX, iBorderWidthY;
 
   /* Invalid input checking */
   if (pWin==NULL || lParam==0)
@@ -228,19 +230,20 @@ ValidateSizing (HWND hwnd, WindowPtr pWin,
   iWidth = rect->right - rect->left;
   iHeight = rect->bottom - rect->top;
 
-  /* Now remove size of any borders */
-  iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
-  iHeight -= (GetSystemMetrics(SM_CYCAPTION)
-	      + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
-	      
+  /* Now remove size of any borders and title bar */
+  GetClientRect(hwnd, &rcClient);
+  GetWindowRect(hwnd, &rcWindow);
+  iBorderWidthX = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left);
+  iBorderWidthY = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
+  iWidth -= iBorderWidthX;
+  iHeight -= iBorderWidthY;
 
   /* Constrain the size to legal values */
   ConstrainSize (sizeHints, &iWidth, &iHeight);
 
-  /* Add back the borders */
-  iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
-  iHeight += (GetSystemMetrics(SM_CYCAPTION)
-	      + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
+  /* Add back the size of borders and title bar */
+  iWidth += iBorderWidthX;
+  iHeight += iBorderWidthY;
 
   /* Adjust size according to where we're dragging from */
   switch(wParam) {
-- 
1.6.1.2



More information about the xorg-devel mailing list