From faf6d9976ade53a0a6f929ce9cf51cf7fb720853 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 29 Aug 2024 17:15:59 +0100 Subject: [PATCH] Windows: Fix WM_NCCALCSIZE behaviour for frameless windows on multiple display systems Previously, maximising a frameless window on a secondary display could result in the window's coordinates being computed incorrectly, leading to graphical glitches. --- .../native/juce_Windowing_windows.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index 4787935af0..2bb35c82b1 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -3938,8 +3938,17 @@ private: // so that the client area exactly fills the available space. if (isFullScreen()) { - const auto padX = -param->left; - const auto padY = -param->top; + const auto monitor = MonitorFromWindow (hwnd, MONITOR_DEFAULTTONULL); + + if (monitor == nullptr) + return 0; + + MONITORINFOEX info{}; + info.cbSize = sizeof (info); + GetMonitorInfo (monitor, &info); + + const auto padX = info.rcMonitor.left - param->left; + const auto padY = info.rcMonitor.top - param->top; param->left += padX; param->right -= padX; @@ -5242,7 +5251,7 @@ private: public: LowLevelGraphicsContext* startFrame (HWND hwnd, float scale, const RectangleList& dirty) { - RECT r; + RECT r{}; GetClientRect (hwnd, &r); const auto w = r.right - r.left;