keep the toolbox in the workArea (e.g. out from underneath panels and other strut reservers)
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=782438
This commit is contained in:
parent
05a8c2c56c
commit
8c4cfbca60
@ -36,6 +36,7 @@
|
||||
#include <KRun>
|
||||
#include <KServiceTypeTrader>
|
||||
#include <KStandardDirs>
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include "applethandle_p.h"
|
||||
#include "corona.h"
|
||||
@ -74,12 +75,25 @@ public:
|
||||
{
|
||||
if (!toolbox) {
|
||||
toolbox = new DesktopToolbox(q);
|
||||
toolbox->setPos(q->geometry().width() - toolbox->boundingRect().width(), 0);
|
||||
positionToolbox();
|
||||
}
|
||||
|
||||
return toolbox;
|
||||
}
|
||||
|
||||
void positionToolbox()
|
||||
{
|
||||
QRectF r;
|
||||
if (screen < 0) {
|
||||
r = q->geometry();
|
||||
} else {
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
r = desktop->availableGeometry(screen);
|
||||
}
|
||||
|
||||
toolbox->setPos(QPointF(r.right() - toolbox->boundingRect().width(), r.y()));
|
||||
}
|
||||
|
||||
void setLockToolText();
|
||||
|
||||
Containment *q;
|
||||
@ -743,11 +757,20 @@ void Containment::setScreen(int screen)
|
||||
{
|
||||
// screen of -1 means no associated screen.
|
||||
// sanity check to make sure someone else doesn't have this screen already!
|
||||
if (screen > -1 && containmentType() == DesktopContainment && corona()) {
|
||||
Containment* currently = corona()->containmentForScreen(screen);
|
||||
if (currently && currently != this) {
|
||||
//kDebug() << "currently is on screen" << currently->screen() << "and is" << currently->name() << (QObject*)currently << (QObject*)this;
|
||||
currently->setScreen(-1);
|
||||
if (containmentType() == DesktopContainment) {
|
||||
// we want to listen to changes in work area if our screen changes
|
||||
if (d->screen < 0 && screen > -1) {
|
||||
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(repositionToolbox()));
|
||||
} else if (screen < 0) {
|
||||
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(repositionToolbox()));
|
||||
}
|
||||
|
||||
if (screen > -1 && corona()) {
|
||||
Containment* currently = corona()->containmentForScreen(screen);
|
||||
if (currently && currently != this) {
|
||||
//kDebug() << "currently is on screen" << currently->screen() << "and is" << currently->name() << (QObject*)currently << (QObject*)this;
|
||||
currently->setScreen(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -991,6 +1014,14 @@ void Containment::hideToolbox()
|
||||
d->createToolbox()->hideToolbox();
|
||||
}
|
||||
|
||||
void Containment::repositionToolbox()
|
||||
{
|
||||
//kDebug() << "reposition" << d->screen << (QObject*)d->toolbox;
|
||||
if (d->toolbox) {
|
||||
d->positionToolbox();
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "containment.moc"
|
||||
|
@ -361,6 +361,11 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
void handleDisappeared(AppletHandle *handle);
|
||||
void destroyApplet();
|
||||
|
||||
/**
|
||||
* Repositions the Plasma toolbox. Useful to ensure its always in the correct place within the view.
|
||||
*/
|
||||
void repositionToolbox();
|
||||
|
||||
private:
|
||||
QRectF geometryForApplet(Applet *applet) const;
|
||||
bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const;
|
||||
|
Loading…
Reference in New Issue
Block a user