Exemple #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 __MonoCS__
            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);
#endif
        }
Exemple #2
0
        /// <summary>
        /// Set WM_CLASS property
        /// </summary>
        /// <remarks>You should call this method after you opened your main form so that the
        /// icon in the launcher and the app menu will show the correct name/icon when running
        /// on Ubuntu 18.04. The <paramref name="name"/> should match the name of the
        /// application/launcher used to start the application, e.g. fieldworks-flex.</remarks>
        public static void SetWmClass(string name, string @class, IntPtr handle)
        {
            if (!Platform.IsLinux)
            {
                return;
            }

            var classHint = new XClassHint {
                res_name  = Marshal.StringToCoTaskMemAnsi(name),
                res_class = Marshal.StringToCoTaskMemAnsi(@class)
            };
            var classHints = Marshal.AllocCoTaskMem(Marshal.SizeOf(classHint));

            Marshal.StructureToPtr(classHint, classHints, true);

            XSetClassHint(NativeReplacements.MonoGetDisplayHandle(),
                          NativeReplacements.MonoGetX11Window(handle), classHints);

            Marshal.FreeCoTaskMem(classHint.res_name);
            Marshal.FreeCoTaskMem(classHint.res_class);
            Marshal.FreeCoTaskMem(classHints);
        }