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 <KRun>
|
||||||
#include <KServiceTypeTrader>
|
#include <KServiceTypeTrader>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
|
#include <KWindowSystem>
|
||||||
|
|
||||||
#include "applethandle_p.h"
|
#include "applethandle_p.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
|
@ -74,12 +75,25 @@ public:
|
||||||
{
|
{
|
||||||
if (!toolbox) {
|
if (!toolbox) {
|
||||||
toolbox = new DesktopToolbox(q);
|
toolbox = new DesktopToolbox(q);
|
||||||
toolbox->setPos(q->geometry().width() - toolbox->boundingRect().width(), 0);
|
positionToolbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolbox;
|
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();
|
void setLockToolText();
|
||||||
|
|
||||||
Containment *q;
|
Containment *q;
|
||||||
|
@ -743,11 +757,20 @@ void Containment::setScreen(int screen)
|
||||||
{
|
{
|
||||||
// screen of -1 means no associated screen.
|
// screen of -1 means no associated screen.
|
||||||
// sanity check to make sure someone else doesn't have this screen already!
|
// sanity check to make sure someone else doesn't have this screen already!
|
||||||
if (screen > -1 && containmentType() == DesktopContainment && corona()) {
|
if (containmentType() == DesktopContainment) {
|
||||||
Containment* currently = corona()->containmentForScreen(screen);
|
// we want to listen to changes in work area if our screen changes
|
||||||
if (currently && currently != this) {
|
if (d->screen < 0 && screen > -1) {
|
||||||
//kDebug() << "currently is on screen" << currently->screen() << "and is" << currently->name() << (QObject*)currently << (QObject*)this;
|
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(repositionToolbox()));
|
||||||
currently->setScreen(-1);
|
} 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();
|
d->createToolbox()->hideToolbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Containment::repositionToolbox()
|
||||||
|
{
|
||||||
|
//kDebug() << "reposition" << d->screen << (QObject*)d->toolbox;
|
||||||
|
if (d->toolbox) {
|
||||||
|
d->positionToolbox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "containment.moc"
|
#include "containment.moc"
|
||||||
|
|
|
@ -361,6 +361,11 @@ class PLASMA_EXPORT Containment : public Applet
|
||||||
void handleDisappeared(AppletHandle *handle);
|
void handleDisappeared(AppletHandle *handle);
|
||||||
void destroyApplet();
|
void destroyApplet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repositions the Plasma toolbox. Useful to ensure its always in the correct place within the view.
|
||||||
|
*/
|
||||||
|
void repositionToolbox();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF geometryForApplet(Applet *applet) const;
|
QRectF geometryForApplet(Applet *applet) const;
|
||||||
bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const;
|
bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user