Skip to content

Commit

Permalink
Bug 1838330: Make AppWindow::FullscreenWillChange correctly compare w…
Browse files Browse the repository at this point in the history
…indow 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
  • Loading branch information
bradwerth committed Jun 14, 2023
1 parent 8596ffe commit c03417c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions xpfe/appshell/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c03417c

Please sign in to comment.