This lets the View have a desktop set to it and when drawing a Containment we pass in the effective desktop # being currently painted. The Containment is free to ignore this information, or it can try and cast the passed in options to a Containment::StyleOption to retrieve this information. This should be used for any per-desktop painting that happens (e.g. separate background per desktop) and opens the way to having View-per-Desktop for better composite manager support (think: desktop grid or cube where more than one desktop is simultaneously visible)
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=778239
This commit is contained in:
parent
ee26284ec3
commit
2b68bb49ee
11
applet.cpp
11
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<Plasma::View*>(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;
|
||||
|
@ -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)
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <QtGui/QGraphicsItem>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QStyleOptionGraphicsItem>
|
||||
|
||||
#include <kplugininfo.h>
|
||||
#include <ksharedconfig.h>
|
||||
@ -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<Applet*> List;
|
||||
typedef QHash<QString, Applet*> Dict;
|
||||
|
||||
|
39
view.cpp
39
view.cpp
@ -18,6 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "view.h"
|
||||
|
||||
#include <KWindowSystem>
|
||||
|
||||
#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()));
|
||||
}
|
||||
|
21
view.h
21
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user