예제 #1
0
        public static void Grab(this Gtk.Window window)
        {
            window.GrabFocus();

            Gtk.Grab.Add(window);

            var mask = Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask;

#if GTK3
            var grabbed = window.Display.DeviceManager.ClientPointer.Grab(window.GetWindow(), Gdk.GrabOwnership.Window, true, mask, null, 0);
            if (grabbed != Gdk.GrabStatus.Success)
            {
                Gtk.Grab.Remove(window);
            }
#else
            var grabbed = Gdk.Pointer.Grab(window.GdkWindow, true, mask, null, null, 0);
            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(window.GdkWindow, true, 0);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Gtk.Grab.Remove(window);
                    window.Destroy();
                }
            }
            else
            {
                Gtk.Grab.Remove(window);
            }
#endif
        }
예제 #2
0
        public static void Grab(this Gtk.Window window)
        {
            window.GrabFocus();

            Gtk.Grab.Add(window);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(window.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, 0);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(window.GdkWindow, true, 0);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Gtk.Grab.Remove(window);
                    window.Destroy();
                }
            }
            else
            {
                Gtk.Grab.Remove(window);
            }
        }