Example #1
0
        void OnForceSuspendRequested(AbstractWorkspace <StoredSession> workspace)
        {
            var virtualDesktop = (VirtualDesktop)workspace;

            // TODO: Is there any way to always support this? The internal WindowSnapshot constructor assumes the windows are part of the currently visible desktop.
            if (!virtualDesktop.IsVisible)
            {
                throw new InvalidOperationException("Can only transfer windows when the desktop is currently visible.");
            }

            // Move windows from the forcefully suspended workspace to the startup workspace.
            List <WindowSnapshot> snapshots = virtualDesktop.Windows.Select(w => new WindowSnapshot(virtualDesktop, w.WindowInfo)).ToList();

            virtualDesktop.RemoveWindows(snapshots);
            StartupWorkspace.AddWindows(snapshots);
        }
Example #2
0
        protected override VirtualDesktop CreateWorkspaceFromSessionInner(StoredSession session)
        {
            // Do not restore startup desktop, simply use the newly created startup desktop.
            if (session.IsStartupDesktop)
            {
                return(StartupWorkspace);
            }

            // The startup desktop contains all windows open at startup.
            // Windows from previously stored sessions shouldn't be assigned to this startup desktop, so remove them.
            List <WindowSnapshot> otherWindows = StartupWorkspace.WindowSnapshots.Where(o => session.OpenWindows.Contains(o)).ToList();

            StartupWorkspace.RemoveWindows(otherWindows);
            VirtualDesktop restored = new VirtualDesktop(session, _persistenceProvider);

            HookDesktopEvents(restored);
            session.OpenWindows.ForEach(w => w.ChangeDesktop(restored));
            return(restored);
        }