2008-09-17 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Wed, 17 Sep 2008 21:00:00 +0000 (21:00 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Wed, 17 Sep 2008 21:00:00 +0000 (21:00 -0000)
* XplatUIX11.cs, X11Structs.cs: For mapped windows SetTopMost should
ask the window manager to do the work instead of changing the property
directly.
[Fixes bug #423417]

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

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

index 979f2a8af3ea4289c81cccf39be45a1aa998b89d..30c264c0e0132f6c8f95acbd2f7f94c6e80e830a 100644 (file)
@@ -1,3 +1,10 @@
+2008-09-17  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * XplatUIX11.cs, X11Structs.cs: For mapped windows SetTopMost should 
+       ask the window manager to do the work instead of changing the property 
+       directly.
+       [Fixes bug #423417]
+
 2008-09-17  Everaldo Canuto  <ecanuto@novell.com>
 
        * CurrencyManager.cs: Check for positon before call ChangeRecordState in
index d7e18895eef04ff5983ecae95f56538c1a38c92b..38622afb6735c01caddc797849fa0eed1055eff7 100644 (file)
@@ -1353,6 +1353,12 @@ namespace System.Windows.Forms {
                SYSTEM_TRAY_CANCEL_MESSAGE      = 2
        }
 
+       internal enum NetWmStateRequest {
+               _NET_WM_STATE_REMOVE            = 0,
+               _NET_WM_STATE_ADD               = 1,
+               _NET_WM_STATE_TOGGLE            = 2
+       }
+
        [Flags]
        internal enum XSizeHintsFlags  {
                USPosition                      = (1 << 0),
index fda0b2efbdf9c2c18f38a96d34177a0d4cf79b6e..6e91d4e726253a4c80b451f75809a7da2ec1ad5f 100644 (file)
@@ -5394,13 +5394,20 @@ namespace System.Windows.Forms {
 
                        if (enabled) {
                                lock (XlibLock) {
-                                       int[] atoms = new int[8];
-                                       atoms[0] = _NET_WM_STATE_ABOVE.ToInt32();
-                                       XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_STATE, (IntPtr)Atom.XA_ATOM, 32, PropertyMode.Replace, atoms, 1);
+                                       if (hwnd.Mapped) {
+                                               SendNetWMMessage(hwnd.WholeWindow, _NET_WM_STATE, (IntPtr) NetWmStateRequest._NET_WM_STATE_ADD, _NET_WM_STATE_ABOVE, IntPtr.Zero);
+                                       } else {
+                                               int[] atoms = new int[8];
+                                               atoms[0] = _NET_WM_STATE_ABOVE.ToInt32();
+                                               XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_STATE, (IntPtr)Atom.XA_ATOM, 32, PropertyMode.Replace, atoms, 1);
+                                       }
                                }
                        } else {
                                lock (XlibLock) {
-                                       XDeleteProperty(DisplayHandle, hwnd.whole_window, _NET_WM_STATE);
+                                       if (hwnd.Mapped)
+                                               SendNetWMMessage(hwnd.WholeWindow, _NET_WM_STATE, (IntPtr) NetWmStateRequest._NET_WM_STATE_REMOVE, _NET_WM_STATE_ABOVE, IntPtr.Zero);
+                                       else
+                                               XDeleteProperty(DisplayHandle, hwnd.whole_window, _NET_WM_STATE);
                                }
                        }
                        return true;