Bug 1254019 - Don't attempt to resize a maximized window on DPI change; and when handling a DPI change, constrain the resized window to the screen bounds. r=emk

This commit is contained in:
Jonathan Kew 2016-03-15 19:52:46 +00:00
parent 95bb5373a4
commit 36f8bc41ec

View File

@ -6882,7 +6882,7 @@ nsWindow::OnDPIChanged(int32_t x, int32_t y, int32_t width, int32_t height)
mDefaultScale = -1.0; // force recomputation of scale factor
double newScale = GetDefaultScaleInternal();
if (mResizeState != RESIZING) {
if (mResizeState != RESIZING && mSizeMode == nsSizeMode_Normal) {
// We want to try and maintain the size of the client area, rather than
// the overall size of the window including non-client area, so we prefer
// to calculate the new size instead of using Windows' suggested values.
@ -6899,6 +6899,22 @@ nsWindow::OnDPIChanged(int32_t x, int32_t y, int32_t width, int32_t height)
width = w;
height = h;
}
// Limit the position & size, if it would overflow the destination screen
nsCOMPtr<nsIScreenManager> sm = do_GetService(sScreenManagerContractID);
if (sm) {
nsCOMPtr<nsIScreen> screen;
sm->ScreenForRect(x, y, width, height, getter_AddRefs(screen));
if (screen) {
int32_t availLeft, availTop, availWidth, availHeight;
screen->GetAvailRect(&availLeft, &availTop, &availWidth, &availHeight);
x = std::max(x, availLeft);
y = std::max(y, availTop);
width = std::min(width, availWidth);
height = std::min(height, availHeight);
}
}
Resize(x, y, width, height, true);
}
ChangedDPI();