KDE/kdelibs/plasma

Aaron J. Seigo aseigo at kde.org
Fri Jan 23 08:33:32 CET 2009


SVN commit 915488 by aseigo:

a lot less popup flickering and repainting. if there are no sideeffects to this discovered, this needs to be backported to the 4.2 branch.
CCMAIL:plasma-devel at kde.org


 M  +39 -30    dialog.cpp  
 M  +8 -9      popupapplet.cpp  


--- trunk/KDE/kdelibs/plasma/dialog.cpp #915487:915488
@@ -48,8 +48,6 @@
 #include <X11/Xlib.h>
 #endif
 
-const int resizeAreaMargin = 20;
-
 namespace Plasma
 {
 
@@ -72,8 +70,10 @@
 
     void themeUpdated();
     void adjustView();
+    void updateResizeCorners();
 
     Plasma::Dialog *q;
+
     /**
      * Holds the background SVG, to be re-rendered when the cache is invalidated,
      * for example by resizing the dialogue.
@@ -124,6 +124,7 @@
     } else {
         q->setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight);
     }
+
     q->update();
 }
 
@@ -196,32 +197,8 @@
 void Dialog::paintEvent(QPaintEvent *e)
 {
     QPainter p(this);
-    p.setRenderHint(QPainter::Antialiasing);
-    p.setClipRect(e->rect());
     p.setCompositionMode(QPainter::CompositionMode_Source);
-    d->background->paintFrame(&p);
-
-    //we set the resize handlers
-    d->resizeAreas.clear();
-    if (d->resizeCorners & Dialog::NorthEast) {
-        d->resizeAreas[Dialog::NorthEast] = QRect(rect().right() - resizeAreaMargin, 0,
-                                             resizeAreaMargin, resizeAreaMargin);
-    }
-
-    if (d->resizeCorners & Dialog::NorthWest) {
-        d->resizeAreas[Dialog::NorthWest] = QRect(0, 0, resizeAreaMargin, resizeAreaMargin);
-    }
-
-    if (d->resizeCorners & Dialog::SouthEast) {
-        d->resizeAreas[Dialog::SouthEast] = QRect(rect().right() - resizeAreaMargin,
-                                            rect().bottom() - resizeAreaMargin,
-                                            resizeAreaMargin, resizeAreaMargin);
-    }
-
-    if (d->resizeCorners & Dialog::SouthWest) {
-        d->resizeAreas[Dialog::SouthWest] = QRect(0, rect().bottom() - resizeAreaMargin,
-                                            resizeAreaMargin, resizeAreaMargin);
-    }
+    d->background->paintFrame(&p, e->rect());
 }
 
 void Dialog::mouseMoveEvent(QMouseEvent *event)
@@ -340,8 +317,38 @@
         d->view->setSceneRect(d->widget->mapToScene(d->widget->boundingRect()).boundingRect());
         d->view->centerOn(d->widget);
     }
+
+    d->updateResizeCorners();
 }
 
+void DialogPrivate::updateResizeCorners()
+{
+    const int resizeAreaMargin = 20;
+    const QRect r = q->rect();
+
+    resizeAreas.clear();
+    if (resizeCorners & Dialog::NorthEast) {
+        resizeAreas[Dialog::NorthEast] = QRect(r.right() - resizeAreaMargin, 0,
+                                               resizeAreaMargin, resizeAreaMargin);
+    }
+
+    if (resizeCorners & Dialog::NorthWest) {
+        resizeAreas[Dialog::NorthWest] = QRect(0, 0, resizeAreaMargin, resizeAreaMargin);
+    }
+
+    if (resizeCorners & Dialog::SouthEast) {
+        resizeAreas[Dialog::SouthEast] = QRect(r.right() - resizeAreaMargin,
+                                               r.bottom() - resizeAreaMargin,
+                                               resizeAreaMargin, resizeAreaMargin);
+    }
+
+    if (resizeCorners & Dialog::SouthWest) {
+        resizeAreas[Dialog::SouthWest] = QRect(0, r.bottom() - resizeAreaMargin,
+                                               resizeAreaMargin, resizeAreaMargin);
+    }
+
+}
+
 void Dialog::setGraphicsWidget(QGraphicsWidget *widget)
 {
     if (d->widget) {
@@ -412,14 +419,16 @@
         d->view->setSceneRect(d->widget->mapToScene(d->widget->boundingRect()).boundingRect());
         d->view->centerOn(d->widget);
     }
-    
+
     emit dialogVisible(true);
 }
 
 void Dialog::setResizeHandleCorners(ResizeCorners corners)
 {
-    d->resizeCorners = corners;
-    update();
+    if (d->resizeCorners != corners) {
+        d->resizeCorners = corners;
+        d->updateResizeCorners();
+    }
 }
 
 Dialog::ResizeCorners Dialog::resizeCorners() const
--- trunk/KDE/kdelibs/plasma/popupapplet.cpp #915487:915488
@@ -478,7 +478,6 @@
         updateDialogPosition();
         KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
         dialog->show();
-        dialog->resize(dialog->size());
     }
 
     dialog->clearFocus();
@@ -544,22 +543,22 @@
     QSize saved(width, height);
 
     if (saved.isNull()) {
-        dialog->adjustSize();
+        saved = dialog->sizeHint();
     } else {
         saved = saved.expandedTo(dialog->minimumSizeHint());
+    }
+
+    if (saved.width() != dialog->width() || saved.height() != dialog->height()) {
         dialog->resize(saved);
     }
 
     QSize s = dialog->size();
     QPoint pos = view->mapFromScene(q->scenePos());
+
     //try to access a corona
-    if (q->containment() && q->containment()->corona()) {
-        pos = q->containment()->corona()->popupPosition(q, s);
-    } else {
-        Corona *corona = qobject_cast<Corona *>(q->scene());
-        if (corona) {
-            pos = corona->popupPosition(q, s);
-        }
+    Corona *corona = qobject_cast<Corona *>(q->scene());
+    if (corona) {
+        pos = corona->popupPosition(q, s);
     }
 
     bool reverse = false;


More information about the Plasma-devel mailing list