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

Jon TURNEY jon.turney at dronecode.org.uk
Wed Jan 7 12:04:02 PST 2009


Fix internal WM to correctly use the current native window style in determining
the native window border when validating window sizing

XXX: Needs to allow for different border thickness when window is uncaptioned?

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

diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 8d8a906..df0f856 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -208,6 +208,7 @@ ValidateSizing (HWND hwnd, WindowPtr pWin,
   WinXSizeHints sizeHints;
   RECT *rect;
   int iWidth, iHeight;
+  unsigned long rcStyle;
 
   /* Invalid input checking */
   if (pWin==NULL || lParam==0)
@@ -229,19 +230,31 @@ 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 */
+  rcStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
+  if (rcStyle & WS_CAPTION)
+    {
+      iHeight -= GetSystemMetrics(SM_CYCAPTION);
+    }
+  if (rcStyle & WS_SIZEBOX)
+    {
+      iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+      iHeight -= 2 * GetSystemMetrics(SM_CYSIZEFRAME);
+    }
 
   /* 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 */
+  if (rcStyle & WS_CAPTION)
+    {
+      iHeight += GetSystemMetrics(SM_CYCAPTION);
+    }
+  if (rcStyle & WS_SIZEBOX)
+    {
+      iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+      iHeight += 2 * GetSystemMetrics(SM_CYSIZEFRAME);
+    }
 
   /* Adjust size according to where we're dragging from */
   switch(wParam) {
-- 
1.6.0.4




More information about the xorg mailing list