From 7d22ab298c5b567d62aa9e0478a5f344e2fd9848 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 17 Apr 2007 09:43:17 +0000 Subject: [PATCH] * XplatUIX11.cs: When setting min/max size for a window we need to translate the coordinates to x coordinates. Create an overload of SetWindowMinMax that takes a CreateParams handling this, and change SetWMStyles to call this function (can't use Control.FromHandle in the SetWindowMinMax to get the control/CreateParams from the handle because the handle might not have been assigned to the control yet). Fixes #81371. svn path=/trunk/mcs/; revision=75811 --- .../System.Windows.Forms/ChangeLog | 10 +++++++++ .../System.Windows.Forms/XplatUIX11.cs | 21 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index ff944af06e9..a615d8e69e0 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,13 @@ +2007-04-17 Rolf Bjarne Kvinge + + * XplatUIX11.cs: When setting min/max size for a window we need to + translate the coordinates to x coordinates. Create an overload of + SetWindowMinMax that takes a CreateParams handling this, and change + SetWMStyles to call this function (can't use Control.FromHandle in + the SetWindowMinMax to get the control/CreateParams from the handle + because the handle might not have been assigned to the control + yet). Fixes #81371. + 2007-04-16 Carlos Alberto Cortez * ListView.cs: In ItemControl.ItemMouseDown, don't change check state diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs index 28b432225ce..eb73f0f8a23 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs @@ -1035,7 +1035,8 @@ namespace System.Windows.Forms { if ((functions & MotifFunctions.Resize) == 0) { hwnd.fixed_size = true; - XplatUI.SetWindowMinMax(hwnd.Handle, new Rectangle(cp.X, cp.Y, cp.Width, cp.Height), new Size(cp.Width, cp.Height), new Size(cp.Width, cp.Height)); + Rectangle fixed_rectangle = new Rectangle (cp.X, cp.Y, cp.Width, cp.Height); + SetWindowMinMax(hwnd.Handle, fixed_rectangle, fixed_rectangle.Size, fixed_rectangle.Size, cp); } else { hwnd.fixed_size = false; } @@ -1043,6 +1044,10 @@ namespace System.Windows.Forms { mwmHints.functions = (IntPtr)functions; mwmHints.decorations = (IntPtr)decorations; +#if debug + Console.WriteLine ("SetWMStyles ({0}, {1}) functions = {2}, decorations = {3}", hwnd, cp, functions, decorations); +#endif + if (cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW)) { // needed! map toolwindows to _NET_WM_WINDOW_TYPE_UTILITY to make newer metacity versions happy // and get those windows in front of their parents @@ -1299,7 +1304,7 @@ namespace System.Windows.Forms { hwnd.ClientRect = Rectangle.Empty; #if debug - Console.WriteLine ("AddConfigureNotify (hwnd.Handle = {1}, hwnd.rect = {0})", new Rectangle (hwnd.x, hwnd.y, hwnd.width, hwnd.height), hwnd.Handle); + Console.WriteLine ("AddConfigureNotify (hwnd.Handle = {1}, final hwnd.rect = {0}, reported rect={2})", new Rectangle (hwnd.x, hwnd.y, hwnd.width, hwnd.height), hwnd.Handle, new Rectangle (xevent.ConfigureEvent.x, xevent.ConfigureEvent.y, xevent.ConfigureEvent.width, xevent.ConfigureEvent.width)); #endif lock (hwnd.configure_lock) { if (!hwnd.configure_pending) { @@ -5161,6 +5166,12 @@ namespace System.Windows.Forms { } internal override void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) { + Control ctrl = Control.FromHandle (handle); + SetWindowMinMax (handle, maximized, min, max, ctrl != null ? ctrl.GetCreateParams () : null); + } + + internal void SetWindowMinMax (IntPtr handle, Rectangle maximized, Size min, Size max, CreateParams cp) + { Hwnd hwnd; XSizeHints hints; IntPtr dummy; @@ -5174,12 +5185,16 @@ namespace System.Windows.Forms { XGetWMNormalHints(DisplayHandle, hwnd.whole_window, ref hints, out dummy); if ((min != Size.Empty) && (min.Width > 0) && (min.Height > 0)) { + if (cp != null) + min = TranslateWindowSizeToXWindowSize (cp); hints.flags = (IntPtr)((int)hints.flags | (int)XSizeHintsFlags.PMinSize); hints.min_width = min.Width; hints.min_height = min.Height; } if ((max != Size.Empty) && (max.Width > 0) && (max.Height > 0)) { + if (cp != null) + max = TranslateWindowSizeToXWindowSize (cp); hints.flags = (IntPtr)((int)hints.flags | (int)XSizeHintsFlags.PMaxSize); hints.max_width = max.Width; hints.max_height = max.Height; @@ -5193,6 +5208,8 @@ namespace System.Windows.Forms { } if ((maximized != Rectangle.Empty) && (maximized.Width > 0) && (maximized.Height > 0)) { + if (cp != null) + maximized.Size = TranslateWindowSizeToXWindowSize (cp); hints.flags = (IntPtr)XSizeHintsFlags.PPosition; hints.x = maximized.X; hints.y = maximized.Y; -- 2.25.1