refactor(new_editor): centralize win32 frame execution

This commit is contained in:
2026-04-22 14:37:25 +08:00
parent 4a42b757c7
commit b44f5ca9fc
10 changed files with 114 additions and 44 deletions

View File

@@ -222,12 +222,16 @@ bool EditorWindow::Initialize(
<< " scale=" << GetDpiScale();
LogRuntimeTrace("window", dpiTrace.str());
return m_runtime->Initialize(
const bool initialized = m_runtime->Initialize(
m_state->window.hwnd,
repoRoot,
editorContext,
captureRoot,
autoCaptureOnStartup);
if (initialized) {
RequestFrame(EditorWindowFrameRequestReason::Initial);
}
return initialized;
}
void EditorWindow::Shutdown() {
@@ -385,6 +389,7 @@ void EditorWindow::OnResize(UINT width, UINT height) {
if (!matchesPredictedClientSize) {
ApplyWindowResize(width, height);
}
RequestFrame(EditorWindowFrameRequestReason::Resize);
}
void EditorWindow::OnEnterSizeMove() {
@@ -399,6 +404,7 @@ void EditorWindow::OnExitSizeMove() {
if (QueryCurrentClientPixelSize(width, height)) {
ApplyWindowResize(width, height);
}
RequestFrame(EditorWindowFrameRequestReason::ExitSizeMove);
}
void EditorWindow::OnDpiChanged(UINT dpi, const RECT& suggestedRect) {
@@ -427,6 +433,7 @@ void EditorWindow::OnDpiChanged(UINT dpi, const RECT& suggestedRect) {
trace << "dpi changed to " << m_chromeController->GetWindowDpi()
<< " scale=" << GetDpiScale();
LogRuntimeTrace("window", trace.str());
RequestFrame(EditorWindowFrameRequestReason::DpiChanged);
}
bool EditorWindow::IsVerboseRuntimeTraceEnabled() {
@@ -651,19 +658,15 @@ EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
return transferRequests;
}
EditorWindowFrameTransferRequests EditorWindow::OnPaintMessage(
EditorContext& editorContext,
bool globalTabDragActive) {
void EditorWindow::OnPaintMessage() {
if (!m_runtime->IsReady() || m_state->window.hwnd == nullptr) {
return {};
return;
}
PAINTSTRUCT paintStruct = {};
BeginPaint(m_state->window.hwnd, &paintStruct);
const EditorWindowFrameTransferRequests transferRequests =
RenderFrame(editorContext, globalTabDragActive);
EndPaint(m_state->window.hwnd, &paintStruct);
return transferRequests;
RequestFrame(EditorWindowFrameRequestReason::PaintMessage);
}
UIRect EditorWindow::ResolveWorkspaceBounds(float clientWidthDips, float clientHeightDips) const {
@@ -926,6 +929,17 @@ void EditorWindow::ResetInputModifiers() {
void EditorWindow::RequestManualScreenshot() {
m_runtime->RequestManualScreenshot("manual_f12");
RequestFrame(EditorWindowFrameRequestReason::ManualScreenshot);
}
void EditorWindow::RequestFrame(EditorWindowFrameRequestReason reason) {
m_pendingFrameRequestReasons |= ToFrameRequestMask(reason);
}
std::uint32_t EditorWindow::ConsumePendingFrameRequestReasons() {
const std::uint32_t pendingFrameRequestReasons = m_pendingFrameRequestReasons;
m_pendingFrameRequestReasons = 0u;
return pendingFrameRequestReasons;
}
bool EditorWindow::IsPointerInsideClientArea() const {