summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/widgets/qdockwidget.cpp13
-rw-r--r--src/widgets/widgets/qdockwidget_p.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 53cb21186f..f51e3c7988 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1024,6 +1024,12 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
}
}
+void QDockWidgetPrivate::recalculatePressPos(QResizeEvent *event)
+{
+ qreal ratio = event->oldSize().width() / (1.0 * event->size().width());
+ state->pressPos.setX(state->pressPos.x() / ratio);
+}
+
/*! \internal
Called when the QDockWidget or the QDockWidgetGroupWindow is moved
*/
@@ -1540,6 +1546,13 @@ bool QDockWidget::event(QEvent *event)
// if the mainwindow is plugging us, we don't want to update undocked geometry
if (isFloating() && layout != 0 && layout->pluggingWidget != this)
d->undockedGeometry = geometry();
+
+ // Usually the window won't get resized while it's being moved, but it can happen,
+ // for example on Windows when moving to a screen with bigger scale factor
+ // (and Qt::AA_EnableHighDpiScaling is enabled). If that happens we should
+ // update state->pressPos, otherwise it will be outside the window when the window shrinks.
+ if (d->state && d->state->dragging)
+ d->recalculatePressPos(static_cast<QResizeEvent*>(event));
break;
default:
break;
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 94a3ad3b34..84bf8efacf 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -118,6 +118,7 @@ public:
void startDrag(bool group = true);
void endDrag(bool abort = false);
void moveEvent(QMoveEvent *event);
+ void recalculatePressPos(QResizeEvent *event);
void unplug(const QRect &rect);
void plug(const QRect &rect);