If the window manager does not support _NET_ACTIVE_WINDOW, fall back to XGetInputFocus
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 20 Mar 2012 03:45:39 +0000 (03:45 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 20 Mar 2012 03:47:42 +0000 (03:47 +0000)
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

index d00c40d13be29a7a7673c5411911aa221f8b4faf..c903781a906bd7a2c565fecb64218f64432376d3 100644 (file)
@@ -3768,6 +3768,10 @@ namespace System.Windows.Forms {
                        if (((long)nitems > 0) && (prop != IntPtr.Zero)) {
                                active = (IntPtr)Marshal.ReadInt32(prop);
                                XFree(prop);
+                       } else {
+                               // The window manager does not support _NET_ACTIVE_WINDOW.  Fall back to XGetInputFocus.
+                               IntPtr  revert_to = IntPtr.Zero;
+                               XGetInputFocus(DisplayHandle, out active, out revert_to);
                        }
 
                        if (active != IntPtr.Zero) {
@@ -7526,6 +7530,9 @@ namespace System.Windows.Forms {
 
                [DllImport ("libX11", EntryPoint="XIfEvent")]
                internal extern static void XIfEvent (IntPtr display, ref XEvent xevent, Delegate event_predicate, IntPtr arg);
+
+               [DllImport ("libX11", EntryPoint="XGetInputFocus")]
+               internal extern static void XGetInputFocus (IntPtr display, out IntPtr focus, out IntPtr revert_to);
                #endregion
 #endif
        }