Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Bjarne Kvinge <RKvinge@novell.com>2007-01-23 14:32:30 +0300
committerRolf Bjarne Kvinge <RKvinge@novell.com>2007-01-23 14:32:30 +0300
commitd2c94dc3926c57db520ee703ba85a42a88523c56 (patch)
treedbf93d8c651ec11abe50b37dc24cc2a26e388333
parent902327f91048d0b814d2d1c8e26bf061f33777fa (diff)
2007-01-23 Rolf Bjarne Kvinge <RKvinge@novell.com>
* XplatWin32.cs: In RequestNCRecalc call SetWindowPos with SWP_NOZORDER to prevent it from changing z-order. * MdiWindowManager.cs: Refactor part of SetWindowState to MdiClient, only leave UI updates in MdiWindowManager. * InternalWindowManager.cs: Check for 0 sized nc areas and make them 1 sized (NC handling goes weird on Linux otherwise). * MdiClient.cs: Add missing ExStyle (WS_EX_CLIENTEDGE), so it's no longer necessary to handle WM_NCCALCSIZE anymore. This also made it possible to remove a few NCRequestRecalcs. Changed calculations in IconicBounds to use ClientSize of MdiClient instead of entire size. Refactored ActivateChild and SetWindowState(s) to allow for changing the size of an activated child before activating it (reduces a lot of flicker). svn path=/trunk/mcs/; revision=71507
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog15
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs9
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs129
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs82
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs2
5 files changed, 146 insertions, 91 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
index 9291f078a63..9bcf26e1959 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,18 @@
+2007-01-23 Rolf Bjarne Kvinge <RKvinge@novell.com>
+
+ * XplatWin32.cs: In RequestNCRecalc call SetWindowPos with SWP_NOZORDER
+ to prevent it from changing z-order.
+ * MdiWindowManager.cs: Refactor part of SetWindowState to MdiClient, only
+ leave UI updates in MdiWindowManager.
+ * InternalWindowManager.cs: Check for 0 sized nc areas and make them
+ 1 sized (NC handling goes weird on Linux otherwise).
+ * MdiClient.cs: Add missing ExStyle (WS_EX_CLIENTEDGE), so it's no longer
+ necessary to handle WM_NCCALCSIZE anymore. This also made it possible to
+ remove a few NCRequestRecalcs. Changed calculations in IconicBounds
+ to use ClientSize of MdiClient instead of entire size. Refactored ActivateChild
+ and SetWindowState(s) to allow for changing the size of an activated child
+ before activating it (reduces a lot of flicker).
+
2007-01-22 Jonathan Pobst <monkey@jpobst.com>
* Form.cs: Changing FormBorderStyle has different semantics based
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
index 30783c1bc52..5da9a8ad9e6 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
@@ -225,6 +225,15 @@ namespace System.Windows.Forms {
ncp.rgrc1.right -= bw;
}
+ // This is necessary for Linux, can't handle 0-sized
+ // client areas correctly.
+ if (ncp.rgrc1.right == ncp.rgrc1.left) {
+ ncp.rgrc1.right++;
+ }
+ if (ncp.rgrc1.top == ncp.rgrc1.bottom) {
+ ncp.rgrc1.bottom++;
+ }
+
Marshal.StructureToPtr (ncp, m.LParam, true);
}
}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
index d5367d520a5..eb68ee48300 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
@@ -170,25 +170,6 @@ namespace System.Windows.Forms {
protected override void WndProc(ref Message m) {
switch ((Msg)m.Msg) {
- case Msg.WM_NCCALCSIZE:
- XplatUIWin32.NCCALCSIZE_PARAMS ncp;
-
- if (m.WParam == (IntPtr) 1) {
- ncp = (XplatUIWin32.NCCALCSIZE_PARAMS) Marshal.PtrToStructure (m.LParam,
- typeof (XplatUIWin32.NCCALCSIZE_PARAMS));
-
- int bw = 2;
-
- ncp.rgrc1.top += bw;
- ncp.rgrc1.bottom -= bw;
- ncp.rgrc1.left += bw;
- ncp.rgrc1.right -= bw;
-
- Marshal.StructureToPtr (ncp, m.LParam, true);
- }
-
- break;
-
case Msg.WM_NCPAINT:
PaintEventArgs pe = XplatUI.PaintEventStart (Handle, false);
@@ -263,7 +244,9 @@ namespace System.Windows.Forms {
#region Protected Instance Properties
protected override CreateParams CreateParams {
get {
- return base.CreateParams;
+ CreateParams result = base.CreateParams;
+ result.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
+ return result;
}
}
#endregion // Protected Instance Properties
@@ -554,7 +537,7 @@ namespace System.Windows.Forms {
MdiWindowManager wm = child.WindowManager as MdiWindowManager;
if (wm.GetWindowState () == FormWindowState.Maximized)
- wm.SizeMaximized ();
+ child.Bounds = wm.MaximizedBounds;
if (wm.GetWindowState () == FormWindowState.Minimized) {
child.Top += change;
@@ -568,7 +551,7 @@ namespace System.Windows.Forms {
internal void ArrangeIconicWindows (bool rearrange_all)
{
int xspacing = 160;
- int yspacing = 25;
+ int yspacing = 27;
Rectangle rect = new Rectangle (0, 0, xspacing, yspacing);
@@ -589,15 +572,13 @@ namespace System.Windows.Forms {
// different widths for different styles
int bw = ThemeEngine.Current.ManagedWindowBorderWidth (wm);
- // The extra one pixel is a cheap hack for now until we
- // handle 0 client sizes properly in the driver
- int height = wm.TitleBarHeight + (bw * 2) + 1;
+ int height = wm.TitleBarHeight + (bw * 2);
bool success = true;
int startx, starty, currentx, currenty;
startx = 0;
- starty = Bottom - yspacing - bw - 2;
+ starty = ClientSize.Height - yspacing;
currentx = startx;
currenty = starty;
@@ -641,7 +622,6 @@ namespace System.Windows.Forms {
Controls.Remove (form);
form.Close ();
- XplatUI.RequestNCRecalc (Handle);
if (Controls.Count == 0) {
XplatUI.RequestNCRecalc (Parent.Handle);
ParentForm.PerformLayout ();
@@ -681,13 +661,27 @@ namespace System.Windows.Forms {
if (ParentForm.is_changing_visible_state)
return;
-
+
Form current = (Form) Controls [0];
- form.SuspendLayout ();
+
+ // We want to resize the new active form before it is
+ // made active to avoid flickering. Can't do it in the
+ // normal way (form.WindowState = Maximized) since it's not
+ // active yet and everything would just return to before.
+ // We also won't suspend layout, this way the layout will
+ // happen before the form is made active (and in many cases
+ // before it is visible, which avoids flickering as well).
+ MdiWindowManager wm = (MdiWindowManager)form.WindowManager;
+ if (current.WindowState == FormWindowState.Maximized && form.WindowState != FormWindowState.Maximized && form.Visible) {
+ FormWindowState old_state = form.window_state;
+ SetWindowState (form, old_state, FormWindowState.Maximized, true);
+ wm.was_minimized = form.window_state == FormWindowState.Minimized;
+ form.window_state = FormWindowState.Maximized;
+ SetParentText (false);
+ }
form.BringToFront ();
form.SendControlFocus (form);
- form.ResumeLayout(false);
- SetWindowStates ((MdiWindowManager) form.window_manager);
+ SetWindowStates (wm);
if (current != form) {
form.has_focus = false;
XplatUI.InvalidateNC (current.Handle);
@@ -741,6 +735,9 @@ namespace System.Windows.Forms {
if (!is_active){
return false;
}
+
+ ArrayList minimize_these = new ArrayList ();
+ ArrayList normalize_these = new ArrayList ();
setting_windowstates = true;
foreach (Form frm in mdi_child_list) {
@@ -751,19 +748,29 @@ namespace System.Windows.Forms {
}
if (frm.WindowState == FormWindowState.Maximized && is_active) {
maximize_this = true;
- if (((MdiWindowManager) frm.window_manager).was_minimized)
- frm.WindowState = FormWindowState.Minimized;
- else
- frm.WindowState = FormWindowState.Normal;//
+ if (((MdiWindowManager) frm.window_manager).was_minimized) {
+ minimize_these.Add (frm);
+ } else {
+ normalize_these.Add (frm);
+ }
}
}
- if (maximize_this) {
+
+ if (maximize_this && form.WindowState != FormWindowState.Maximized) {
wm.was_minimized = form.window_state == FormWindowState.Minimized;
form.WindowState = FormWindowState.Maximized;
}
- SetParentText(false);
- XplatUI.RequestNCRecalc(ParentForm.Handle);
+ foreach (Form frm in minimize_these)
+ frm.WindowState = FormWindowState.Minimized;
+
+ foreach (Form frm in normalize_these)
+ frm.WindowState = FormWindowState.Normal;
+
+
+ SetParentText (false);
+
+ XplatUI.RequestNCRecalc (ParentForm.Handle);
XplatUI.RequestNCRecalc (Handle);
SizeScrollBars ();
@@ -778,6 +785,52 @@ namespace System.Windows.Forms {
return maximize_this;
}
+ internal void SetWindowState (Form form, FormWindowState old_window_state, FormWindowState new_window_state, bool is_activating_child)
+ {
+ bool mdiclient_layout;
+
+ MdiWindowManager wm = (MdiWindowManager) form.window_manager;
+
+ if (!is_activating_child && new_window_state == FormWindowState.Maximized && !wm.IsActive ()) {
+ ActivateChild (form);
+ return;
+ }
+
+ if (SetWindowStates (wm))
+ return;
+
+ if (old_window_state == new_window_state)
+ return;
+
+ if (old_window_state == FormWindowState.Normal)
+ wm.NormalBounds = form.Bounds;
+
+ mdiclient_layout = old_window_state == FormWindowState.Maximized || new_window_state == FormWindowState.Maximized;
+
+ switch (new_window_state) {
+ case FormWindowState.Minimized:
+ ArrangeIconicWindows (false);
+ break;
+ case FormWindowState.Maximized:
+ form.Bounds = wm.MaximizedBounds;
+ break;
+ case FormWindowState.Normal:
+ form.Bounds = wm.NormalBounds;
+ break;
+ }
+
+ wm.UpdateWindowDecorations (new_window_state);
+
+ form.ResetCursor ();
+
+ if (mdiclient_layout)
+ Parent.PerformLayout ();
+
+ //XplatUI.RequestNCRecalc (Parent.Handle);
+ //XplatUI.RequestNCRecalc (form.Handle);
+ if (!setting_windowstates)
+ SizeScrollBars ();
+ }
internal int ChildrenCreated {
get { return mdi_created; }
set { mdi_created = value; }
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
index 13191131e83..dcc4daad137 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
@@ -38,7 +38,6 @@ namespace System.Windows.Forms {
private MainMenu maximized_menu;
private MenuItem icon_menu;
private ContextMenu icon_popup_menu;
- private FormWindowState prev_window_state;
internal bool was_minimized;
private PaintEventHandler draw_maximized_buttons;
@@ -46,14 +45,36 @@ namespace System.Windows.Forms {
private MdiClient mdi_container;
private Rectangle prev_virtual_position;
- private Rectangle prev_bounds;
-
+ private Rectangle normal_bounds;
private Rectangle iconic_bounds;
private Point icon_clicked;
private DateTime icon_clicked_time;
private bool icon_dont_show_popup;
+ internal Rectangle MaximizedBounds {
+ get {
+ Rectangle pb = mdi_container.ClientRectangle;
+ int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
+ int tw = TitleBarHeight;
+
+ Rectangle new_bounds = new Rectangle (pb.Left - bw,
+ pb.Top - tw - bw,
+ pb.Width + bw * 2,
+ pb.Height + tw + bw * 2);
+ return new_bounds;
+ }
+ }
+
+ internal Rectangle NormalBounds {
+ get {
+ return normal_bounds;
+ }
+ set {
+ normal_bounds = value;
+ }
+ }
+
internal Rectangle IconicBounds {
get {
if (iconic_bounds == Rectangle.Empty)
@@ -71,8 +92,8 @@ namespace System.Windows.Forms {
public MdiWindowManager (Form form, MdiClient mdi_container) : base (form)
{
this.mdi_container = mdi_container;
- prev_bounds = form.Bounds;
- prev_window_state = form.window_state;
+ if (form.WindowState == FormWindowState.Normal)
+ normal_bounds = form.Bounds;
form_closed_handler = new EventHandler (FormClosed);
form.Closed += form_closed_handler;
form.TextChanged += new EventHandler (FormTextChangedHandler);
@@ -109,14 +130,11 @@ namespace System.Windows.Forms {
{
if (form.window_state == FormWindowState.Minimized)
IconicBounds = form.Bounds;
- XplatUI.RequestNCRecalc (mdi_container.Handle);
form.MdiParent.MdiContainer.SizeScrollBars ();
}
private void FormSizeChangedHandler (object sender, EventArgs e)
{
- XplatUI.RequestNCRecalc (form.MdiParent.MdiContainer.Handle);
- XplatUI.RequestNCRecalc (form.Handle);
form.MdiParent.MdiContainer.SizeScrollBars ();
}
@@ -306,72 +324,33 @@ namespace System.Windows.Forms {
XplatUI.ClientToScreen (mdi_container.Handle, ref x, ref y);
}
- public override void SetWindowState (FormWindowState old_state, FormWindowState window_state)
+ public void UpdateWindowDecorations (FormWindowState window_state)
{
- bool mdiclient_layout;
-
- if (this.mdi_container.SetWindowStates (this))
- return;
-
- if (prev_window_state == window_state)
- return;
-
- if (prev_window_state == FormWindowState.Normal)
- prev_bounds = form.Bounds;
-
- mdiclient_layout = prev_window_state == FormWindowState.Maximized || window_state == FormWindowState.Maximized;
+ CreateButtons ();
switch (window_state) {
case FormWindowState.Minimized:
- CreateButtons ();
maximize_button.Caption = CaptionButton.Maximize;
minimize_button.Caption = CaptionButton.Restore;
- prev_window_state = FormWindowState.Minimized;
- mdi_container.ArrangeIconicWindows (false);
MaximizedMenu.Paint -= draw_maximized_buttons;
break;
case FormWindowState.Maximized:
- if (mdi_container.ActiveMdiChild != form)
- mdi_container.ActivateChild (form);
- CreateButtons ();
maximize_button.Caption = CaptionButton.Restore;
minimize_button.Caption = CaptionButton.Minimize;
- prev_window_state = FormWindowState.Maximized;
- SizeMaximized ();
MaximizedMenu.Paint += draw_maximized_buttons;
break;
case FormWindowState.Normal:
- CreateButtons ();
maximize_button.Caption = CaptionButton.Maximize;
minimize_button.Caption = CaptionButton.Minimize;
- form.Bounds = prev_bounds;
- prev_window_state =FormWindowState.Normal;
-
MaximizedMenu.Paint -= draw_maximized_buttons;
break;
}
-
- form.ResetCursor ();
-
- if (mdiclient_layout)
- mdi_container.Parent.PerformLayout ();
-
- XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
XplatUI.RequestNCRecalc (form.Handle);
- mdi_container.SizeScrollBars ();
}
- internal void SizeMaximized ()
+ public override void SetWindowState (FormWindowState old_state, FormWindowState window_state)
{
- Rectangle pb = mdi_container.ClientRectangle;
- int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
- int tw = TitleBarHeight;
-
- Rectangle new_bounds = new Rectangle (pb.Left - bw,
- pb.Top - tw - bw,
- pb.Width + bw * 2,
- pb.Height + tw + bw * 2);
- form.Bounds = new_bounds;
+ mdi_container.SetWindowState (form, old_state, window_state, true);
}
private void FormClosed (object sender, EventArgs e)
@@ -618,7 +597,6 @@ namespace System.Windows.Forms {
{
if (mdi_container.ActiveMdiChild != form) {
mdi_container.ActivateChild (form);
- mdi_container.SetWindowStates (this);
}
base.Activate ();
}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
index a388e3f6bd1..48ffe3846a1 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
@@ -1527,7 +1527,7 @@ namespace System.Windows.Forms {
}
internal override void RequestNCRecalc(IntPtr handle) {
- Win32SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_NOOWNERZORDER | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOMOVE);
+ Win32SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_NOOWNERZORDER | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOZORDER);
}
internal override void ResetMouseHover(IntPtr handle) {