a bit smarter policy to enable/disable borders:

-if the dialog is far from the panel, don't disable the corresponding border
-if the panel is smaller then the dialog, don't disable the corresponding border


svn path=/trunk/KDE/kdelibs/; revision=1083523
This commit is contained in:
Marco Martin 2010-02-01 12:02:20 +00:00
parent 87548ab1b2
commit fd7b4fa730

View File

@ -45,6 +45,7 @@
#include "plasma/applet.h" #include "plasma/applet.h"
#include "plasma/animator.h" #include "plasma/animator.h"
#include "plasma/containment.h"
#include "plasma/extenders/extender.h" #include "plasma/extenders/extender.h"
#include "plasma/private/extender_p.h" #include "plasma/private/extender_p.h"
#include "plasma/framesvg.h" #include "plasma/framesvg.h"
@ -129,34 +130,58 @@ void DialogPrivate::themeChanged()
} }
} }
} }
//used to remove borders at the edge of the desktop
QDesktopWidget *desktop = QApplication::desktop();
QRect avail = desktop->availableGeometry(desktop->screenNumber(q));
QRect screenGeom = desktop->screenGeometry(desktop->screenNumber(q));
QRect dialogGeom = q->geometry();
//decide about disabling the border attached to the panel
if (applet) { if (applet) {
background->getMargins(leftWidth, topHeight, rightWidth, bottomHeight); background->getMargins(leftWidth, topHeight, rightWidth, bottomHeight);
switch (applet->location()) { switch (applet->location()) {
case BottomEdge: case BottomEdge:
if (applet->containment() &&
dialogGeom.bottom() + 2 >= screenGeom.bottom() - applet->containment()->size().height() &&
dialogGeom.width() <= applet->containment()->size().width()) {
borders &= ~FrameSvg::BottomBorder; borders &= ~FrameSvg::BottomBorder;
leftWidth = 0; leftWidth = 0;
rightWidth = 0; rightWidth = 0;
bottomHeight = 0; bottomHeight = 0;
}
break; break;
case TopEdge: case TopEdge:
if (applet->containment() &&
dialogGeom.top() <= screenGeom.top() + applet->containment()->size().height() &&
dialogGeom.width() <= applet->containment()->size().width()) {
borders &= ~FrameSvg::TopBorder; borders &= ~FrameSvg::TopBorder;
topHeight = 0; topHeight = 0;
leftWidth = 0; leftWidth = 0;
rightWidth = 0; rightWidth = 0;
}
break; break;
case LeftEdge: case LeftEdge:
if (applet->containment() &&
dialogGeom.left() <= screenGeom.left() + applet->containment()->size().width() &&
dialogGeom.height() <= applet->containment()->size().height()) {
borders &= ~FrameSvg::LeftBorder; borders &= ~FrameSvg::LeftBorder;
leftWidth = 0; leftWidth = 0;
rightWidth = 0; rightWidth = 0;
}
break; break;
case RightEdge: case RightEdge:
if (applet->containment() &&
dialogGeom.right() + 2 >= screenGeom.right() - applet->containment()->size().width() &&
dialogGeom.height() <= applet->containment()->size().height()) {
borders &= ~FrameSvg::RightBorder; borders &= ~FrameSvg::RightBorder;
leftWidth = 0; leftWidth = 0;
rightWidth = 0; rightWidth = 0;
}
break; break;
default: default:
@ -164,23 +189,26 @@ void DialogPrivate::themeChanged()
} }
} }
//decide if to disable the other borders
if (!extender && q->isVisible()) { if (!extender && q->isVisible()) {
//remove borders at the edge of the desktop QRect geom;
QDesktopWidget *desktop = QApplication::desktop(); if (applet) {
QRect avail = desktop->availableGeometry(desktop->screenNumber(q)); geom = screenGeom;
QRect dialogGeom = q->geometry(); } else {
geom = avail;
}
if (dialogGeom.left() <= avail.left()) { if (dialogGeom.left() <= geom.left()) {
borders &= ~FrameSvg::LeftBorder; borders &= ~FrameSvg::LeftBorder;
} }
if (dialogGeom.top() <= avail.top()) { if (dialogGeom.top() <= geom.top()) {
borders &= ~FrameSvg::TopBorder; borders &= ~FrameSvg::TopBorder;
} }
//FIXME: that 2 pixels offset has probably something to do with kwin //FIXME: that 2 pixels offset has probably something to do with kwin
if (dialogGeom.right() + 2 > avail.right()) { if (dialogGeom.right() + 2 > geom.right()) {
borders &= ~FrameSvg::RightBorder; borders &= ~FrameSvg::RightBorder;
} }
if (dialogGeom.bottom() + 2 > avail.bottom()) { if (dialogGeom.bottom() + 2 > geom.bottom()) {
borders &= ~FrameSvg::BottomBorder; borders &= ~FrameSvg::BottomBorder;
} }
} }