diff --git a/applet.cpp b/applet.cpp index 3d689a528..4e636d4cc 100644 --- a/applet.cpp +++ b/applet.cpp @@ -870,7 +870,6 @@ QColor Applet::color() const void Applet::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - Q_UNUSED(widget) if (d->shadow && d->shadow->shadowedSize() != boundingRect().size()) { //kDebug() << "sizes are " << d->shadow->shadowedSize() << boundingRect().size(); d->shadow->generate(); @@ -893,10 +892,14 @@ void Applet::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *opti if (widget && isContainment()) { // note that the widget we get is actually the viewport of the view, not the view itself View* v = qobject_cast(widget->parent()); - if (v && !v->drawWallpaper()) { - painter->restore(); - return; + if (v && v->drawWallpaper()) { + Containment::StyleOption coption(*option); + coption.desktop = v->effectiveDesktop(); + paintInterface(painter, &coption, QRect(QPoint(0,0), d->contentSize(this).toSize())); } + + painter->restore(); + return; } //kDebug() << "paint interface of" << (QObject*) this; diff --git a/containment.cpp b/containment.cpp index a25ecedbc..31b66918f 100644 --- a/containment.cpp +++ b/containment.cpp @@ -58,7 +58,7 @@ public: : q(c), formFactor(Planar), location(Floating), - screen(-1), + screen(-1), // no screen toolbox(0), type(Containment::NoContainmentType) { @@ -90,6 +90,25 @@ public: Containment::Type type; }; +Containment::StyleOption::StyleOption() + : QStyleOptionGraphicsItem(), + desktop(-1) +{ + +} + +Containment::StyleOption::StyleOption(const Containment::StyleOption & other) + : QStyleOptionGraphicsItem(other), + desktop(other.desktop) +{ +} + +Containment::StyleOption::StyleOption(const QStyleOptionGraphicsItem &other) + : QStyleOptionGraphicsItem(other), + desktop(-1) +{ +} + Containment::Containment(QGraphicsItem* parent, const QString& serviceId, uint containmentId) diff --git a/containment.h b/containment.h index bdd76445c..b59140d3c 100644 --- a/containment.h +++ b/containment.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -64,6 +65,16 @@ class PLASMA_EXPORT Containment : public Applet Q_OBJECT public: + class StyleOption : public QStyleOptionGraphicsItem + { + public: + explicit StyleOption(); + explicit StyleOption(const StyleOption &other); + explicit StyleOption(const QStyleOptionGraphicsItem &other); + + int desktop; + }; + typedef QList List; typedef QHash Dict; diff --git a/view.cpp b/view.cpp index 4f23f3080..3b2ec8e20 100644 --- a/view.cpp +++ b/view.cpp @@ -18,6 +18,9 @@ */ #include "view.h" + +#include + #include "corona.h" #include "containment.h" @@ -31,7 +34,7 @@ class View::Private public: Private() : drawWallpaper(true), - screen(-1), + desktop(-1), containment(0) { } @@ -41,7 +44,7 @@ public: } bool drawWallpaper; - int screen; + int desktop; Plasma::Containment *containment; }; @@ -58,6 +61,7 @@ View::View(Containment *containment, QWidget *parent) : QGraphicsView(parent), d(new Private) { + Q_ASSERT(containment); initGraphicsView(); setScene(containment->scene()); setContainment(containment); @@ -91,15 +95,37 @@ void View::setScreen(int screen) } setContainment(corona->containmentForScreen(screen)); - } else { - // reseting the screen who knows what. - d->screen = screen; + if (d->desktop < -1) { + // we want to set it to "all desktops" if we get ownership of + // a screen but don't have a desktop set + d->desktop = -1; + } } } int View::screen() const { - return d->screen; + return d->containment->screen(); +} + +void View::setDesktop(int desktop) +{ + // -1 == All desktops + if (desktop < -1 || desktop > KWindowSystem::numberOfDesktops() - 1) { + desktop = -1; + } + + d->desktop = desktop; +} + +int View::desktop() const +{ + return d->desktop; +} + +int View::effectiveDesktop() const +{ + return d->desktop > -1 ? d->desktop : KWindowSystem::currentDesktop(); } void View::setContainment(Containment *containment) @@ -113,7 +139,6 @@ void View::setContainment(Containment *containment) } d->containment = containment; - d->screen = containment->screen(); updateSceneRect(); connect(containment, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect())); } diff --git a/view.h b/view.h index f29374a4b..c65a573f7 100644 --- a/view.h +++ b/view.h @@ -68,6 +68,27 @@ public: */ int screen() const; + /** + * Sets which virtual desktop this view is asociated with, if any. + * + * @arg desktop a valid desktop number, -1 for all desktops, less than -1 for none + */ + void setDesktop(int desktop); + + /** + * The virtual desktop this view is associated with + * + * @return the desktop number, -1 for all desktops and less than -1 for none + */ + int desktop() const; + + /** + * The virtual desktop this view is actually being viewed on + * + * @return the desktop number (always valid, never < 0) + */ + int effectiveDesktop() const; + /** * Sets the containment for this view, which will also cause the view * to track the geometry of the containment.