diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index a525589a83..7ae9196fe1 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -4511,15 +4511,20 @@ static const Displays::Display* getCurrentDisplayFromScaleFactor (HWND hwnd) //============================================================================== struct MonitorInfo { - MonitorInfo (bool main, RECT rect, double d) noexcept - : isMain (main), bounds (rect), dpi (d) {} + MonitorInfo (bool main, RECT totalArea, RECT workArea, double d) noexcept + : isMain (main), + totalAreaRect (totalArea), + workAreaRect (workArea), + dpi (d) + { + } bool isMain; - RECT bounds; + RECT totalAreaRect, workAreaRect; double dpi; }; -static BOOL CALLBACK enumMonitorsProc (HMONITOR hm, HDC, LPRECT r, LPARAM userInfo) +static BOOL CALLBACK enumMonitorsProc (HMONITOR hm, HDC, LPRECT, LPARAM userInfo) { MONITORINFO info = {}; info.cbSize = sizeof (info); @@ -4536,7 +4541,7 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR hm, HDC, LPRECT r, LPARAM userIn dpi = (dpiX + dpiY) / 2.0; } - ((Array*) userInfo)->add ({ isMain, *r, dpi }); + ((Array*) userInfo)->add ({ isMain, info.rcMonitor, info.rcWork, dpi }); return TRUE; } @@ -4550,7 +4555,10 @@ void Displays::findDisplays (float masterScale) auto globalDPI = getGlobalDPI(); if (monitors.size() == 0) - monitors.add ({ true, getWindowRect (GetDesktopWindow()), globalDPI }); + { + auto windowRect = getWindowRect (GetDesktopWindow()); + monitors.add ({ true, windowRect, windowRect, globalDPI }); + } // make sure the first in the list is the main monitor for (int i = 1; i < monitors.size(); ++i) @@ -4574,17 +4582,8 @@ void Displays::findDisplays (float masterScale) d.scale = (d.dpi / USER_DEFAULT_SCREEN_DPI) * (masterScale / Desktop::getDefaultMasterScale()); } - d.userArea = d.totalArea = Rectangle::leftTopRightBottom (monitor.bounds.left, monitor.bounds.top, - monitor.bounds.right, monitor.bounds.bottom); - - if (d.isMain) - { - RECT workArea; - SystemParametersInfo (SPI_GETWORKAREA, 0, &workArea, 0); - - d.userArea = d.userArea.getIntersection (Rectangle::leftTopRightBottom (workArea.left, workArea.top, - workArea.right, workArea.bottom)); - } + d.totalArea = rectangleFromRECT (monitor.totalAreaRect); + d.userArea = rectangleFromRECT (monitor.workAreaRect); displays.add (d); }