/// <summary> /// Gets all newly created windows, not handled by the desktop manager yet. /// </summary> /// <returns>A list with all new windows.</returns> List <WindowSnapshot> GetNewWindows() { List <WindowInfo> newWindows = WindowManager.GetWindows().Except( Workspaces.SelectMany(d => d.WindowSnapshots).Concat(WindowClipboard) .Select(w => w.Info) .Concat(_invalidWindows)).ToList(); var validWindows = new List <WindowSnapshot>(); foreach (var w in newWindows) { var snapshot = new WindowSnapshot(CurrentWorkspace, w); if (IsValidWindow(snapshot)) { validWindows.Add(snapshot); } else { lock ( _invalidWindows ) { _invalidWindows.Add(w); } } } return(validWindows); }
protected bool Equals(WindowSnapshot other) { if (ReferenceEquals(null, other)) { return(false); } return(ReferenceEquals(this, other) || Info.Equals(other.Info)); }
/// <summary> /// Find z-order of all passed windows. /// </summary> /// <returns>A new list containing all the passed windows, but ordered according to their z-order, most on top first.</returns> static List <WindowSnapshot> OrderWindowsByZOrder(List <WindowSnapshot> toOrder) { // TODO: Safeguard for infinite loop and possible destroyed windows. // http://stackoverflow.com/q/12992201/590790 var ordenedWindows = new List <WindowSnapshot>(); WindowInfo window = WindowManager.GetTopWindow(); while (window != null) { WindowSnapshot match = toOrder.FirstOrDefault(w => w.Info.Equals(window)); if (match != null) { ordenedWindows.Add(match); } window = WindowManager.GetWindowBelow(window); } return(ordenedWindows); }
/// <summary> /// Show all windows associated with this virtual desktop. /// Unresponsive window event is triggered when any unresponsive windows are detected during show operation. /// </summary> protected override void ShowInner() { // Early out when virtual desktop has not windows. if (_windows.Count == 0) { return; } var unresponsiveWindows = new List <WindowSnapshot>(); // Reposition windows. // Topmost windows are repositioned separately in order to prevent non-topmost windows from becoming topmost when moving them above topmost windows in the z-order. var allWindows = _windows .Where(w => !w.Ignore) .GroupBy(w => w.Info.IsTopmost()); allWindows.ForEach(group => { var showWindows = group.Select(w => new RepositionWindowInfo(w.Info) { Visible = w.Visible }); unresponsiveWindows.AddRange(RepositionWindows(showWindows, true)); }); // Activate top window. // TODO: Is the topmost window always the previous active one? Possibly a better check is needed. // TODO: Which window to activate when desktops are merged? WindowSnapshot first = _windows.FirstOrDefault(w => w.Visible && !unresponsiveWindows.Contains(w)); if (first != null) { first.Info.SetForegroundWindow(); } TriggerIfUnresponsive(unresponsiveWindows); }
protected bool Equals( WindowSnapshot other ) { if ( ReferenceEquals( null, other ) ) { return false; } return ReferenceEquals( this, other ) || Info.Equals( other.Info ); }
/// <summary> /// Check whether the WindowInfo object represents a valid Window. /// </summary> /// <returns>True if valid, false if unvalid.</returns> bool IsValidWindow(WindowSnapshot window) { return(!window.Info.IsDestroyed() && _windowFilter(new Window(window.Info))); }