/// <summary> /// Update which windows are associated to the current virtual desktop. /// </summary> public void UpdateWindowAssociations() { ThrowExceptionIfDisposed(); // The desktop needs to be visible in order to update window associations. if (!CurrentWorkspace.IsVisible) { return; } // Update window associations for the currently open desktop. CurrentWorkspace.AddWindows(GetNewWindows()); CurrentWorkspace.RemoveWindows(CurrentWorkspace.WindowSnapshots.Where(w => !IsValidWindow(w)).ToList()); CurrentWorkspace.WindowSnapshots.ForEach(w => w.Update()); // Remove destroyed windows from places where they are cached. var destroyedWindows = _invalidWindows.Where(w => w.IsDestroyed()).ToList(); foreach (var w in destroyedWindows) { lock ( _invalidWindows ) { _invalidWindows.Remove(w); } } }
/// <summary> /// Paste all windows on the clipboard on the currently open desktop. /// </summary> public void PasteWindows() { ThrowExceptionIfDisposed(); UpdateWindowAssociations(); // There might be newly added windows of which the z-order isn't known yet, so update associations first. CurrentWorkspace.AddWindows(WindowClipboard.ToList()); }