mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-08 18:16:28 +00:00
This adds a new feature to the Windows Terminal: "Workspaces" Workspaces are very shamelessly inspired by Edge workspaces of the same name. The core idea is that when users name a window and they close that window, we will persist that Windows layout and buffers, seperately from the rest of window restoration. So a user can open a named window, open some profiles, some panes, do some stuff in it, then close it, and we will keep that state around for the next time the user opens that window name. Unnamed windows still behave the same. If you close an unnamed window, and it's not the last window, then we won't persist the state of it. To facilitate restoring named windows, we add a `openWorkspace` action. This allows us to persist the open workspace action in the window layout restoration path. So when we deserialize the list of tab layouts, and open workspace action will tell us, hey, go retrieve this known workspace from the state.json, instead of trying to serialize the window state in two places. As demoed in the video, we add a flyout to list the windows that the user has open, and the named workspaces that they have saved. This allows users to quickly reopen previously closed workspaces, as well as quickly rename a window, thereby adding it to the list of saved workspaces. This button can also be hidden using the theme settings. Closes #17084 (this is a reboot of #20162, but with the event from #20311)
100 lines
3.9 KiB
C++
100 lines
3.9 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "AppCommandlineArgs.h"
|
|
#include "CommandlineArgs.g.h"
|
|
#include "RequestReceiveContentArgs.g.h"
|
|
#include "SummonWindowBehavior.g.h"
|
|
#include "WindowRequestedArgs.g.h"
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
{
|
|
struct CommandlineArgs : public CommandlineArgsT<CommandlineArgs>
|
|
{
|
|
::TerminalApp::AppCommandlineArgs& ParsedArgs() noexcept;
|
|
winrt::com_array<winrt::hstring>& CommandlineRef() noexcept;
|
|
|
|
// These bits are exposed via WinRT:
|
|
int32_t ExitCode() const noexcept;
|
|
winrt::hstring ExitMessage() const;
|
|
winrt::hstring TargetWindow() const;
|
|
|
|
til::property<winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection> Connection;
|
|
void Commandline(const winrt::array_view<const winrt::hstring>& value);
|
|
winrt::com_array<winrt::hstring> Commandline();
|
|
til::property<winrt::hstring> CurrentDirectory;
|
|
til::property<winrt::hstring> CurrentEnvironment;
|
|
til::property<uint32_t> ShowWindowCommand{ static_cast<uint32_t>(SW_NORMAL) }; // SW_NORMAL is 1, 0 is SW_HIDE
|
|
|
|
private:
|
|
::TerminalApp::AppCommandlineArgs _parsed;
|
|
int32_t _parseResult = 0;
|
|
winrt::com_array<winrt::hstring> _args;
|
|
};
|
|
|
|
struct RequestReceiveContentArgs : RequestReceiveContentArgsT<RequestReceiveContentArgs>
|
|
{
|
|
WINRT_PROPERTY(uint64_t, SourceWindow);
|
|
WINRT_PROPERTY(uint64_t, TargetWindow);
|
|
WINRT_PROPERTY(uint32_t, TabIndex);
|
|
|
|
public:
|
|
RequestReceiveContentArgs(const uint64_t src, const uint64_t tgt, const uint32_t tabIndex) :
|
|
_SourceWindow{ src },
|
|
_TargetWindow{ tgt },
|
|
_TabIndex{ tabIndex } {};
|
|
};
|
|
|
|
struct SummonWindowBehavior : public SummonWindowBehaviorT<SummonWindowBehavior>
|
|
{
|
|
public:
|
|
SummonWindowBehavior() = default;
|
|
WINRT_PROPERTY(bool, MoveToCurrentDesktop, true);
|
|
WINRT_PROPERTY(bool, ToggleVisibility, true);
|
|
WINRT_PROPERTY(uint32_t, DropdownDuration, 0);
|
|
WINRT_PROPERTY(MonitorBehavior, ToMonitor, MonitorBehavior::ToCurrent);
|
|
|
|
public:
|
|
SummonWindowBehavior(const SummonWindowBehavior& other) :
|
|
_MoveToCurrentDesktop{ other.MoveToCurrentDesktop() },
|
|
_ToMonitor{ other.ToMonitor() },
|
|
_DropdownDuration{ other.DropdownDuration() },
|
|
_ToggleVisibility{ other.ToggleVisibility() } {};
|
|
};
|
|
|
|
struct WindowRequestedArgs : public WindowRequestedArgsT<WindowRequestedArgs>
|
|
{
|
|
public:
|
|
WindowRequestedArgs(uint64_t id, const winrt::TerminalApp::CommandlineArgs& command) :
|
|
_Id{ id },
|
|
_Command{ std::move(command) }
|
|
{
|
|
}
|
|
|
|
WindowRequestedArgs(const winrt::hstring& window, const winrt::hstring& content, const Windows::Foundation::IReference<Windows::Foundation::Rect>& bounds) :
|
|
_WindowName{ window },
|
|
_Content{ content },
|
|
_InitialBounds{ bounds }
|
|
{
|
|
}
|
|
|
|
WINRT_PROPERTY(uint64_t, Id);
|
|
WINRT_PROPERTY(winrt::hstring, WindowName);
|
|
WINRT_PROPERTY(TerminalApp::CommandlineArgs, Command, nullptr);
|
|
WINRT_PROPERTY(winrt::hstring, Content);
|
|
WINRT_PROPERTY(Windows::Foundation::IReference<Windows::Foundation::Rect>, InitialBounds);
|
|
WINRT_PROPERTY(winrt::Microsoft::Terminal::Settings::Model::WindowLayout, PersistedLayout, nullptr);
|
|
WINRT_PROPERTY(Windows::Foundation::Collections::IVector<winrt::Microsoft::Terminal::Settings::Model::ActionAndArgs>, StartupActions, nullptr);
|
|
};
|
|
}
|
|
|
|
namespace winrt::TerminalApp::factory_implementation
|
|
{
|
|
BASIC_FACTORY(SummonWindowBehavior);
|
|
BASIC_FACTORY(CommandlineArgs);
|
|
BASIC_FACTORY(RequestReceiveContentArgs);
|
|
BASIC_FACTORY(WindowRequestedArgs);
|
|
}
|