IDEA-172422 Popup at the wrong place on the second monitor (new hidpi)

Adopted: moved to AwtWindow::Reshape

(cherry picked from commit 11a0911d65)
This commit is contained in:
Anton Tarasov
2021-03-16 18:02:03 +03:00
committed by Vitaly Provodin
parent acedb2b62f
commit 9900fe019a

View File

@@ -1233,8 +1233,16 @@ void AwtWindow::Reshape(int x, int y, int w, int h) {
VERIFY(::GetWindowRect(parent->GetHWnd(), &rect));
int xOffset = /*ceil'd*/device->ScaleUpAbsX(device->ScaleDownAbsX(rect.left)) - rect.left;
int yOffset = /*ceil'd*/device->ScaleUpAbsY(device->ScaleDownAbsY(rect.top)) - rect.top;
scaleUpAbsX -= xOffset;
scaleUpAbsY -= yOffset;
int newX = scaleUpAbsX - xOffset;
int newY = scaleUpAbsY - yOffset;
// Check the toplevel is not going to be moved to another screen.
::SetRect(&rect, newX, newY, newX + w, newY + h);
HMONITOR hmon = ::MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
if (hmon != NULL && AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hmon) == device->GetDeviceIndex()) {
scaleUpAbsX = newX;
scaleUpAbsY = newY;
}
}
ReshapeNoScale(scaleUpAbsX, scaleUpAbsY, ScaleUpX(w), ScaleUpY(h));