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 }
private static bool AnyIsActiveWindow(Gtk.Window[] windows) { var activeWindow = Gdk.Screen.Default.ActiveWindow; if (activeWindow != null) { var activeWindowHandle = activeWindow.Handle; for (int i = 0; i < windows.Length; i++) { Gtk.Window window = windows[i]; var gdkwindow = window.GetWindow(); if (gdkwindow != null && gdkwindow.Handle == activeWindowHandle) { return(true); } } activeWindow.Dispose(); } return(false); }