From c03417c28426efacc1d4c0519d84500930a81f94 Mon Sep 17 00:00:00 2001 From: Brad Werth Date: Wed, 14 Jun 2023 18:53:34 +0000 Subject: [PATCH] Bug 1838330: Make AppWindow::FullscreenWillChange correctly compare window to screen using device scale. r=edgar The implementation of AppWindow::ForceRoundedDimensions makes clear that the window size from GetSize` is unscaled. This patch updates the math in FullscreenWillChange to also consider devices pixels per css pixel. Differential Revision: https://phabricator.services.mozilla.com/D180886 --- xpfe/appshell/AppWindow.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/xpfe/appshell/AppWindow.cpp b/xpfe/appshell/AppWindow.cpp index 95a810b6e501..aaa78e49152e 100644 --- a/xpfe/appshell/AppWindow.cpp +++ b/xpfe/appshell/AppWindow.cpp @@ -2968,20 +2968,19 @@ void AppWindow::FullscreenWillChange(bool aInFullscreen) { } MOZ_ASSERT(mFullscreenChangeState == FullscreenChangeState::NotChanging); - int32_t winWidth = 0; - int32_t winHeight = 0; - GetSize(&winWidth, &winHeight); + CSSToLayoutDeviceScale scale = UnscaledDevicePixelsPerCSSPixel(); + CSSIntSize windowSizeCSS = RoundedToInt(GetSize() / scale); - int32_t screenWidth = 0; - int32_t screenHeight = 0; - GetAvailScreenSize(&screenWidth, &screenHeight); + CSSIntSize screenSizeCSS; + GetAvailScreenSize(&screenSizeCSS.width, &screenSizeCSS.height); // Check if the window is already at the expected dimensions. If it is, set // the fullscreen change state to WidgetResized to avoid waiting for a resize // event. On macOS, a fullscreen window could be slightly higher than // available screen size because of the OS menu bar isn't yet hidden. mFullscreenChangeState = - (aInFullscreen == (winWidth == screenWidth && winHeight >= screenHeight)) + (aInFullscreen == (windowSizeCSS.width == screenSizeCSS.width && + windowSizeCSS.height >= screenSizeCSS.height)) ? FullscreenChangeState::WidgetResized : FullscreenChangeState::WillChange; } -- 2.11.4.GIT