Refine editor native window frame contract
This commit is contained in:
@@ -156,6 +156,81 @@ bool EditorWindow::HasLiveHostWindow() const {
|
||||
return hwnd != nullptr && IsWindow(hwnd);
|
||||
}
|
||||
|
||||
EditorNativeWindowMetrics EditorWindow::CaptureMetrics() const {
|
||||
return EditorNativeWindowMetrics{
|
||||
.dpiScale = GetDpiScale(),
|
||||
};
|
||||
}
|
||||
|
||||
bool EditorWindow::CaptureRuntimeSurface(
|
||||
const EditorHostWindow& window,
|
||||
EditorNativeWindowRuntimeSurface& outSurface) {
|
||||
(void)window;
|
||||
outSurface = {};
|
||||
const HWND hwnd = m_session->GetHwnd();
|
||||
if (hwnd == nullptr || !IsWindow(hwnd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint32_t clientWidth = 0u;
|
||||
std::uint32_t clientHeight = 0u;
|
||||
if (!QueryCurrentClientPixelSize(clientWidth, clientHeight)) {
|
||||
clientWidth = 1u;
|
||||
clientHeight = 1u;
|
||||
}
|
||||
|
||||
outSurface.nativeWindowHandle = hwnd;
|
||||
outSurface.widthPixels = clientWidth;
|
||||
outSurface.heightPixels = clientHeight;
|
||||
outSurface.dpiScale = GetDpiScale();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorWindow::CaptureFrameSnapshot(
|
||||
const EditorHostWindow& window,
|
||||
const UIEditorShellInteractionState& shellState,
|
||||
EditorNativeWindowFrameSnapshot& outSnapshot) {
|
||||
outSnapshot = {};
|
||||
if (!HasLiveHostWindow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint32_t pixelWidth = 0u;
|
||||
std::uint32_t pixelHeight = 0u;
|
||||
if (!ResolveRenderClientPixelSize(pixelWidth, pixelHeight)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SyncShellCapturedPointerButtonsFromSystemState(shellState);
|
||||
|
||||
const float width = PixelsToDips(static_cast<float>(pixelWidth));
|
||||
const float height = PixelsToDips(static_cast<float>(pixelHeight));
|
||||
const bool useDetachedTitleBarTabStrip =
|
||||
ShouldUseDetachedTitleBarTabStrip(window);
|
||||
|
||||
outSnapshot.widthPixels = pixelWidth;
|
||||
outSnapshot.heightPixels = pixelHeight;
|
||||
outSnapshot.widthDips = width;
|
||||
outSnapshot.heightDips = height;
|
||||
outSnapshot.dpiScale = GetDpiScale();
|
||||
outSnapshot.workspaceBounds = ResolveWorkspaceBounds(window, width, height);
|
||||
outSnapshot.inputEvents = TakePendingInputEvents();
|
||||
outSnapshot.cursorScreenPoint = QueryCursorScreenPoint();
|
||||
outSnapshot.useDetachedTitleBarTabStrip = useDetachedTitleBarTabStrip;
|
||||
return outSnapshot.IsValid();
|
||||
}
|
||||
|
||||
void EditorWindow::ApplyFrameCommands(
|
||||
const EditorHostWindow& window,
|
||||
const EditorNativeWindowFrameCommands& commands) {
|
||||
if (commands.applyShellRuntimePointerCapture) {
|
||||
ApplyShellRuntimePointerCapture(window);
|
||||
}
|
||||
if (commands.applyCurrentCursor) {
|
||||
ApplyCurrentCursor();
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring& EditorWindow::GetTitle() const {
|
||||
return m_owner.GetTitle();
|
||||
}
|
||||
@@ -194,10 +269,6 @@ void EditorWindow::InvalidateHostWindow() const {
|
||||
}
|
||||
}
|
||||
|
||||
void* EditorWindow::GetNativeWindowHandle() const {
|
||||
return m_session->GetHwnd();
|
||||
}
|
||||
|
||||
void EditorWindow::PrepareRuntimeInitialization(EditorHostWindow& window) {
|
||||
(void)window;
|
||||
Host::RefreshBorderlessWindowDwmDecorations(m_session->GetHwnd());
|
||||
|
||||
Reference in New Issue
Block a user