Ejemplo n.º 1
0
        /// <summary>
        /// Set InputFocus to a WinForm controls using Mono winforms connection to the X11 server.
        /// GeckoWebBrowser.RemoveInputFocus uses the Gecko/Gtk connection to the X11 server.
        /// The undoes the call to _browser.SetInputFocus.
        /// Call this method when a winform control has gained focus, and X11 Input focus is still on the Gecko control.
        /// </summary>
        protected static void MoveInputFocusBackToAWinFormsControl()
        {
            if (Platform.IsWindows)
            {
                return;
            }

            IntPtr newTargetHandle = NativeReplacements.MonoGetFocus();
            IntPtr displayHandle   = NativeReplacements.MonoGetDisplayHandle();

            // Remove the Focus from a Gtk window back to a mono winform X11 window.
            NativeX11Methods.XSetInputFocus(displayHandle, NativeReplacements.MonoGetX11Window(newTargetHandle), NativeX11Methods.RevertTo.None, IntPtr.Zero);
        }