This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Cygwin/X: Make transient windows resizable again


Reverts the change which makes parented windows non-resizeable

Because this was trying to do something which we should be doing, as an alternative we
try checking WM_NORMAL_HINTS for windows which shouldn't  be resizable

If a window has a maximum size specified, no maximize box
If a window has a fixed size (max size == min size, per EWMH 1.3 Implementation Notes), no resizing frame

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
 hw/xwin/winmultiwindowwm.c |   41 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index ef94335..06fc599 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1551,6 +1551,7 @@ winDeinitMultiWindowWM (void)
 #define HINT_BORDER	(1L<<1)
 #define HINT_SIZEBOX	(1l<<2)
 #define HINT_CAPTION	(1l<<3)
+#define HINT_NOMAXIMIZE (1L<<4)
 /* These two are used on their own */
 #define HINT_MAX	(1L<<0)
 #define HINT_MIN	(1L<<1)
@@ -1632,7 +1633,30 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
     if (pAtom) XFree(pAtom);
   }
 
-  /* Apply Styles, overriding hint settings from above */
+  XSizeHints *normal_hint = XAllocSizeHints();
+  long supplied;
+  if (normal_hint && (XGetWMNormalHints(pDisplay, iWindow, normal_hint, &supplied) == Success))
+    {
+      if (normal_hint->flags & PMaxSize)
+	{
+	  /* Not maximizable if a maximum size is specified */
+	  hint |= HINT_NOMAXIMIZE;
+
+	  if (normal_hint->flags & PMinSize)
+	    {
+	      /*
+                If both minimum size and maximum size are specified and are the same,
+                don't bother with a resizing frame
+	      */
+	      if ((normal_hint->min_width == normal_hint->max_width)
+		  && (normal_hint->min_height == normal_hint->max_height))
+                hint = (hint & ~HINT_SIZEBOX);
+	    }
+	}
+    }
+  XFree(normal_hint);
+
+  /* Override hint settings from above with settings from config file */
   style = winOverrideStyle((unsigned long)pWin);
   if (style & STYLE_TOPMOST) *zstyle = HWND_TOPMOST;
   else if (style & STYLE_MAXIMIZE) maxmin = (hint & ~HINT_MIN) | HINT_MAX;
@@ -1649,14 +1673,21 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
   else if (style & STYLE_NOFRAME)
 	hint = (hint & ~HINT_BORDER & ~HINT_CAPTION & ~HINT_SIZEBOX) | HINT_NOFRAME;
 
+  /* Now apply styles to window */
   style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
   if (!style) return;
-  if (!hint) /* All on, but no resize of children is allowed */
-    style = style | WS_CAPTION | (GetParent(hWnd) ? 0 : WS_SIZEBOX);
-  else if (hint & HINT_NOFRAME); /* All off, so do nothing */
+
+  if (!hint) /* All on */
+    style = style | WS_CAPTION | WS_SIZEBOX;
+  else if (hint & HINT_NOFRAME) /* All off */
+    style = style & ~WS_CAPTION & ~WS_SIZEBOX;
   else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
-		((hint & HINT_SIZEBOX) ? (GetParent(hWnd) ? 0 : WS_SIZEBOX) : 0) |
+		((hint & HINT_SIZEBOX) ? WS_SIZEBOX : 0) |
 		((hint & HINT_CAPTION) ? WS_CAPTION : 0);
+
+  if (hint & HINT_NOMAXIMIZE)
+    style = style & ~WS_MAXIMIZEBOX;
+
   SetWindowLongPtr (hWnd, GWL_STYLE, style);
 }
 
-- 
1.6.4.2


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]