From 7799bbb57ab90264334727f752c677c35d74889f Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 26 Sep 2021 21:16:49 +0200 Subject: [PATCH] ui: Improved borderless window resizing and moving --- source/window/win_window.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/window/win_window.cpp b/source/window/win_window.cpp index 550290194..fbf9ac566 100644 --- a/source/window/win_window.cpp +++ b/source/window/win_window.cpp @@ -99,8 +99,8 @@ POINT cursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; const POINT border{ - static_cast((::GetSystemMetrics(SM_CXFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 2.0F), - static_cast((::GetSystemMetrics(SM_CYFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 2.0F) + static_cast((::GetSystemMetrics(SM_CXFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 1.5F), + static_cast((::GetSystemMetrics(SM_CYFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER)) * SharedData::globalScale / 1.5F) }; RECT window; @@ -120,6 +120,9 @@ RegionTop * (cursor.y < (window.top + border.y)) | RegionBottom * (cursor.y >= (window.bottom - border.y)); + if (result != 0 && (ImGui::IsItemHovered() || ImGui::IsPopupOpen(nullptr, ImGuiPopupFlags_AnyPopupId))) + break; + switch (result) { case RegionLeft: return HTLEFT; @@ -139,7 +142,7 @@ return HTBOTTOMRIGHT; case RegionClient: default: - if ((cursor.y < (window.top + titleBarHeight)) && !(ImGui::IsAnyItemHovered() || ImGui::IsAnyItemFocused())) + if ((cursor.y < (window.top + titleBarHeight * 2)) && !(ImGui::IsAnyItemHovered() || ImGui::IsPopupOpen(nullptr, ImGuiPopupFlags_AnyPopupId))) return HTCAPTION; else break; }