add proper support for virtual desktops, which really requires more than just the View being aware of it; given the default parameters, it's a detail most plasma based apps can ignore (just like screens in general, actually =)

svn path=/trunk/KDE/kdelibs/; revision=885330
This commit is contained in:
Aaron J. Seigo 2008-11-17 04:34:55 +00:00
parent ac6a69d29a
commit 160e70ccd0
7 changed files with 42 additions and 27 deletions

View File

@ -446,6 +446,7 @@ void Containment::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void Containment::showDropZone(const QPoint pos)
{
Q_UNUSED(pos)
//Base implementation does nothing, don't put code here
}
@ -744,7 +745,7 @@ Applet::List Containment::applets() const
return d->applets;
}
void Containment::setScreen(int screen)
void Containment::setScreen(int screen, int desktop)
{
// What we want to do in here is:
// * claim the screen as our own
@ -758,7 +759,6 @@ void Containment::setScreen(int screen)
// a screen of -1 means no associated screen.
Containment *swapScreensWith(0);
if (d->type == DesktopContainment || d->type == CustomContainment) {
// we want to listen to changes in work area if our screen changes
if (d->screen < 0 && screen > -1) {
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()),
@ -770,7 +770,7 @@ void Containment::setScreen(int screen)
if (screen > -1 && corona()) {
// sanity check to make sure someone else doesn't have this screen already!
Containment *currently = corona()->containmentForScreen(screen);
Containment *currently = corona()->containmentForScreen(screen, desktop);
if (currently && currently != this) {
//kDebug() << "currently is on screen" << currently->screen()
// << "and is" << currently->name()
@ -788,6 +788,7 @@ void Containment::setScreen(int screen)
screen = -1;
}
//kDebug() << "setting screen to " << screen << "and type is" << containmentType();
if (screen < numScreens && screen > -1) {
if (containmentType() == DesktopContainment ||
@ -796,6 +797,13 @@ void Containment::setScreen(int screen)
}
}
// -1 == All desktops
if (desktop < -1 || desktop > KWindowSystem::numberOfDesktops() - 1) {
desktop = -1;
}
d->desktop = desktop;
int oldScreen = d->screen;
d->screen = screen;
updateConstraints(Plasma::ScreenConstraint);
@ -817,6 +825,11 @@ int Containment::screen() const
return d->screen;
}
int Containment::desktop() const
{
return d->desktop;
}
KPluginInfo::List Containment::listContainments(const QString &category,
const QString &parentApp)
{

View File

@ -208,8 +208,9 @@ class PLASMA_EXPORT Containment : public Applet
*
* @param screen the screen number this containment is the desktop for, or -1
* if it is not serving as the desktop for any screen
* @param desktop the virtual desktop to also associate this this screen with
*/
void setScreen(int screen);
void setScreen(int screen, int desktop = -1);
/**
* @return the screen number this containment is serving as the desktop for
@ -217,6 +218,11 @@ class PLASMA_EXPORT Containment : public Applet
*/
int screen() const;
/**
* @return the viewport (e.g. virtual desktop) this Containment is associated with.
*/
int desktop() const;
/**
* @reimplemented from Applet
*/

View File

@ -320,10 +320,11 @@ void Corona::loadLayout(const QString &configName)
}
}
Containment *Corona::containmentForScreen(int screen) const
Containment *Corona::containmentForScreen(int screen, int desktop) const
{
foreach (Containment *containment, d->containments) {
if (containment->screen() == screen &&
(desktop < 0 || containment->desktop() == desktop) &&
(containment->containmentType() == Containment::DesktopContainment ||
containment->containmentType() >= Containment::CustomContainment)) {
return containment;

View File

@ -94,8 +94,10 @@ public:
* Returns the Containment, if any, for a given physical screen
*
* @param screen number of the physical screen to locate
* @param desktop the virtual dekstop) to locate; if < 0 then it will
* simply return the first Containment associated with screen
*/
Containment *containmentForScreen(int screen) const;
Containment *containmentForScreen(int screen, int desktop = -1) const;
/**
* Adds a widget in the topleft quadrant in the scene. Widgets in the topleft quadrant are

View File

@ -43,6 +43,7 @@ public:
focusedApplet(0),
wallpaper(0),
screen(-1), // no screen
desktop(-1), // all desktops
toolBox(0),
con(0),
type(Containment::NoContainmentType),
@ -112,6 +113,7 @@ public:
Plasma::Wallpaper *wallpaper;
QMap<Applet*, AppletHandle*> handles;
int screen;
int desktop;
ToolBox *toolBox;
Context *con;
Containment::Type type;

View File

@ -141,7 +141,7 @@ View::~View()
clearFocus();
}
void View::setScreen(int screen)
void View::setScreen(int screen, int desktop)
{
if (screen > -1) {
Corona *corona = qobject_cast<Corona*>(scene());
@ -150,7 +150,14 @@ void View::setScreen(int screen)
return;
}
Containment *containment = corona->containmentForScreen(screen);
// -1 == All desktops
if (desktop < -1 || desktop > KWindowSystem::numberOfDesktops() - 1) {
desktop = -1;
}
d->desktop = desktop;
Containment *containment = corona->containmentForScreen(screen, desktop);
if (containment) {
d->containment = 0; //so that we don't end up on the old containment's screen
setContainment(containment);
@ -167,16 +174,6 @@ int View::screen() const
return -1;
}
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;

12
view.h
View File

@ -84,9 +84,10 @@ public:
* Sets which screen this view is associated with, if any.
* This will also set the containment if a valid screen is specified
*
* @arg screen the xinerama screen number; -1 for no screen
* @arg screen the physical screen number; -1 for no screen
* @arg desktop the virtual desktop number, or -1 for all virtual desktops
*/
void setScreen(int screen);
void setScreen(int screen, int desktop = -1);
/**
* Returns the screen this view is associated with
@ -95,13 +96,6 @@ 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
*