Reduce calls to ShellCorona::screenForContainment

Just store some values instead of calling repeatedly without reason.
This commit is contained in:
Aleix Pol 2014-05-13 14:15:46 +02:00
parent cc661dfdd6
commit da190fa711

View File

@ -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());
}