From e0ea93cb7e37462e0012d097b156ca75609ac737 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 28 Aug 2014 17:35:05 +0200 Subject: [PATCH] Dialog: Use the correct screen for repositioning when overflowing --- src/plasmaquick/dialog.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 55303267b..b62c8db91 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -99,6 +99,8 @@ public: */ void updateLayoutParameters(); + QRect availableScreenGeometryForPosition(const QPoint& pos) const; + /** * This function checks the current position of the dialog and repositions * it so that no part of it is not on the screen @@ -129,7 +131,7 @@ public: QPointer mainItemLayout; }; -void DialogPrivate::syncBorders() +QRect DialogPrivate::availableScreenGeometryForPosition(const QPoint& pos) const { // FIXME: QWindow::screen() never ever changes if the window is moved across // virtual screens (normal two screens with X), this seems to be intentional @@ -138,7 +140,6 @@ void DialogPrivate::syncBorders() // we simply iterate over the virtual screens and pick the one our QWindow // says it's at. QRect avail; - QPoint pos = q->position(); Q_FOREACH (QScreen *screen, q->screen()->virtualSiblings()) { if (screen->availableGeometry().contains(pos)) { avail = screen->availableGeometry(); @@ -146,6 +147,12 @@ void DialogPrivate::syncBorders() } } + return avail; +} + +void DialogPrivate::syncBorders() +{ + QRect avail = availableScreenGeometryForPosition(q->position()); int borders = Plasma::FrameSvg::AllBorders; //Tooltips always have all the borders @@ -462,7 +469,7 @@ void DialogPrivate::repositionIfOffScreen() if (!componentComplete) { return; } - const QRect avail = q->screen()->availableGeometry(); + const QRect avail = availableScreenGeometryForPosition(q->position()); int x = q->x(); int y = q->y();