2008-09-18 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Thu, 18 Sep 2008 10:21:13 +0000 (10:21 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Thu, 18 Sep 2008 10:21:13 +0000 (10:21 -0000)
* XplatUIX11.cs:
 - Do not set _NET_WM_WINDOW_TYPE_DIALOG for modal forms, because this
 leads to the window manager overriding our border style and zorder.
 - Allow the activation of non-modal forms, which are children of a
 modal form.
[Fixes bug #423417]

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

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

index 30c264c0e0132f6c8f95acbd2f7f94c6e80e830a..9d6ccd4a46f67e9157689381f8dce68df97b06b6 100644 (file)
@@ -1,3 +1,12 @@
+2008-09-18  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * XplatUIX11.cs: 
+        - Do not set _NET_WM_WINDOW_TYPE_DIALOG for modal forms, because this 
+        leads to the window manager overriding our border style and zorder. 
+        - Allow the activation of non-modal forms, which are children of a 
+        modal form.
+       [Fixes bug #423417]
+
 2008-09-17  Ivan N. Zlatev  <contact@i-nz.net>
 
        * XplatUIX11.cs, X11Structs.cs: For mapped windows SetTopMost should 
index 6e91d4e726253a4c80b451f75809a7da2ec1ad5f..9859c681fbb595cd29f4976d72ef8cc8554064cb 100644 (file)
@@ -1073,8 +1073,6 @@ namespace System.Windows.Forms {
                                // needed! map toolwindows to _NET_WM_WINDOW_TYPE_UTILITY to make newer metacity versions happy
                                // and get those windows in front of their parents
                                window_type = _NET_WM_WINDOW_TYPE_UTILITY;
-                       } else if (form != null && form.Modal) {
-                               window_type = _NET_WM_WINDOW_TYPE_DIALOG;
                        } else {
                                window_type = _NET_WM_WINDOW_TYPE_NORMAL;
                        }
@@ -1786,11 +1784,23 @@ namespace System.Windows.Forms {
                                                        if (ModalWindows.Count == 0) {
                                                                break;
                                                        } else {
-                                                               // Modality handling, if we are modal and the new active window is one
-                                                               // of ours but not the modal one, switch back to the modal window
-
-                                                               if (NativeWindow.FromHandle(ActiveWindow) != null) {
-                                                                       if (ActiveWindow != (IntPtr)ModalWindows.Peek()) {
+                                                               // Modality Handling
+                                                               // 
+                                                               // If there is a modal window on the stack and the new active 
+                                                               // window is MWF window, but not the modal one and not a non-modal 
+                                                               // child of the modal one, switch back to the modal window.
+                                                               //
+                                                               // To identify if a non-modal form is child of a modal form 
+                                                               // we match their ApplicationContexts, which will be the same.
+                                                               // This is because each modal form runs the loop with a 
+                                                               // new ApplicationContext, which is inherited by the non-modal 
+                                                               // forms.
+
+                                                               Form activeForm = Control.FromHandle (ActiveWindow) as Form;
+                                                               if (activeForm != null) {
+                                                                       Form modalForm = Control.FromHandle ((IntPtr)ModalWindows.Peek()) as Form;
+                                                                       if (ActiveWindow != (IntPtr)ModalWindows.Peek() && 
+                                                                           (modalForm == null || activeForm.context == modalForm.context)) {
                                                                                Activate((IntPtr)ModalWindows.Peek());
                                                                        }
                                                                }