[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdelibs/KDE/4.10] plasma: Fix border detection in Plasma dialogs
From:       Aleix Pol <aleixpol () kde ! org>
Date:       2013-03-21 17:41:41
Message-ID: 20130321174141.98D63A604F () git ! kde ! org
[Download RAW message or body]

Git commit 4602e8155078a28968c2e85ebab6351efc2dd7ac by Aleix Pol.
Committed on 21/03/2013 at 18:40.
Pushed by apol into branch 'KDE/4.10'.

Fix border detection in Plasma dialogs

I had some problems with plasma dialogs borders, they appeared arbitrarily.
After a good couple of hours of debugging, I found out that there was some
really weird processing of the available region.

This patch removes this processing and uses QRegion itself to figure out if
the border has to be painted.

REVIEW: 109641

M  +7    -14   plasma/dialog.cpp

http://commits.kde.org/kdelibs/4602e8155078a28968c2e85ebab6351efc2dd7ac

diff --git a/plasma/dialog.cpp b/plasma/dialog.cpp
index 038444c..5307db0 100644
--- a/plasma/dialog.cpp
+++ b/plasma/dialog.cpp
@@ -141,7 +141,7 @@ void DialogPrivate::checkBorders(bool updateMaskIfNeeded)
     Plasma::Applet *applet = appletPtr.data();
 
     //used to remove borders at the edge of the desktop
-    QRect avail;
+    QRegion avail;
     QRect screenGeom;
     QDesktopWidget *desktop = QApplication::desktop();
     Plasma::Corona *c = 0;
@@ -151,17 +151,10 @@ void DialogPrivate::checkBorders(bool updateMaskIfNeeded)
         c = qobject_cast<Plasma::Corona *>(graphicsWidget->scene());
     }
     if (c) {
-        QRegion r = c->availableScreenRegion(desktop->screenNumber(q));
-        QRect maxRect;
-        foreach (QRect rect, r.rects()) {
-            if (rect.width() > maxRect.width() && rect.height() > maxRect.height()) {
-                maxRect = rect;
-            }
-        }
-        avail = maxRect;
+        avail = c->availableScreenRegion(desktop->screenNumber(q));
         screenGeom = c->screenGeometry(desktop->screenNumber(q));
     } else {
-        avail = desktop->availableGeometry(desktop->screenNumber(q));
+        avail = QRegion(desktop->availableGeometry(desktop->screenNumber(q)));
         screenGeom = desktop->screenGeometry(desktop->screenNumber(q));
     }
 
@@ -227,17 +220,17 @@ void DialogPrivate::checkBorders(bool updateMaskIfNeeded)
 
     //decide if to disable the other borders
     if (q->isVisible() && !q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip)) {
-        if (dialogGeom.left() <= avail.left()) {
+        if (!avail.contains(QPoint(dialogGeom.left()-1, dialogGeom.center().y()))) {
             borders &= ~FrameSvg::LeftBorder;
         }
-        if (dialogGeom.top() <= avail.top()) {
+        if (!avail.contains(QPoint(dialogGeom.center().x(), dialogGeom.top()-1))) {
             borders &= ~FrameSvg::TopBorder;
         }
         //FIXME: that 2 pixels offset has probably something to do with kwin
-        if (dialogGeom.right() + 2 > avail.right()) {
+        if (!avail.contains(QPoint(dialogGeom.right()+1, dialogGeom.center().y()))) {
             borders &= ~FrameSvg::RightBorder;
         }
-        if (dialogGeom.bottom() + 2 > avail.bottom()) {
+        if (!avail.contains(QPoint(dialogGeom.center().x(), dialogGeom.bottom()+1))) {
             borders &= ~FrameSvg::BottomBorder;
         }
     }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic