From da190fa711c3d29e155de2dccbd0a3494a9e9cae Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 13 May 2014 14:15:46 +0200 Subject: [PATCH] Reduce calls to ShellCorona::screenForContainment Just store some values instead of calling repeatedly without reason. --- .../qml/plasmoid/containmentinterface.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index a1569c98e..21752876f 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -170,14 +170,15 @@ void ContainmentInterface::setContainmentType(Plasma::Types::ContainmentType typ QVariantList ContainmentInterface::availableScreenRegion() const { QRegion reg = QRect(0, 0, width(), height()); - if (containment()->screen() > -1 && containment()->corona()) { - reg = containment()->corona()->availableScreenRegion(containment()->screen()); + int screenId = screen(); + if (screenId > -1 && containment()->corona()) { + reg = containment()->corona()->availableScreenRegion(screenId); } QVariantList regVal; foreach (QRect rect, reg.rects()) { //make it relative - QRect geometry = containment()->corona()->screenGeometry(containment()->screen()); + QRect geometry = containment()->corona()->screenGeometry(screenId); rect.moveTo(rect.topLeft() - geometry.topLeft()); regVal << QVariant::fromValue(QRectF(rect)); } @@ -188,10 +189,12 @@ QRect ContainmentInterface::availableScreenRect() const { QRect rect(0, 0, width(), height()); - if (containment()->screen() > -1 && containment()->corona()) { - rect = containment()->corona()->availableScreenRect(containment()->screen()); + int screenId = screen(); + + if (screenId > -1 && containment()->corona()) { + rect = containment()->corona()->availableScreenRect(screenId); //make it relative - QRect geometry = containment()->corona()->screenGeometry(containment()->screen()); + QRect geometry = containment()->corona()->screenGeometry(screenId); rect.moveTo(rect.topLeft() - geometry.topLeft()); }