diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp index 5456356458..d259b28636 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.cpp @@ -80,6 +80,14 @@ namespace AzQtComponents QPoint midPoint = targetRect.topLeft() + QPoint(targetRect.width() / 2, targetRect.height() / 2); QScreen* pointScreen = QApplication::screenAt(midPoint); QRect rect(targetRect); + + // On environment with multiple screens with different scaling settings, the screen coordinate system may have gaps + // due to the screen real estate shrinking according to the scale. When that happens, if a widget is moved into the gap + // it will resize and translate with undefined behavior, causing a lot of jitter and flashes. + // To prevent this, whenever the widget would end up outside screen boundaries, we resize the widget to be twice its + // original size so that the center of the widget is back inside the screen boundaries, and set the ghost widget + // to paint the widget pixmap at half the previous size to make the process seamless. + // This makes the dragging a lot smoother in most situations. PaintMode paintMode = PaintMode::FULL; if (!pointScreen || pointScreen != screen) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h index 6649c6d848..5244bcdd0a 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FancyDockingGhostWidget.h @@ -46,11 +46,12 @@ namespace AzQtComponents bool m_visible = false; // maintain our own flag, so that we're always ready to render ignoring Qt's widget caching system bool m_clipToWidgets = false; + //! Determines the way the ghost widget pixmap should be painted on the widget. enum class PaintMode { - FULL = 0, - BOTTOMLEFT, - BOTTOMRIGHT + FULL = 0, //!< Paint the pixmap on the full widget + BOTTOMLEFT, //!< Paint the pixmap on the bottom left quarter of the widget, halving its size + BOTTOMRIGHT //!< Paint the pixmap on the bottom right quarter of the widget, halving its size }; PaintMode m_paintMode = PaintMode::FULL;