2026-04-25 16:46:01 +08:00
|
|
|
#include "Platform/Win32/Windowing/EditorWindowSession.h"
|
|
|
|
|
|
|
|
|
|
#include "Platform/Win32/Windowing/EditorWindowSupport.h"
|
|
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine::UI::Editor::App {
|
|
|
|
|
|
|
|
|
|
using namespace EditorWindowSupport;
|
|
|
|
|
|
|
|
|
|
EditorWindowSession::EditorWindowSession(
|
|
|
|
|
std::string windowId,
|
|
|
|
|
std::wstring title,
|
2026-04-25 17:51:37 +08:00
|
|
|
EditorWindowCategory category,
|
|
|
|
|
EditorWindowChromePolicy chromePolicy,
|
2026-04-25 16:46:01 +08:00
|
|
|
bool primary) {
|
|
|
|
|
m_state.window.windowId = std::move(windowId);
|
|
|
|
|
m_state.window.title = std::move(title);
|
2026-04-25 17:51:37 +08:00
|
|
|
m_state.window.category = category;
|
|
|
|
|
m_state.window.chromePolicy = chromePolicy;
|
2026-04-25 16:46:01 +08:00
|
|
|
m_state.window.primary = primary;
|
|
|
|
|
UpdateCachedTitleText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string_view EditorWindowSession::GetWindowId() const {
|
|
|
|
|
return m_state.window.windowId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HWND EditorWindowSession::GetHwnd() const {
|
|
|
|
|
return m_state.window.hwnd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EditorWindowSession::HasHwnd() const {
|
|
|
|
|
return m_state.window.hwnd != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 17:51:37 +08:00
|
|
|
EditorWindowCategory EditorWindowSession::GetCategory() const {
|
|
|
|
|
return m_state.window.category;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const EditorWindowChromePolicy& EditorWindowSession::GetChromePolicy() const {
|
|
|
|
|
return m_state.window.chromePolicy;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 16:46:01 +08:00
|
|
|
EditorWindowLifecycleState EditorWindowSession::GetLifecycleState() const {
|
|
|
|
|
return m_state.window.lifecycle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EditorWindowSession::IsPrimary() const {
|
|
|
|
|
return m_state.window.primary;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 17:51:37 +08:00
|
|
|
bool EditorWindowSession::IsWorkspaceWindow() const {
|
|
|
|
|
return m_state.window.category == EditorWindowCategory::Workspace;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EditorWindowSession::IsUtilityWindow() const {
|
|
|
|
|
return m_state.window.category == EditorWindowCategory::Utility;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 16:46:01 +08:00
|
|
|
bool EditorWindowSession::IsClosing() const {
|
|
|
|
|
return m_state.window.lifecycle == EditorWindowLifecycleState::Closing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EditorWindowSession::IsDestroyed() const {
|
|
|
|
|
return m_state.window.lifecycle == EditorWindowLifecycleState::Destroyed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::wstring& EditorWindowSession::GetTitle() const {
|
|
|
|
|
return m_state.window.title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string_view EditorWindowSession::GetCachedTitleText() const {
|
|
|
|
|
return m_state.window.titleText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::AttachHwnd(HWND hwnd) {
|
|
|
|
|
m_state.window.hwnd = hwnd;
|
|
|
|
|
m_state.window.lifecycle = EditorWindowLifecycleState::NativeAttached;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::MarkNativeAttached() {
|
|
|
|
|
m_state.window.lifecycle = EditorWindowLifecycleState::NativeAttached;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::MarkInitializing() {
|
|
|
|
|
m_state.window.lifecycle = EditorWindowLifecycleState::Initializing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::MarkRunning() {
|
|
|
|
|
m_state.window.lifecycle = EditorWindowLifecycleState::Running;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::MarkDestroyed() {
|
|
|
|
|
m_state.window.hwnd = nullptr;
|
|
|
|
|
m_state.window.lifecycle = EditorWindowLifecycleState::Destroyed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::MarkClosing() {
|
|
|
|
|
m_state.window.lifecycle = EditorWindowLifecycleState::Closing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::SetPrimary(bool primary) {
|
|
|
|
|
m_state.window.primary = primary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::SetTitle(std::wstring title) {
|
|
|
|
|
m_state.window.title = std::move(title);
|
|
|
|
|
UpdateCachedTitleText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::QueueCompletedImmediateFrame(
|
|
|
|
|
EditorWindowFrameTransferRequests transferRequests) {
|
|
|
|
|
m_hasQueuedCompletedImmediateFrame = true;
|
2026-04-25 17:51:37 +08:00
|
|
|
if (transferRequests.workspace.beginGlobalTabDrag.has_value()) {
|
|
|
|
|
m_queuedImmediateFrameTransferRequests.workspace.beginGlobalTabDrag =
|
|
|
|
|
std::move(transferRequests.workspace.beginGlobalTabDrag);
|
2026-04-25 16:46:01 +08:00
|
|
|
}
|
2026-04-25 17:51:37 +08:00
|
|
|
if (transferRequests.workspace.detachPanel.has_value()) {
|
|
|
|
|
m_queuedImmediateFrameTransferRequests.workspace.detachPanel =
|
|
|
|
|
std::move(transferRequests.workspace.detachPanel);
|
2026-04-25 16:46:01 +08:00
|
|
|
}
|
2026-04-25 17:51:37 +08:00
|
|
|
if (transferRequests.utility.openUtilityWindow.has_value()) {
|
|
|
|
|
m_queuedImmediateFrameTransferRequests.utility.openUtilityWindow =
|
|
|
|
|
std::move(transferRequests.utility.openUtilityWindow);
|
2026-04-25 16:46:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EditorWindowSession::HasQueuedCompletedImmediateFrame() const {
|
|
|
|
|
return m_hasQueuedCompletedImmediateFrame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorWindowFrameTransferRequests
|
|
|
|
|
EditorWindowSession::ConsumeQueuedCompletedImmediateFrameTransferRequests() {
|
|
|
|
|
m_hasQueuedCompletedImmediateFrame = false;
|
|
|
|
|
EditorWindowFrameTransferRequests transferRequests =
|
|
|
|
|
std::move(m_queuedImmediateFrameTransferRequests);
|
|
|
|
|
m_queuedImmediateFrameTransferRequests = {};
|
|
|
|
|
return transferRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorWindowSession::UpdateCachedTitleText() {
|
|
|
|
|
m_state.window.titleText = WideToUtf8(m_state.window.title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace XCEngine::UI::Editor::App
|