diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
commit | def92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch) | |
tree | 2ef34b9ad8bb9a9220e05d60352558b15f513894 /widget/windows/ScreenHelperWin.cpp | |
parent | Adding debian version 125.0.3-1. (diff) | |
download | firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/windows/ScreenHelperWin.cpp')
-rw-r--r-- | widget/windows/ScreenHelperWin.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/widget/windows/ScreenHelperWin.cpp b/widget/windows/ScreenHelperWin.cpp index 8a0ec3b608..945b8d1895 100644 --- a/widget/windows/ScreenHelperWin.cpp +++ b/widget/windows/ScreenHelperWin.cpp @@ -7,9 +7,12 @@ #include "ScreenHelperWin.h" #include "mozilla/Logging.h" +#include "mozilla/gfx/DeviceManagerDx.h" #include "nsTArray.h" #include "WinUtils.h" +#include <dxgi.h> + static mozilla::LazyLogModule sScreenLog("WidgetScreen"); namespace mozilla { @@ -74,8 +77,13 @@ static void GetDisplayInfo(const char16ptr_t aName, } } +struct CollectMonitorsParam { + nsTArray<RefPtr<Screen>> screens; +}; + BOOL CALLBACK CollectMonitors(HMONITOR aMon, HDC, LPRECT, LPARAM ioParam) { - auto screens = reinterpret_cast<nsTArray<RefPtr<Screen>>*>(ioParam); + CollectMonitorsParam* cmParam = + reinterpret_cast<CollectMonitorsParam*>(ioParam); BOOL success = FALSE; MONITORINFOEX info; info.cbSize = sizeof(MONITORINFOEX); @@ -123,6 +131,9 @@ BOOL CALLBACK CollectMonitors(HMONITOR aMon, HDC, LPRECT, LPARAM ioParam) { GetDisplayInfo(info.szDevice, orientation, angle, isPseudoDisplay, refreshRate); + auto* manager = gfx::DeviceManagerDx::Get(); + bool isHDR = manager ? manager->MonitorHDREnabled(aMon) : false; + MOZ_LOG(sScreenLog, LogLevel::Debug, ("New screen [%s (%s) %d %u %f %f %f %d %d %d]", ToString(rect).c_str(), ToString(availRect).c_str(), pixelDepth, @@ -131,26 +142,32 @@ BOOL CALLBACK CollectMonitors(HMONITOR aMon, HDC, LPRECT, LPARAM ioParam) { auto screen = MakeRefPtr<Screen>( rect, availRect, pixelDepth, pixelDepth, refreshRate, contentsScaleFactor, defaultCssScaleFactor, dpi, Screen::IsPseudoDisplay(isPseudoDisplay), - orientation, angle); + Screen::IsHDR(isHDR), orientation, angle); if (info.dwFlags & MONITORINFOF_PRIMARY) { // The primary monitor must be the first element of the screen list. - screens->InsertElementAt(0, std::move(screen)); + cmParam->screens.InsertElementAt(0, std::move(screen)); } else { - screens->AppendElement(std::move(screen)); + cmParam->screens.AppendElement(std::move(screen)); } return TRUE; } +/* static */ void ScreenHelperWin::RefreshScreens() { MOZ_LOG(sScreenLog, LogLevel::Debug, ("Refreshing screens")); - AutoTArray<RefPtr<Screen>, 4> screens; + auto* manager = gfx::DeviceManagerDx::Get(); + if (XRE_IsParentProcess() && manager) { + manager->UpdateMonitorInfo(); + } + + CollectMonitorsParam cmParam; BOOL result = ::EnumDisplayMonitors( - nullptr, nullptr, (MONITORENUMPROC)CollectMonitors, (LPARAM)&screens); + nullptr, nullptr, (MONITORENUMPROC)CollectMonitors, (LPARAM)&cmParam); if (!result) { NS_WARNING("Unable to EnumDisplayMonitors"); } - ScreenManager::Refresh(std::move(screens)); + ScreenManager::Refresh(std::move(cmParam.screens)); } } // namespace widget |