Author: pbartok
Date: 2005-03-08 03:11:55 -0500 (Tue, 08 Mar 2005)
New Revision: 41550

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
2005-03-07  Peter Bartok  <[EMAIL PROTECTED]>

        * Hwnd.cs: Added DefaultClientRectangle property
        * XplatUI.cs: Now using the X11 driver Where() method, which provides
          more detailed debug information
        * XplatUIX11.cs: 
          - Fixed size-change feedback loop, where we would pull an old size 
            off the queue and mistakenly change our window's size to an 
            earlier value
          - Now compressing ConfigureNotify events, to reduce looping and 
            redraw issues
        * TextBoxBase.cs: Preventing crash when no text is set and ToString()
          is called



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-08 06:15:47 UTC (rev 41549)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-03-08 08:11:55 UTC (rev 41550)
@@ -1,3 +1,17 @@
+2005-03-07  Peter Bartok  <[EMAIL PROTECTED]>
+
+       * Hwnd.cs: Added DefaultClientRectangle property
+       * XplatUI.cs: Now using the X11 driver Where() method, which provides
+         more detailed debug information
+       * XplatUIX11.cs: 
+         - Fixed size-change feedback loop, where we would pull an old size 
+           off the queue and mistakenly change our window's size to an 
+           earlier value
+         - Now compressing ConfigureNotify events, to reduce looping and 
+           redraw issues
+       * TextBoxBase.cs: Preventing crash when no text is set and ToString()
+         is called
+
 2005-03-07  Jackson Harper  <[EMAIL PROTECTED]>
 
        * Binding.cs: Push data pushes from data -> property. Check if the

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs  
2005-03-08 06:15:47 UTC (rev 41549)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs  
2005-03-08 08:11:55 UTC (rev 41550)
@@ -33,7 +33,7 @@
 
 // NOTE: Possible optimization:
 // Several properties calculate dimensions on the fly; instead; they can 
-// be stored in a field and only be recalculated when a style is changed
+// be stored in a field and only be recalculated when a style is changed 
(DefaultClientRect, for example)
 
 namespace System.Windows.Forms {
        internal class Hwnd : IDisposable {
@@ -59,6 +59,7 @@
                internal Rectangle      invalid;
                internal bool           expose_pending;
                internal bool           nc_expose_pending;
+               internal bool           configure_pending;
                internal Graphics       client_dc;
                internal object         user_data;
                internal Rectangle      client_rectangle;
@@ -215,39 +216,9 @@
                public Rectangle ClientRect {
                        get {
                                if (client_rectangle == Rectangle.Empty) {
-                                       Rectangle rect;
-
-                                       rect = new Rectangle(0, 0, width, 
height);
-
-                                       if (menu_handle != IntPtr.Zero) {
-                                               rect.Y += menu_height;
-                                               rect.Height -= menu_height;
-                                       }
-
-                                       if (border_style == 
BorderStyle.Fixed3D) {
-                                               rect.X += 2;
-                                               rect.Y += 2;
-                                               rect.Width -= 4;
-                                               rect.Height -= 4;
-                                       } else if (border_style == 
BorderStyle.FixedSingle) {
-                                               rect.X += 1;
-                                               rect.Y += 1;
-                                               rect.Width -= 2;
-                                               rect.Height -= 2;
-                                       }
-
-                                       if (this.title_style == 
TitleStyle.Normal)  {
-                                               rect.Y += caption_height;
-                                               rect.Height -= caption_height;
-                                       } else if (this.title_style == 
TitleStyle.Normal)  {
-                                               rect.Y += tool_caption_height;
-                                               rect.Height -= 
tool_caption_height;
-                                       }
-
-                                       return rect;
-                               } else {
-                                       return client_rectangle;
+                                       return DefaultClientRect;
                                }
+                               return client_rectangle;
                        }
 
                        set {
@@ -270,6 +241,41 @@
                        }
                }
 
+               public Rectangle DefaultClientRect {
+                       get {
+                               Rectangle rect;
+
+                               rect = new Rectangle(0, 0, width, height);
+
+                               if (menu_handle != IntPtr.Zero) {
+                                       rect.Y += menu_height;
+                                       rect.Height -= menu_height;
+                               }
+
+                               if (border_style == BorderStyle.Fixed3D) {
+                                       rect.X += 2;
+                                       rect.Y += 2;
+                                       rect.Width -= 4;
+                                       rect.Height -= 4;
+                               } else if (border_style == 
BorderStyle.FixedSingle) {
+                                       rect.X += 1;
+                                       rect.Y += 1;
+                                       rect.Width -= 2;
+                                       rect.Height -= 2;
+                               }
+
+                               if (this.title_style == TitleStyle.Normal)  {
+                                       rect.Y += caption_height;
+                                       rect.Height -= caption_height;
+                               } else if (this.title_style == 
TitleStyle.Normal)  {
+                                       rect.Y += tool_caption_height;
+                                       rect.Height -= tool_caption_height;
+                               }
+
+                               return rect;
+                       }
+               }
+
                public Border3DStyle EdgeStyle {
                        get {
                                return edge_style;

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2005-03-08 06:15:47 UTC (rev 41549)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2005-03-08 08:11:55 UTC (rev 41550)
@@ -608,6 +608,10 @@
                        int             i;
                        int             end;
 
+                       if (document == null) {
+                               return String.Empty;
+                       }
+
                        sb = new StringBuilder();
 
                        end = document.Lines;

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs       
2005-03-08 06:15:47 UTC (rev 41549)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs       
2005-03-08 08:11:55 UTC (rev 41550)
@@ -686,7 +686,7 @@
                }
 
                internal static void Where() {
-                       Console.WriteLine("Here: {0}", new 
StackTrace().ToString());
+                       XplatUIX11.Where();
                }
                #endregion      // Public Static Methods
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2005-03-08 06:15:47 UTC (rev 41549)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs    
2005-03-08 08:11:55 UTC (rev 41550)
@@ -37,16 +37,17 @@
 // NOT COMPLETE
 
 // define to log Window handles and relationships to stdout
-#define DriverDebug
+#undef DriverDebug
 
 // Extra detailed debug
-#define        DriverDebugExtra
+#undef DriverDebugExtra
 
 using System;
 using System.ComponentModel;
 using System.Collections;
 using System.Diagnostics;
 using System.Drawing;
+using System.IO;
 using System.Net;
 using System.Net.Sockets;
 using System.Reflection;
@@ -342,7 +343,7 @@
                        newline = String.Format("{0}\t {1} ", 
Environment.NewLine, Locale.GetText("at"));
                        unknown = Locale.GetText("<unknown method>");
                        sb = new StringBuilder();
-                       stack = new StackTrace();
+                       stack = new StackTrace(true);
 
                        for (int i = 0; i < stack.FrameCount; i++) {
                                frame = stack.GetFrame(i);
@@ -353,9 +354,8 @@
                                        #if not
                                                
sb.AppendFormat(frame.ToString());
                                        #endif
-
                                        if (frame.GetFileLineNumber() != 0) {
-                                               sb.AppendFormat("{0}.{1} () 
[{2}:{3}]", method.DeclaringType.FullName, method.Name, frame.GetFileName(), 
frame.GetFileLineNumber());
+                                               sb.AppendFormat("{0}.{1} () 
[{2}:{3}]", method.DeclaringType.FullName, method.Name, 
Path.GetFileName(frame.GetFileName()), frame.GetFileLineNumber());
                                        } else {
                                                sb.AppendFormat("{0}.{1} ()", 
method.DeclaringType.FullName, method.Name);
                                        }
@@ -564,7 +564,7 @@
                        mwmHints.decorations = (IntPtr)decorations;
 
 
-                       client_rect= hwnd.ClientRect;
+                       client_rect = hwnd.ClientRect;
                        lock (XlibLock) {
                                XChangeProperty(DisplayHandle, 
hwnd.whole_window, NetAtoms[(int)NA._MOTIF_WM_HINTS], 
NetAtoms[(int)NA._MOTIF_WM_HINTS], 32, PropertyMode.Replace, ref mwmHints, 5);
 
@@ -596,6 +596,7 @@
                private void WakeupMain () {
                        wake.BeginSend (new byte [] { 0xFF }, 0, 1, 
SocketFlags.None, null, null);
                }
+
                private void AddExpose (XEvent xevent) {
                        Hwnd    hwnd;
 
@@ -620,6 +621,39 @@
                                }
                        }
                }
+
+               private void AddConfigureNotify (XEvent xevent) {
+                       Hwnd    hwnd;
+
+                       hwnd = 
Hwnd.GetObjectFromWindow(xevent.ConfigureEvent.window);
+
+                       // Don't waste time
+                       if (hwnd == null) {
+                               return;
+                       }
+
+                       if (xevent.ConfigureEvent.window == hwnd.whole_window) {
+                               if (hwnd.parent != null) {
+                                       hwnd.x = xevent.ConfigureEvent.x;
+                                       hwnd.y = xevent.ConfigureEvent.y;
+                               } else {
+                                       IntPtr  child;
+
+                                       // We need to 'discount' the window the 
WM has put us in
+                                       XTranslateCoordinates(DisplayHandle, 
XGetParent(hwnd.whole_window), RootWindow, xevent.ConfigureEvent.x, 
xevent.ConfigureEvent.y, out hwnd.x, out hwnd.y, out child);
+                               }
+
+                               hwnd.width = xevent.ConfigureEvent.width;
+                               hwnd.height = xevent.ConfigureEvent.height;
+
+                               if (!hwnd.configure_pending) {
+                                       MessageQueue.Enqueue(xevent);
+                                       hwnd.configure_pending = true;
+                               }
+                       }
+                       // We drop configure events for Client windows
+               }
+
                private void ShowCaret() {
                        if ((Caret.gc == IntPtr.Zero) || Caret.On) {
                                return;
@@ -748,7 +782,6 @@
                                        case XEventName.EnterNotify:
                                        case XEventName.LeaveNotify:
                                        case XEventName.CreateNotify:
-                                       case XEventName.ConfigureNotify:
                                        case XEventName.DestroyNotify:
                                        case XEventName.FocusIn:
                                        case XEventName.FocusOut:
@@ -756,6 +789,10 @@
                                                MessageQueue.Enqueue (xevent);
                                                break;
 
+                                       case XEventName.ConfigureNotify:
+                                               AddConfigureNotify(xevent);
+                                               break;
+
                                        case XEventName.PropertyNotify:
                                                if (xevent.PropertyEvent.atom 
== NetAtoms[(int)NA._NET_ACTIVE_WINDOW]) {
                                                        Atom    actual_atom;
@@ -2065,27 +2102,12 @@
                                                #if DriverDebugExtra
                                                        
Console.WriteLine("GetMessage(): Window {0:X} ConfigureNotify x={1} y={2} 
width={3} height={4}", hwnd.client_window.ToInt32(), xevent.ConfigureEvent.x, 
xevent.ConfigureEvent.y, xevent.ConfigureEvent.width, 
xevent.ConfigureEvent.height);
                                                #endif
+                                               msg.message = 
Msg.WM_WINDOWPOSCHANGED;
+                                               hwnd.configure_pending = false;
 
-                                               if ((hwnd.x != 
xevent.ConfigureEvent.x) || (hwnd.y != xevent.ConfigureEvent.y) ||
-                                                       (hwnd.width != 
xevent.ConfigureEvent.width) || (hwnd.height != xevent.ConfigureEvent.height)) {
-                                                       
msg.message=Msg.WM_WINDOWPOSCHANGED;
+                                               // We need to adjust our client 
window to track the resize of whole_window
+                                               rect = hwnd.DefaultClientRect;
 
-                                                       if (hwnd.parent != 
null) {
-                                                               hwnd.x = 
xevent.ConfigureEvent.x;
-                                                               hwnd.y = 
xevent.ConfigureEvent.y;
-                                                       } else {
-                                                               IntPtr  child;
-                                                               // We need to 
'discount' the window the WM has put us in
-                                                               
XTranslateCoordinates(DisplayHandle, XGetParent(hwnd.whole_window), RootWindow, 
xevent.ConfigureEvent.x, xevent.ConfigureEvent.y, out hwnd.x, out hwnd.y, out 
child);
-                                                       }
-                                                       hwnd.width = 
xevent.ConfigureEvent.width;
-                                                       hwnd.height = 
xevent.ConfigureEvent.height;
-                                               } else {
-                                                       goto ProcessNextMessage;
-                                               }
-
-                                               // We need to adjust our client 
window to track the resize of whole_window
-                                               rect = hwnd.ClientRect;
                                                ncp = new 
XplatUIWin32.NCCALCSIZE_PARAMS();
                                                ptr = 
Marshal.AllocHGlobal(Marshal.SizeOf(ncp));
 
@@ -2099,14 +2121,16 @@
                                                ncp = 
(XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(ptr, 
typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
                                                Marshal.FreeHGlobal(ptr);
 
-                                               hwnd.ClientRect = new 
Rectangle(ncp.rgrc1.left, ncp.rgrc1.top, ncp.rgrc1.right - ncp.rgrc1.left, 
ncp.rgrc1.bottom - ncp.rgrc1.top);
+                                               // FIXME - debug this with 
Menus, need to set hwnd.ClientRect
 
+                                               rect = new 
Rectangle(ncp.rgrc1.left, ncp.rgrc1.top, ncp.rgrc1.right - ncp.rgrc1.left, 
ncp.rgrc1.bottom - ncp.rgrc1.top);
+
                                                
XMoveResizeWindow(DisplayHandle, hwnd.client_window, rect.X, rect.Y, 
rect.Width, rect.Height);
                                        } else {
                                                goto ProcessNextMessage;
                                        }
 
-                                       msg.lParam=IntPtr.Zero;         // 
FIXME - Generated LPWINDOWPOS structure and pass
+                                       msg.lParam=IntPtr.Zero;         // 
FIXME - Generate LPWINDOWPOS structure and pass on
                                        break;
                                }
 
@@ -2354,7 +2378,7 @@
                }
 
                internal override void HandleException(Exception e) {
-                       StackTrace st = new StackTrace(e);
+                       StackTrace st = new StackTrace(e, true);
                        Console.WriteLine("Exception '{0}'", 
e.Message+st.ToString());
                        Console.WriteLine("{0}{1}", e.Message, st.ToString());
                }
@@ -2759,7 +2783,6 @@
                        Rectangle       client_rect;
 
                        hwnd = Hwnd.ObjectFromHandle(handle);
-
                        // Save a server roundtrip (and prevent a feedback loop)
                        if ((hwnd.x == x) && (hwnd.y == y) && (hwnd.width == 
width) && (hwnd.height == height)) {
                                return;
@@ -2780,6 +2803,10 @@
                                XMoveResizeWindow(DisplayHandle, 
hwnd.whole_window, x, y, width, height);
                                XMoveResizeWindow(DisplayHandle, 
hwnd.client_window, client_rect.X, client_rect.Y, client_rect.Width, 
client_rect.Height);
                        }
+
+                       // Prevent an old queued ConfigureNotify from setting 
our width with outdated data, set it now
+                       hwnd.width = width;
+                       hwnd.height = height;
                }
 
                internal override void SetWindowState(IntPtr handle, 
FormWindowState state) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to