From 59590a5993181221baf9bbda4819bbd1039e047a Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Thu, 13 May 2010 04:06:27 +0000 Subject: [PATCH] react to activity removal svn path=/trunk/KDE/kdebase/workspace/; revision=1126057 --- client.cpp | 9 +++++---- workspace.cpp | 13 +++++++++++++ workspace.h | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/client.cpp b/client.cpp index 1a2b0cec0e..87f70d4580 100644 --- a/client.cpp +++ b/client.cpp @@ -1495,14 +1495,15 @@ void Client::setOnActivity( const QString &activity, bool enable ) { if( activityList.contains(activity) == enable ) //nothing to do return; - KActivityConsumer c; - QStringList allActivities = c.availableActivities(); - if( !allActivities.contains(activity) ) //bogus ID - return; //check whether we should set it to all activities QStringList newActivitiesList = activityList; + QStringList allActivities = KActivityConsumer().availableActivities(); if (enable) + { + if( !allActivities.contains(activity) ) //bogus ID + return; newActivitiesList.append(activity); + } else newActivitiesList.removeOne(activity); if( newActivitiesList.size() == allActivities.size() || newActivitiesList.isEmpty() ) diff --git a/workspace.cpp b/workspace.cpp index d0d83d955a..ba60c327a6 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -243,6 +243,7 @@ Workspace::Workspace( bool restore ) connect( Kephal::Screens::self(), SIGNAL( screenMoved(Kephal::Screen*, QPoint, QPoint) ), SLOT( desktopResized() )); connect( &activityController_, SIGNAL( currentActivityChanged(QString) ), SLOT( updateCurrentActivity(QString) )); + connect( &activityController_, SIGNAL( activityRemoved(QString) ), SLOT( activityRemoved(QString) )); } void Workspace::init() @@ -1647,6 +1648,18 @@ void Workspace::updateCurrentActivity(const QString &new_activity) } +/** + * updates clients when an activity is destroyed. + * this ensures that a client does not get 'lost' if the only activity it's on is removed. + */ +void Workspace::activityRemoved(const QString &activity) + { + foreach (Client *client, stacking_order) + { + client->setOnActivity(activity, false); + } + } + /** * Called only from D-Bus */ diff --git a/workspace.h b/workspace.h index fb408492b2..0a44d6e11a 100644 --- a/workspace.h +++ b/workspace.h @@ -756,7 +756,8 @@ class Workspace : public QObject, public KDecorationDefines void resetCursorPosTime(); void delayedCheckUnredirect(); - void updateCurrentActivity(const QString &activity); + void updateCurrentActivity(const QString &new_activity); + void activityRemoved(const QString &activity); protected: bool keyPressMouseEmulation( XKeyEvent& ev );