public WindowActiveHelper(Gtk.Window window) { if (window == null) { return; } _window = window; _window.AddEvents((int)Gdk.EventMask.FocusChangeMask); _window.FocusInEvent += _window_FocusInEvent; _window.FocusOutEvent += _window_FocusOutEvent; }
public static void PresentWithServerTime(this Gtk.Window window) { if (window == null) { return; } var gdkWindow = window.GdkWindow; if (gdkWindow == null || !IsGdkX11Available) { window.Present(); return; } // HACK: disabled, see window.AddEvents() below /* * if ((gdkWindow.Events & Gdk.EventMask.PropertyChangeMask) == 0) { * // GDK_PROPERTY_CHANGE_MASK is not set thus we have to bail out * // else gdk_x11_get_server_time() will hang! * window.Present(); * return; * } */ // HACK: we can't obtain and check for GDK_PROPERTY_CHANGE_MASK as // gdk_window_x11_get_events() filters that mask, thus we have to // ignorantly set it using gtk_widget_add_events() else // gdk_x11_get_server_time() would hang if it wasn't set! window.AddEvents((int)Gdk.EventMask.PropertyChangeMask); try { // TODO: should we fallback to gdk_x11_display_get_user_time? var timestamp = gdk_x11_get_server_time(gdkWindow.Handle); window.PresentWithTime(timestamp); } catch (DllNotFoundException) { IsGdkX11Available = false; // no libgdk-x11 available (probably Mac OS X or Windows), thus // fallback to gtk_window_present() without a timestamp as they // don't require a timestamp to change the window focus window.Present(); } }
/// <summary> /// Restores the specified window state. /// </summary> /// <param name="targetWindow">The window.</param> /// <param name="attachToWindow"></param> public void Restore( Window targetWindow, bool attachToWindow) { // Set the window state. targetWindow.DefaultSize = new Size(width, height); // If we are attaching, then attach to the events so we can // track the window sizes. if (attachToWindow) { // Save the window. window = targetWindow; // Enable the events and attach to them. window.AddEvents((int)EventMask.AllEventsMask); window.ConfigureEvent += OnUpdateWindowState; window.DeleteEvent += OnDestroyWindow; } }
/// <summary> /// Restores the specified window state. /// </summary> /// <param name="targetWindow">The window.</param> /// <param name="attachToWindow"></param> public void Restore( Window targetWindow, bool attachToWindow) { // Set the window state. targetWindow.DefaultSize = new Size(width, height); // If we are attaching, then attach to the events so we can // track the window sizes. if (attachToWindow) { // Save the window. window = targetWindow; // Enable the events and attach to them. window.AddEvents((int) EventMask.AllEventsMask); window.ConfigureEvent += OnUpdateWindowState; window.DeleteEvent += OnDestroyWindow; } }