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)); setLocation((Plasma::Location)group.readEntry("location", (int)d->location));
setFormFactor((Plasma::FormFactor)group.readEntry("formfactor", (int)d->formFactor)); setFormFactor((Plasma::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
//kDebug() << "setScreen from restore"; //kDebug() << "setScreen from restore";
d->lastScreen = group.readEntry("lastScreen", d->lastScreen); d->setScreen(group.readEntry("screen", d->screen));
d->lastDesktop = group.readEntry("lastDesktop", d->lastDesktop);
d->setScreen(group.readEntry("screen", d->screen), group.readEntry("desktop", d->desktop), false);
d->activityId = group.readEntry("activityId", QString()); d->activityId = group.readEntry("activityId", QString());
flushPendingConstraintsEvents(); flushPendingConstraintsEvents();
@ -305,9 +303,6 @@ void Containment::save(KConfigGroup &g) const
} }
group.writeEntry("screen", d->screen); 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("formfactor", (int)d->formFactor);
group.writeEntry("location", (int)d->location); group.writeEntry("location", (int)d->location);
group.writeEntry("activityId", d->activityId); group.writeEntry("activityId", d->activityId);
@ -496,9 +491,9 @@ QList<Applet *> Containment::applets() const
return d->applets; 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 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 * if it is not serving as the desktop for any screen
* @param desktop the virtual desktop to also associate this this screen with * @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 * @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); return d->importLayout(conf, true);
} }
Containment *Corona::containmentForScreen(int screen, int desktop) const Containment *Corona::containmentForScreen(int screen) const
{ {
foreach (Containment *containment, d->containments) { foreach (Containment *containment, d->containments) {
if (containment->screen() == screen && if (containment->screen() == screen &&
@ -228,17 +228,16 @@ Containment *Corona::containmentForScreen(int screen, int desktop) const
return 0; return 0;
} }
Containment *Corona::containmentForScreen(int screen, int desktop, Containment *Corona::containmentForScreen(int screen,
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
{ {
Containment *containment = containmentForScreen(screen, desktop); Containment *containment = containmentForScreen(screen);
if (!containment && !defaultPluginIfNonExistent.isEmpty()) { if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
// screen requests are allowed to bypass immutability // screen requests are allowed to bypass immutability
if (screen >= 0 && screen < numScreens() && if (screen >= 0 && screen < numScreens()) {
desktop >= -1 && desktop < KWindowSystem::numberOfDesktops()) {
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0); containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0);
if (containment) { 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 * @param desktop the virtual desktop) to locate; if < 0 then it will
* simply return the first Containment associated with screen * 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 * 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 * @param defaultArgs optional arguments to pass in when creating a Containment if needed
* @since 4.6 * @since 4.6
*/ */
Containment *containmentForScreen(int screen, int desktop, Containment *containmentForScreen(int screen,
const QString &defaultPluginIfNonExistent, const QString &defaultPluginIfNonExistent,
const QVariantList &defaultArgs = QVariantList()); 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: // What we want to do in here is:
// * claim the screen as our own // * claim the screen as our own
@ -211,12 +211,7 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
newScreen = -1; newScreen = -1;
} }
// -1 == All desktops //kDebug() << activity() << "setting screen to " << newScreen << "and type is" << type;
if (newDesktop < -1 || (preventInvalidDesktops && newDesktop > KWindowSystem::numberOfDesktops() - 1)) {
newDesktop = -1;
}
//kDebug() << activity() << "setting screen to " << newScreen << newDesktop << "and type is" << type;
Containment *swapScreensWith(0); Containment *swapScreensWith(0);
const bool isDesktopContainment = type == Containment::DesktopContainment || const bool isDesktopContainment = type == Containment::DesktopContainment ||
@ -224,7 +219,7 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
if (isDesktopContainment) { if (isDesktopContainment) {
if (newScreen > -1) { if (newScreen > -1) {
// 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!
Containment *currently = corona->containmentForScreen(newScreen, newDesktop); Containment *currently = corona->containmentForScreen(newScreen);
if (currently && currently != q) { if (currently && currently != q) {
#ifndef NDEBUG #ifndef NDEBUG
kDebug() << "currently is on screen" << currently->screen() kDebug() << "currently is on screen" << currently->screen()
@ -232,44 +227,34 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
<< "and is" << currently->activity() << "and is" << currently->activity()
<< (QObject*)currently << "i'm" << (QObject*)q; << (QObject*)currently << "i'm" << (QObject*)q;
#endif #endif
currently->setScreen(-1, -1); currently->setScreen(-1);
swapScreensWith = currently; swapScreensWith = currently;
} }
} }
} }
int oldDesktop = desktop;
desktop = newDesktop;
int oldScreen = screen; int oldScreen = screen;
screen = newScreen; screen = newScreen;
q->updateConstraints(Plasma::ScreenConstraint); q->updateConstraints(Plasma::ScreenConstraint);
if (oldScreen != newScreen || oldDesktop != newDesktop) { if (oldScreen != newScreen) {
/* /*
#ifndef NDEBUG #ifndef NDEBUG
kDebug() << "going to signal change for" << q kDebug() << "going to signal change for" << q
#endif #endif
<< ", old screen & desktop:" << oldScreen << oldDesktop << ", old screen & desktop:" << oldScreen
<< ", new:" << screen << desktop; << ", new:" << screen << desktop;
*/ */
KConfigGroup c = q->config(); KConfigGroup c = q->config();
c.writeEntry("screen", screen); 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->configNeedsSaving();
emit q->screenChanged(oldScreen, newScreen, q); emit q->screenChanged(oldScreen, newScreen, q);
} }
if (swapScreensWith) { if (swapScreensWith) {
//kDebug() << "setScreen due to swap, part 2"; //kDebug() << "setScreen due to swap, part 2";
swapScreensWith->setScreen(oldScreen, oldDesktop); swapScreensWith->setScreen(oldScreen);
} }
checkRemoveAction(); checkRemoveAction();

View File

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

View File

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

View File

@ -56,7 +56,7 @@ public:
*/ */
void checkScreen(int screen, bool signalWhenExists = false); 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; int numScreens() const;
QRect screenGeometry(int id) const; QRect screenGeometry(int id) const;