Example #1
0
        /// <summary>
        /// Set a winform windows "X group leader" value.
        /// By default all mono winform applications get the same group leader (WM_HINTS property)
        /// (use xprop to see a windows WM_HINTS values)
        /// </summary>
        public static void SetGroupLeader(IntPtr handle, IntPtr newValue)
        {
            var    x11Handle = MonoGetX11Window(handle);
            IntPtr ptr       = NativeX11Methods.XGetWMHints(NativeReplacements.MonoGetDisplayHandle(), x11Handle);
            var    wmhints   = (NativeX11Methods.XWMHints)Marshal.PtrToStructure(ptr, typeof(NativeX11Methods.XWMHints));

            NativeX11Methods.XFree(ptr);
            wmhints.window_group = NativeReplacements.MonoGetX11Window(newValue);
            NativeX11Methods.XSetWMHints(NativeReplacements.MonoGetDisplayHandle(), NativeReplacements.MonoGetX11Window(x11Handle), ref wmhints);
        }
Example #2
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);
        }
Example #3
0
        public static void SetWmClass(string name, string @class, IntPtr handle)
        {
            var a = new NativeX11Methods.XClassHint {
                res_name = Marshal.StringToCoTaskMemAnsi(name), res_class = Marshal.StringToCoTaskMemAnsi(@class)
            };
            IntPtr classHints = Marshal.AllocCoTaskMem(Marshal.SizeOf(a));

            Marshal.StructureToPtr(a, classHints, true);

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

            Marshal.FreeCoTaskMem(a.res_name);
            Marshal.FreeCoTaskMem(a.res_class);

            Marshal.FreeCoTaskMem(classHints);
        }