2007-03-12 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Mon, 12 Mar 2007 20:40:40 +0000 (20:40 -0000)
committerChris Toshok <toshok@novell.com>
Mon, 12 Mar 2007 20:40:40 +0000 (20:40 -0000)
* XEventQueue.cs: remove the use of PostQuitState.

* XplatUIX11.cs: remove the use of PostQuitState.  If we get a
WM_QUIT message in GetMessage, return false (and if we're in the
nested WaitForHwndMessage, repost the WM_QUIT message).

svn path=/trunk/mcs/; revision=74141

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XEventQueue.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

index af67d83e8e26c3898b7265f6e24702b32c0d62a9..bca18aa014168c2f1f0e5c2804f6c8b56c6a6f79 100644 (file)
@@ -1,3 +1,11 @@
+2007-03-12  Chris Toshok  <toshok@ximian.com>
+
+       * XEventQueue.cs: remove the use of PostQuitState.
+
+       * XplatUIX11.cs: remove the use of PostQuitState.  If we get a
+       WM_QUIT message in GetMessage, return false (and if we're in the
+       nested WaitForHwndMessage, repost the WM_QUIT message).
+
 2007-03-12  Jonathan Pobst  <monkey@jpobst.com>
 
        * Form.cs: Don't call RecreateHandle when we change the MinimizeBox
index 29812fd1e56ebf14615e7f5e70c7c614a71f9ac1..11391af1a7279093caeaea71e177f8d3447a5adb 100644 (file)
@@ -39,7 +39,6 @@ namespace System.Windows.Forms {
                private PaintQueue      paint;  // Paint-only queue
                internal ArrayList      timer_list;
                private Thread          thread;
-               private bool            quit_posted;
                private bool            dispatch_idle;
 
                private static readonly int InitialXEventSize = 100;
@@ -52,7 +51,6 @@ namespace System.Windows.Forms {
                        paint = new PaintQueue(InitialPaintSize);
                        timer_list = new ArrayList ();
                        this.thread = thread;
-                       this.quit_posted = false;
                        this.dispatch_idle = true;
                }
 
@@ -132,16 +130,6 @@ namespace System.Windows.Forms {
                        }
                }
 
-               public bool PostQuitState {
-                       get {
-                               return quit_posted;
-                       }
-
-                       set {
-                               quit_posted = value;
-                       }
-               }
-
                public class PaintQueue {
 
                        private ArrayList       hwnds;
index f45b9491c75f201640548619933ada9a5525aba0..e9b8d2662e4e2ab972192e8da555df26ef851b56 100644 (file)
@@ -1276,17 +1276,18 @@ namespace System.Windows.Forms {
 
                        bool done = false;
                        do {
-                               // if the application is exiting exit this loop immediately so the
-                               // default application mainloop gets the WM_QUIT message and exits
-                               // properly.  Also, only check PostQuitState if the message loop
-                               // for this thread is actually running.
-                               if (Application.MessageLoop && ThreadQueue(Thread.CurrentThread).PostQuitState)
-                                       break;
-
                                if (PeekMessage(queue, ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
-                                       done = (msg.hwnd == hwnd.Handle) && ((Msg)msg.message == message || (Msg)msg.message == Msg.WM_DESTROY);
-                                       TranslateMessage (ref msg);
-                                       DispatchMessage (ref msg);
+                                       if ((Msg)msg.message == Msg.WM_QUIT) {
+                                               PostQuitMessage (0);
+                                               done = true;
+                                       }
+                                       else {
+                                               if ((msg.hwnd == hwnd.Handle) &&
+                                                   ((Msg)msg.message == message || (Msg)msg.message == Msg.WM_DESTROY))
+                                                       done = true;
+                                               TranslateMessage (ref msg);
+                                               DispatchMessage (ref msg);
+                                       }
                                }
                        } while (!done);
 
@@ -3275,24 +3276,9 @@ namespace System.Windows.Forms {
                                } else if (((XEventQueue)queue_id).Paint.Count > 0) {
                                        xevent = ((XEventQueue)queue_id).Paint.Dequeue();
                                } else {
-                                       if (!ThreadQueue(Thread.CurrentThread).PostQuitState) {
-                                               msg.hwnd= IntPtr.Zero;
-                                               msg.message = Msg.WM_ENTERIDLE;
-                                               return true;
-                                       }
-
-                                       // We reset ourselves so GetMessage can be called again
-
-                                       // XXX this is *so* wrong.  if
-                                       // we've posted the quit
-                                       // message we shouldn't *be*
-                                       // called again.  Removing it,
-                                       // however, makes many of the
-                                       // ListView unit tests fail.
-                                       // should investigate why.
-                                       ThreadQueue(Thread.CurrentThread).PostQuitState = false;
-
-                                       return false;
+                                       msg.hwnd= IntPtr.Zero;
+                                       msg.message = Msg.WM_ENTERIDLE;
+                                       return true;
                                }
                        }
 
@@ -3686,7 +3672,7 @@ namespace System.Windows.Forms {
                                }
 
                                case XEventName.ConfigureNotify: {
-                                       if (ThreadQueue(Thread.CurrentThread).PostQuitState|| !client && (xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) {      // Ignore events for children (SubstructureNotify) and client areas
+                                       if (!client && (xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) {        // Ignore events for children (SubstructureNotify) and client areas
                                                #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
@@ -3769,7 +3755,7 @@ namespace System.Windows.Forms {
                                }
 
                                case XEventName.Expose: {
-                                       if (ThreadQueue(Thread.CurrentThread).PostQuitState || !hwnd.Mapped) {
+                                       if (!hwnd.Mapped) {
                                                if (client) {
                                                        hwnd.expose_pending = false;
                                                } else {
@@ -3882,7 +3868,10 @@ namespace System.Windows.Forms {
                                                msg.message = (Msg) xevent.ClientMessageEvent.ptr2.ToInt32 ();
                                                msg.wParam = xevent.ClientMessageEvent.ptr3;
                                                msg.lParam = xevent.ClientMessageEvent.ptr4;
-                                               return true;
+                                               if (msg.message == (Msg)Msg.WM_QUIT)
+                                                       return false;
+                                               else
+                                                       return true;
                                        }
 
                                        if  (xevent.ClientMessageEvent.message_type == _XEMBED) {
@@ -4316,7 +4305,6 @@ namespace System.Windows.Forms {
                internal override void PostQuitMessage(int exitCode) {
                        PostMessage (FosterParent, Msg.WM_QUIT, IntPtr.Zero, IntPtr.Zero);
                        XFlush(DisplayHandle);
-                       ThreadQueue(Thread.CurrentThread).PostQuitState = true;
                }
 
                internal override void RequestAdditionalWM_NCMessages(IntPtr hwnd, bool hover, bool leave)
@@ -5128,7 +5116,6 @@ namespace System.Windows.Forms {
 
                internal override object StartLoop(Thread thread) {
                        XEventQueue q = ThreadQueue(thread);
-                       q.PostQuitState = false;
                        return q;
                }