desktop/kde-workspace/workspace1.diff

218 lines
9.3 KiB
Diff

commit 3071d561f5708ddc40aad3e9e6ed5218476fe64b
Author: Martin Gräßlin <mgraesslin@kde.org>
Date: Thu Jun 21 20:37:23 2012 +0200
Add activity support to Workspace Script Wrapper and Effects
New properties for the current activity and the available
activities plus related signals in scripts. Signals added to
effects.
BUG: 302060
FIXED-IN: 4.9.0
diff --git a/kwin/effects.cpp b/kwin/effects.cpp
index c56f8d6..3527991 100644
--- a/kwin/effects.cpp
+++ b/kwin/effects.cpp
@@ -115,6 +115,9 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
connect(ws, SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)),
SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)));
connect(ws, SIGNAL(propertyNotify(long)), this, SLOT(slotPropertyNotify(long)));
+ connect(ws, SIGNAL(activityAdded(QString)), SIGNAL(activityAdded(QString)));
+ connect(ws, SIGNAL(activityRemoved(QString)), SIGNAL(activityRemoved(QString)));
+ connect(ws, SIGNAL(currentActivityChanged(QString)), SIGNAL(currentActivityChanged(QString)));
#ifdef KWIN_BUILD_TABBOX
connect(ws->tabBox(), SIGNAL(tabBoxAdded(int)), SIGNAL(tabBoxAdded(int)));
connect(ws->tabBox(), SIGNAL(tabBoxUpdated()), SIGNAL(tabBoxUpdated()));
diff --git a/kwin/libkwineffects/kwineffects.h b/kwin/libkwineffects/kwineffects.h
index bd2b07d..b952999 100644
--- a/kwin/libkwineffects/kwineffects.h
+++ b/kwin/libkwineffects/kwineffects.h
@@ -573,7 +573,7 @@ class KWIN_EXPORT EffectsHandler : public QObject
{
Q_OBJECT
Q_PROPERTY(int currentDesktop READ currentDesktop WRITE setCurrentDesktop NOTIFY desktopChanged)
- Q_PROPERTY(QString currentActivity READ currentActivity)
+ Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY currentActivityChanged)
Q_PROPERTY(KWin::EffectWindow *activeWindow READ activeWindow WRITE activateWindow NOTIFY windowActivated)
Q_PROPERTY(QSize desktopGridSize READ desktopGridSize)
Q_PROPERTY(int desktopGridWidth READ desktopGridWidth)
@@ -1090,6 +1090,27 @@ Q_SIGNALS:
**/
void screenGeometryChanged(const QSize &size);
+ /**
+ * This signal is emitted when the global
+ * activity is changed
+ * @param id id of the new current activity
+ * @since 4.9
+ **/
+ void currentActivityChanged(const QString &id);
+ /**
+ * This signal is emitted when a new activity is added
+ * @param id id of the new activity
+ * @since 4.9
+ */
+ void activityAdded(const QString &id);
+ /**
+ * This signal is emitted when the activity
+ * is removed
+ * @param id id of the removed activity
+ * @since 4.9
+ */
+ void activityRemoved(const QString &id);
+
protected:
QVector< EffectPair > loaded_effects;
QHash< QString, KLibrary* > effect_libraries;
diff --git a/kwin/scripting/workspace_wrapper.cpp b/kwin/scripting/workspace_wrapper.cpp
index 2879cd9..83d2b17 100644
--- a/kwin/scripting/workspace_wrapper.cpp
+++ b/kwin/scripting/workspace_wrapper.cpp
@@ -38,6 +38,11 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent)
connect(ws, SIGNAL(clientActivated(KWin::Client*)), SIGNAL(clientActivated(KWin::Client*)));
connect(ws, SIGNAL(numberDesktopsChanged(int)), SIGNAL(numberDesktopsChanged(int)));
connect(ws, SIGNAL(clientDemandsAttentionChanged(KWin::Client*,bool)), SIGNAL(clientDemandsAttentionChanged(KWin::Client*,bool)));
+ connect(ws, SIGNAL(currentActivityChanged(QString)), SIGNAL(currentActivityChanged(QString)));
+ connect(ws, SIGNAL(activityAdded(QString)), SIGNAL(activitiesChanged()));
+ connect(ws, SIGNAL(activityAdded(QString)), SIGNAL(activityAdded(QString)));
+ connect(ws, SIGNAL(activityRemoved(QString)), SIGNAL(activitiesChanged()));
+ connect(ws, SIGNAL(activityRemoved(QString)), SIGNAL(activityRemoved(QString)));
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SIGNAL(numberScreensChanged(int)));
connect(QApplication::desktop(), SIGNAL(resized(int)), SIGNAL(screenResized(int)));
foreach (KWin::Client *client, ws->clientList()) {
@@ -71,6 +76,8 @@ GETTER(int, desktopGridWidth)
GETTER(int, desktopGridHeight)
GETTER(int, activeScreen)
GETTER(int, numScreens)
+GETTER(QString, currentActivity)
+GETTER(QStringList, activityList)
#undef GETTER
diff --git a/kwin/scripting/workspace_wrapper.h b/kwin/scripting/workspace_wrapper.h
index fecfaca..18fbe58 100644
--- a/kwin/scripting/workspace_wrapper.h
+++ b/kwin/scripting/workspace_wrapper.h
@@ -63,6 +63,8 @@ class WorkspaceWrapper : public QObject
Q_PROPERTY(int displayHeight READ displayHeight)
Q_PROPERTY(int activeScreen READ activeScreen)
Q_PROPERTY(int numScreens READ numScreens NOTIFY numberScreensChanged)
+ Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY currentActivityChanged)
+ Q_PROPERTY(QStringList activities READ activityList NOTIFY activitiesChanged)
private:
Q_DISABLE_COPY(WorkspaceWrapper)
@@ -103,6 +105,26 @@ signals:
* Don't forget to fetch an updated client area.
**/
void screenResized(int screen);
+ /**
+ * Signal emitted whenever the current activity changed.
+ **/
+ void currentActivityChanged();
+ /**
+ * Signal emitted whenever the list of activities changed.
+ * @param id id of the new activity
+ **/
+ void activitiesChanged(const QString &id);
+ /**
+ * This signal is emitted when a new activity is added
+ * @param id id of the new activity
+ */
+ void activityAdded(const QString &id);
+ /**
+ * This signal is emitted when the activity
+ * is removed
+ * @param id id of the removed activity
+ */
+ void activityRemoved(const QString &id);
public:
//------------------------------------------------------------------
@@ -158,6 +180,8 @@ void setter( rettype val );
QSize displaySize() const;
int activeScreen() const;
int numScreens() const;
+ QString currentActivity() const;
+ QStringList activityList() const;
/**
* List of Clients currently managed by KWin.
diff --git a/kwin/workspace.cpp b/kwin/workspace.cpp
index f64dc64..d973a89 100644
--- a/kwin/workspace.cpp
+++ b/kwin/workspace.cpp
@@ -262,8 +262,11 @@ Workspace::Workspace(bool restore)
#ifdef KWIN_BUILD_ACTIVITIES
connect(&activityController_, SIGNAL(currentActivityChanged(QString)), SLOT(updateCurrentActivity(QString)));
- connect(&activityController_, SIGNAL(activityRemoved(QString)), SLOT(activityRemoved(QString)));
- connect(&activityController_, SIGNAL(activityAdded(QString)), SLOT(activityAdded(QString)));
+ connect(&activityController_, SIGNAL(activityRemoved(QString)), SLOT(slotActivityRemoved(QString)));
+ connect(&activityController_, SIGNAL(activityRemoved(QString)), SIGNAL(activityRemoved(QString)));
+ connect(&activityController_, SIGNAL(activityAdded(QString)), SLOT(slotActivityAdded(QString)));
+ connect(&activityController_, SIGNAL(activityAdded(QString)), SIGNAL(activityAdded(QString)));
+ connect(&activityController_, SIGNAL(currentActivityChanged(QString)), SIGNAL(currentActivityChanged(QString)));
#endif
connect(&screenChangedTimer, SIGNAL(timeout()), SLOT(screenChangeTimeout()));
@@ -1650,7 +1653,7 @@ 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)
+void Workspace::slotActivityRemoved(const QString &activity)
{
allActivities_.removeOne(activity);
foreach (Toplevel * toplevel, stacking_order) {
@@ -1663,7 +1666,7 @@ void Workspace::activityRemoved(const QString &activity)
cg.deleteGroup();
}
-void Workspace::activityAdded(const QString &activity)
+void Workspace::slotActivityAdded(const QString &activity)
{
allActivities_ << activity;
}
diff --git a/kwin/workspace.h b/kwin/workspace.h
index ea275d3..2f7fe19 100644
--- a/kwin/workspace.h
+++ b/kwin/workspace.h
@@ -678,8 +678,8 @@ private slots:
void resetCursorPosTime();
void delayedCheckUnredirect();
void updateCurrentActivity(const QString &new_activity);
- void activityRemoved(const QString &activity);
- void activityAdded(const QString &activity);
+ void slotActivityRemoved(const QString &activity);
+ void slotActivityAdded(const QString &activity);
void reallyStopActivity(const QString &id); //dbus deadlocks suck
void handleActivityReply();
void showHideActivityMenu();
@@ -711,6 +711,23 @@ signals:
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
void propertyNotify(long a);
void configChanged();
+ /**
+ * This signal is emitted when the global
+ * activity is changed
+ * @param id id of the new current activity
+ */
+ void currentActivityChanged(const QString &id);
+ /**
+ * This signal is emitted when a new activity is added
+ * @param id id of the new activity
+ */
+ void activityAdded(const QString &id);
+ /**
+ * This signal is emitted when the activity
+ * is removed
+ * @param id id of the removed activity
+ */
+ void activityRemoved(const QString &id);
private:
void init();