From f9deb97229d31f8df0c5c91de128373aa8ffc4e1 Mon Sep 17 00:00:00 2001 From: stefnotch Date: Sun, 7 Feb 2021 18:03:23 +0100 Subject: [PATCH] Fix custom title bar high dpi issues Fix #4 --- Source/Editor/GUI/MainMenu.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Editor/GUI/MainMenu.cs b/Source/Editor/GUI/MainMenu.cs index f0f9458e7..081854046 100644 --- a/Source/Editor/GUI/MainMenu.cs +++ b/Source/Editor/GUI/MainMenu.cs @@ -186,14 +186,14 @@ namespace FlaxEditor.GUI private WindowHitCodes OnHitTest(ref Vector2 mouse) { var dpiScale = _window.DpiScale; - var pos = _window.ScreenToClient(mouse * dpiScale); if (_window.IsMinimized) return WindowHitCodes.NoWhere; if (!_window.IsMaximized) { - var winSize = RootWindow.Size * dpiScale; + var pos = _window.ScreenToClient(mouse * dpiScale); // pos is not DPI adjusted + var winSize = _window.Size; // Distance from which the mouse is considered to be on the border/corner float distance = 5.0f * dpiScale; @@ -223,11 +223,11 @@ namespace FlaxEditor.GUI return WindowHitCodes.Bottom; } - var menuPos = PointFromWindow(pos); - var controlUnderMouse = GetChildAt(menuPos); + var mousePos = PointFromScreen(mouse * dpiScale); + var controlUnderMouse = GetChildAt(mousePos); var isMouseOverSth = controlUnderMouse != null && controlUnderMouse != _title; var rb = GetRightButton(); - if (rb != null && _minimizeButton != null && new Rectangle(rb.UpperRight * dpiScale, (_minimizeButton.BottomLeft - rb.UpperRight) * dpiScale).Contains(ref menuPos) && !isMouseOverSth) + if (rb != null && _minimizeButton != null && new Rectangle(rb.UpperRight, _minimizeButton.BottomLeft - rb.UpperRight).Contains(ref mousePos) && !isMouseOverSth) return WindowHitCodes.Caption; return WindowHitCodes.Client;