MonoDevelop.Components.Commands.CommandManager.GetActiveWindow C# (CSharp) Method

GetActiveWindow() private method

private GetActiveWindow ( Gtk win ) : Gtk.Window
win Gtk
return Gtk.Window
		Gtk.Window GetActiveWindow (Gtk.Window win)
		{
			Gtk.Window[] wins = Gtk.Window.ListToplevels ();
			
			bool hasFocus = false;
			bool lastFocusedExists = lastFocused == null;
			Gtk.Window newFocused = null;
			foreach (Gtk.Window w in wins) {
				if (w.Visible) {
					if (w.HasToplevelFocus) {
						hasFocus = true;
						newFocused = w;
					}
					if (w.IsActive && w.Type == Gtk.WindowType.Toplevel && !(w is Gtk.Dialog)) {
						if (win == null)
							win = w;
					}
					if (lastFocused == w) {
						lastFocusedExists = true;
					}
				}
			}

			lastFocused = newFocused;
			UpdateAppFocusStatus (hasFocus, lastFocusedExists);
			
			if (win != null && win.IsRealized) {
				RegisterTopWindow (win);
				return win;
			}
			else
				return null;
		}