Bug 1514501 - Fix screen selection and scaling for fullscreen r=jmathies

I needed to scale the layout device pixels coming from Windows before passing them to ScreenForRect(). Also, I'm using GetRect() directly instead of GetRectDisplayPix() * scale now, to avoid an unnecessary double scale & round which was making fullscreen windows off by one pixel in many cases.

Differential Revision: https://phabricator.services.mozilla.com/D15604

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Adam Gashlin 2019-01-09 16:35:40 +00:00
Родитель 59081613bd
Коммит 22936a258f
1 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -6500,19 +6500,22 @@ void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info) {
nsCOMPtr<nsIScreenManager> screenmgr =
do_GetService(sScreenManagerContractID);
if (screenmgr) {
LayoutDeviceIntRect bounds(info->x, info->y, info->cx, info->cy);
DesktopIntRect deskBounds =
RoundedToInt(bounds / GetDesktopToDeviceScale());
nsCOMPtr<nsIScreen> screen;
screenmgr->ScreenForRect(info->x, info->y, info->cx, info->cy,
screenmgr->ScreenForRect(deskBounds.X(), deskBounds.Y(),
deskBounds.Width(), deskBounds.Height(),
getter_AddRefs(screen));
if (screen) {
int32_t x, y, width, height;
screen->GetRectDisplayPix(&x, &y, &width, &height);
double scale = GetDesktopToDeviceScale().scale;
screen->GetRect(&x, &y, &width, &height);
info->x = NSToIntRound(x * scale);
info->y = NSToIntRound(y * scale);
info->cx = NSToIntRound(width * scale);
info->cy = NSToIntRound(height * scale);
info->x = x;
info->y = y;
info->cx = width;
info->cy = height;
}
}
}