From 4d9ef32abc6bb5297d7a8612c4ae434272db8341 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 27 Dec 2023 00:29:30 +0100 Subject: [PATCH] Fix auto-docking windows on open when system DPI scale is not `1` --- Source/Editor/GUI/Docking/DockWindow.cs | 7 ++----- Source/Editor/Modules/WindowsModule.cs | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Editor/GUI/Docking/DockWindow.cs b/Source/Editor/GUI/Docking/DockWindow.cs index dd4e39ce2..72c74ad9e 100644 --- a/Source/Editor/GUI/Docking/DockWindow.cs +++ b/Source/Editor/GUI/Docking/DockWindow.cs @@ -63,12 +63,9 @@ namespace FlaxEditor.GUI.Docking public bool IsHidden => !Visible || _dockedTo == null; /// - /// Gets the default window size. + /// Gets the default window size (in UI units, unscaled by DPI which is handled by windowing system). /// - /// - /// Scaled by the DPI, because the window should be large enough for its content on every monitor - /// - public virtual Float2 DefaultSize => new Float2(900, 580) * DpiScale; + public virtual Float2 DefaultSize => new Float2(900, 580); /// /// Gets the serialization typename. diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index cda83b56e..245fd4d5d 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -676,7 +676,9 @@ namespace FlaxEditor.Modules if (newLocation == DockState.Float) { // Check if there is a floating window that has the same size - var defaultSize = window.DefaultSize; + var dpi = (float)Platform.Dpi / 96.0f; + var dpiScale = Platform.CustomDpiScale; + var defaultSize = window.DefaultSize * dpi; for (var i = 0; i < Editor.UI.MasterPanel.FloatingPanels.Count; i++) { var win = Editor.UI.MasterPanel.FloatingPanels[i]; @@ -688,7 +690,7 @@ namespace FlaxEditor.Modules } } - window.ShowFloating(defaultSize); + window.ShowFloating(defaultSize * dpiScale); } else {