[PATCH 07/13] Cygwin/X: Correctly allow for the native window frame width in ValidateSizing()
Colin Harrison
colin.harrison at virgin.net
Mon Jan 26 06:45:36 PST 2009
Hi,
Jon wrote
>XXX: Needs to allow for different border thickness when window is
uncaptioned?
I found this works for me...
--- ./save_winmultiwindowwndproc.c 2009-01-19 18:42:49.000000000 +0000
+++ ./winmultiwindowwndproc.c 2009-01-19 18:43:30.000000000 +0000
@@ -207,6 +209,7 @@
WinXSizeHints sizeHints;
RECT *rect;
int iWidth, iHeight;
+ unsigned long gwlStyle;
/* Invalid input checking */
if (pWin==NULL || lParam==0)
@@ -228,19 +231,37 @@
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 */
+ gwlStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
+ if (gwlStyle & WS_CAPTION)
+ iHeight -= GetSystemMetrics(SM_CYCAPTION);
+ else
+ {
+ iWidth += 2; /* Small fiddle factors as sizebox appears to be */
+ iHeight += 2; /* not the same thickness with and without a caption */
+ }
+ if (gwlStyle & 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 any borders and title bar */
+ if (gwlStyle & WS_CAPTION)
+ iHeight += GetSystemMetrics(SM_CYCAPTION);
+ else
+ {
+ iWidth -= 2;
+ iHeight -= 2;
+ }
+ if (gwlStyle & WS_SIZEBOX)
+ {
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += 2 * GetSystemMetrics(SM_CYSIZEFRAME);
+ }
/* Adjust size according to where we're dragging from */
switch(wParam) {
Thanks,
Colin
More information about the xorg
mailing list