remove perVirtualdesktop views

remove any desktop reference from setScreen and containmentForScreen
along with lastScreen and lastDesktop
This commit is contained in:
Marco Martin 2013-02-18 18:05:45 +01:00
parent 0e8115b697
commit bb005f1cc5
8 changed files with 24 additions and 51 deletions

View File

@ -217,9 +217,7 @@ void Containment::restore(KConfigGroup &group)
setLocation((Plasma::Location)group.readEntry("location", (int)d->location));
setFormFactor((Plasma::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
//kDebug() << "setScreen from restore";
d->lastScreen = group.readEntry("lastScreen", d->lastScreen);
d->lastDesktop = group.readEntry("lastDesktop", d->lastDesktop);
d->setScreen(group.readEntry("screen", d->screen), group.readEntry("desktop", d->desktop), false);
d->setScreen(group.readEntry("screen", d->screen));
d->activityId = group.readEntry("activityId", QString());
flushPendingConstraintsEvents();
@ -305,9 +303,6 @@ void Containment::save(KConfigGroup &g) const
}
group.writeEntry("screen", d->screen);
group.writeEntry("lastScreen", d->lastScreen);
group.writeEntry("desktop", d->desktop);
group.writeEntry("lastDesktop", d->lastDesktop);
group.writeEntry("formfactor", (int)d->formFactor);
group.writeEntry("location", (int)d->location);
group.writeEntry("activityId", d->activityId);
@ -496,9 +491,9 @@ QList<Applet *> Containment::applets() const
return d->applets;
}
void Containment::setScreen(int newScreen, int newDesktop)
void Containment::setScreen(int newScreen)
{
d->setScreen(newScreen, newDesktop);
d->setScreen(newScreen);
}
int Containment::screen() const

View File

@ -219,7 +219,7 @@ class PLASMA_EXPORT Containment : public Applet
* 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, int desktop = -1);
void setScreen(int screen);
/**
* @return the screen number this containment is serving as the desktop for

View File

@ -215,7 +215,7 @@ QList<Plasma::Containment *> Corona::importLayout(const KConfigGroup &conf)
return d->importLayout(conf, true);
}
Containment *Corona::containmentForScreen(int screen, int desktop) const
Containment *Corona::containmentForScreen(int screen) const
{
foreach (Containment *containment, d->containments) {
if (containment->screen() == screen &&
@ -228,17 +228,16 @@ Containment *Corona::containmentForScreen(int screen, int desktop) const
return 0;
}
Containment *Corona::containmentForScreen(int screen, int desktop,
Containment *Corona::containmentForScreen(int screen,
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
{
Containment *containment = containmentForScreen(screen, desktop);
Containment *containment = containmentForScreen(screen);
if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
// screen requests are allowed to bypass immutability
if (screen >= 0 && screen < numScreens() &&
desktop >= -1 && desktop < KWindowSystem::numberOfDesktops()) {
if (screen >= 0 && screen < numScreens()) {
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0);
if (containment) {
containment->setScreen(screen, desktop);
containment->setScreen(screen);
}
}
}

View File

@ -113,7 +113,7 @@ public:
* @param desktop the virtual desktop) to locate; if < 0 then it will
* simply return the first Containment associated with screen
*/
Containment *containmentForScreen(int screen, int desktop = -1) const;
Containment *containmentForScreen(int screen) const;
/**
* Returns the Containment for a given physical screen and desktop, creating one
@ -127,7 +127,7 @@ public:
* @param defaultArgs optional arguments to pass in when creating a Containment if needed
* @since 4.6
*/
Containment *containmentForScreen(int screen, int desktop,
Containment *containmentForScreen(int screen,
const QString &defaultPluginIfNonExistent,
const QVariantList &defaultArgs = QVariantList());

View File

@ -185,7 +185,7 @@ void ContainmentPrivate::addAppletActions(KMenu &desktopMenu, Applet *applet, QE
}
}
void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventInvalidDesktops)
void ContainmentPrivate::setScreen(int newScreen)
{
// What we want to do in here is:
// * claim the screen as our own
@ -211,12 +211,7 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
newScreen = -1;
}
// -1 == All desktops
if (newDesktop < -1 || (preventInvalidDesktops && newDesktop > KWindowSystem::numberOfDesktops() - 1)) {
newDesktop = -1;
}
//kDebug() << activity() << "setting screen to " << newScreen << newDesktop << "and type is" << type;
//kDebug() << activity() << "setting screen to " << newScreen << "and type is" << type;
Containment *swapScreensWith(0);
const bool isDesktopContainment = type == Containment::DesktopContainment ||
@ -224,7 +219,7 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
if (isDesktopContainment) {
if (newScreen > -1) {
// sanity check to make sure someone else doesn't have this screen already!
Containment *currently = corona->containmentForScreen(newScreen, newDesktop);
Containment *currently = corona->containmentForScreen(newScreen);
if (currently && currently != q) {
#ifndef NDEBUG
kDebug() << "currently is on screen" << currently->screen()
@ -232,44 +227,34 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
<< "and is" << currently->activity()
<< (QObject*)currently << "i'm" << (QObject*)q;
#endif
currently->setScreen(-1, -1);
currently->setScreen(-1);
swapScreensWith = currently;
}
}
}
int oldDesktop = desktop;
desktop = newDesktop;
int oldScreen = screen;
screen = newScreen;
q->updateConstraints(Plasma::ScreenConstraint);
if (oldScreen != newScreen || oldDesktop != newDesktop) {
if (oldScreen != newScreen) {
/*
#ifndef NDEBUG
kDebug() << "going to signal change for" << q
#endif
<< ", old screen & desktop:" << oldScreen << oldDesktop
<< ", old screen & desktop:" << oldScreen
<< ", new:" << screen << desktop;
*/
KConfigGroup c = q->config();
c.writeEntry("screen", screen);
c.writeEntry("desktop", desktop);
if (newScreen != -1) {
lastScreen = newScreen;
lastDesktop = newDesktop;
c.writeEntry("lastScreen", lastScreen);
c.writeEntry("lastDesktop", lastDesktop);
}
emit q->configNeedsSaving();
emit q->screenChanged(oldScreen, newScreen, q);
}
if (swapScreensWith) {
//kDebug() << "setScreen due to swap, part 2";
swapScreensWith->setScreen(oldScreen, oldDesktop);
swapScreensWith->setScreen(oldScreen);
}
checkRemoveAction();

View File

@ -53,9 +53,6 @@ public:
formFactor(Planar),
location(Floating),
screen(-1), // no screen
lastScreen(-1),
desktop(-1), // all desktops
lastDesktop(-1),
type(Containment::NoContainmentType),
drawWallpaper(false),
containmentActionsSource(Global)
@ -74,7 +71,7 @@ public:
void triggerShowAddWidgets();
void requestConfiguration();
void checkStatus(Plasma::ItemStatus status);
void setScreen(int newScreen, int newDesktop, bool preventInvalidDesktops = true);
void setScreen(int newScreen);
/**
* Called when constraints have been updated on this containment to provide
@ -126,9 +123,6 @@ public:
QString wallpaper;
QHash<QString, ContainmentActions*> localActionPlugins;
int screen;
int lastScreen;
int desktop;
int lastDesktop;
QList<QAction *> toolBoxActions;
QString activityId;
Containment::Type type;

View File

@ -93,7 +93,7 @@ void DesktopCorona::checkScreen(int screen, bool signalWhenExists)
//TODO: restore activities
//Activity *currentActivity = activity(m_activityController->currentActivity());
//ensure the desktop(s) have a containment and view
checkDesktop(/*currentActivity,*/ signalWhenExists, screen, -1);
checkDesktop(/*currentActivity,*/ signalWhenExists, screen);
//ensure the panels get views too
@ -112,9 +112,9 @@ void DesktopCorona::checkScreen(int screen, bool signalWhenExists)
}
}
void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists, int screen, int desktop)
void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists, int screen)
{
Plasma::Containment *c = /*activity->*/containmentForScreen(screen, desktop);
Plasma::Containment *c = /*activity->*/containmentForScreen(screen);
//TODO: remove following when activities are restored
if (!c) {
@ -125,7 +125,7 @@ void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists,
return;
}
c->setScreen(screen, desktop);
c->setScreen(screen);
if (screen >= 0 || m_views.count() >= screen + 1) {
m_views[screen]->setContainment(c);
} else {

View File

@ -56,7 +56,7 @@ public:
*/
void checkScreen(int screen, bool signalWhenExists = false);
void checkDesktop(/*Activity *activity,*/ bool signalWhenExists, int screen, int desktop);
void checkDesktop(/*Activity *activity,*/ bool signalWhenExists, int screen);
int numScreens() const;
QRect screenGeometry(int id) const;