PerScreenDpi | Moving windows between screens with different scale changes the window size (#4064)
* Fix window size when dropped on a screen with a different scale setting compared to the one it was dragged from. Note that this fixes a bug that could only be reproduced with the PerScreenDpiAware setting activated - current editor uses SystemDpiAware. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Fix loss of precision warning. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
@@ -2461,6 +2461,18 @@ namespace AzQtComponents
|
||||
placeholderRect.translate(0, -margins.bottom());
|
||||
}
|
||||
|
||||
// Also adjust the placeholderRect by the relative dpi change from the original screen, since setGeometry uses the screen's
|
||||
// virtualGeometry!
|
||||
QScreen* fromScreen = dock->screen();
|
||||
QScreen* toScreen = Utilities::ScreenAtPoint(placeholderRect.topLeft());
|
||||
|
||||
if (fromScreen != toScreen)
|
||||
{
|
||||
qreal factorRatio = QHighDpiScaling::factor(fromScreen) / QHighDpiScaling::factor(toScreen);
|
||||
placeholderRect.setWidth(aznumeric_cast<int>(aznumeric_cast<qreal>(placeholderRect.width()) * factorRatio));
|
||||
placeholderRect.setHeight(aznumeric_cast<int>(aznumeric_cast<qreal>(placeholderRect.height()) * factorRatio));
|
||||
}
|
||||
|
||||
// Place the floating dock widget
|
||||
makeDockWidgetFloating(dock, placeholderRect);
|
||||
clearDraggingState();
|
||||
|
||||
Reference in New Issue
Block a user