From f4de9618f87d0463859bfb809fd565c24327431d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 27 Apr 2017 11:40:35 +0200 Subject: [PATCH] revert the hackish overriding of Client::desktop() for session saving The member variable is not what determines which desktop a window is on, it's more like caching the state. Therefore trying to fake a new value eventually leads to inconsistencies, e.g. having KWrite open with unsaved changes on inactive desktop results in the window ending up on all desktops after session save (both successful and cancelled). This pretty much reverts the whole 7ce380497f that introduced this and also a0a976885c2 that tried to fix some of the problems resulting from it. The original problem of session saving of windows of inactive activities still remains, to be fixed by another commit. Differential Revision: https://phabricator.kde.org/D5613 --- client.cpp | 14 -------------- client.h | 2 -- manage.cpp | 33 ++++----------------------------- toplevel.h | 6 ++++++ 4 files changed, 10 insertions(+), 45 deletions(-) diff --git a/client.cpp b/client.cpp index 4697348db5..0a71adca37 100644 --- a/client.cpp +++ b/client.cpp @@ -1319,20 +1319,6 @@ void Client::updateActivities(bool includeTransients) tabGroup()->updateStates(this, TabGroup::Activity); } -/** - * Returns the virtual desktop within the workspace() the client window - * is located in, 0 if it isn't located on any special desktop (not mapped yet), - * or NET::OnAllDesktops. Do not use desktop() directly, use - * isOnDesktop() instead. - */ -int Client::desktop() const -{ - if (needsSessionInteract) { - return NET::OnAllDesktops; - } - return AbstractClient::desktop(); -} - /** * Returns the list of activities the client window is on. * if it's on all activities, the list will be empty. diff --git a/client.h b/client.h index 76dba91500..4f660ff6e3 100644 --- a/client.h +++ b/client.h @@ -132,8 +132,6 @@ public: void releaseWindow(bool on_shutdown = false); void destroyClient(); - virtual int desktop() const; - virtual QStringList activities() const; void setOnActivity(const QString &activity, bool enable); void setOnAllActivities(bool set) override; diff --git a/manage.cpp b/manage.cpp index a1f927b928..b89348851d 100644 --- a/manage.cpp +++ b/manage.cpp @@ -596,35 +596,10 @@ bool Client::manage(xcb_window_t w, bool isMapped) else allow = workspace()->allowClientActivation(this, userTime(), false); - if (!(isMapped || session)) { - if (workspace()->sessionSaving()) { - /* - * If we get a new window during session saving, we assume it's some 'save file?' dialog - * which the user really needs to see (to know why logout's stalled). - * - * Given the current session management protocol, I can't see a nicer way of doing this. - * Someday I'd like to see a protocol that tells the windowmanager who's doing SessionInteract. - */ - needsSessionInteract = true; - //show the parent too - auto mainclients = mainClients(); - for (auto it = mainclients.constBegin(); - it != mainclients.constEnd(); ++it) { - if (Client *mc = dynamic_cast((*it))) { - mc->setSessionInteract(true); - } - (*it)->unminimize(); - } - } else if (allow) { - // also force if activation is allowed - if (!isOnCurrentDesktop() && options->focusPolicyIsReasonable()) { - VirtualDesktopManager::self()->setCurrent(desktop()); - } - /*if (!isOnCurrentActivity()) { - workspace()->setCurrentActivity( activities().first() ); - } FIXME no such method*/ - } - } + // If session saving, force showing new windows (i.e. "save file?" dialogs etc.) + // also force if activation is allowed + if( !isOnCurrentDesktop() && !isMapped && !session && ( allow || workspace()->sessionSaving() )) + VirtualDesktopManager::self()->setCurrent( desktop()); if (isOnCurrentDesktop() && !isMapped && !allow && (!session || session->stackingOrder < 0)) workspace()->restackClientUnderActive(this); diff --git a/toplevel.h b/toplevel.h index 3737c12731..cb604ea1e3 100644 --- a/toplevel.h +++ b/toplevel.h @@ -272,6 +272,12 @@ public: virtual bool isLockScreen() const; virtual bool isInputMethod() const; + /** + * Returns the virtual desktop within the workspace() the client window + * is located in, 0 if it isn't located on any special desktop (not mapped yet), + * or NET::OnAllDesktops. Do not use desktop() directly, use + * isOnDesktop() instead. + */ virtual int desktop() const = 0; virtual QStringList activities() const = 0; bool isOnDesktop(int d) const;