From b9efa292b0f32fcd4c059b4435b9776d91dafd15 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 27 Mar 2015 14:10:20 +0100 Subject: [PATCH] make sure the coordinates are containment relative Change-Id: I82d3d6dded9701cd674a861a339cd60d6d12c962 Corona::availableScreenRegion has absolute coordinates, we need relative ones --- .../qml/plasmoid/containmentinterface.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 6ac7d7df5..f48e37212 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -313,12 +313,20 @@ QPointF ContainmentInterface::mapToApplet(AppletInterface *applet, int x, int y) QPointF ContainmentInterface::adjustToAvailableScreenRegion(int x, int y, int w, int h) const { - QRegion reg = QRect(0, 0, width(), height()); + QRegion reg; int screenId = screen(); if (screenId > -1 && m_containment->corona()) { reg = m_containment->corona()->availableScreenRegion(screenId); } + if (!reg.isEmpty()) { + //make it relative + QRect geometry = m_containment->corona()->screenGeometry(screenId); + reg.translate(- geometry.topLeft()); + } else { + reg = QRect(0, 0, width(), height()); + } + const QRect rect(qBound(reg.boundingRect().left(), x, reg.boundingRect().right() - w), qBound(reg.boundingRect().top(), y, reg.boundingRect().bottom() - h), w, h); const QRectF ar = availableScreenRect();