示例#1
0
        /// <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);
                }
            }
        }
示例#2
0
        /// <summary>
        ///   Cut a given window from the currently open desktop and store it in a clipboard.
        ///   TODO: What if a window from a different desktop is passed? Should this be supported?
        /// </summary>
        public void CutWindow(Window window)
        {
            ThrowExceptionIfDisposed();

            UpdateWindowAssociations();             // Newly added windows might need to be cut too, so update associations first.

            if (!_windowFilter(window))
            {
                return;
            }

            var cutWindows = _hideBehavior(window, this).Select(w => new WindowSnapshot(CurrentWorkspace, w.WindowInfo)).ToList();

            cutWindows.ForEach(w => WindowClipboard.Push(w));

            CurrentWorkspace.RemoveWindows(cutWindows);
        }