1 | /******************************************************************** |
2 | KWin - the KDE window manager |
3 | This file is part of the KDE project. |
4 | |
5 | Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> |
6 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | *********************************************************************/ |
20 | #ifndef KWIN_ACTIVITIES_H |
21 | #define KWIN_ACTIVITIES_H |
22 | |
23 | #include <kwinglobals.h> |
24 | |
25 | #include <QObject> |
26 | #include <QStringList> |
27 | |
28 | namespace KActivities { |
29 | class Controller; |
30 | } |
31 | |
32 | namespace KWin |
33 | { |
34 | class Client; |
35 | |
36 | class Activities : public QObject |
37 | { |
38 | Q_OBJECT |
39 | |
40 | public: |
41 | ~Activities(); |
42 | |
43 | bool stop(const QString &id); |
44 | bool start(const QString &id); |
45 | void update(bool running, bool updateCurrent, QObject *target = NULL, QString slot = QString()); |
46 | void setCurrent(const QString &activity); |
47 | /** |
48 | * Adds/removes client \a c to/from \a activity. |
49 | * |
50 | * Takes care of transients as well. |
51 | */ |
52 | void toggleClientOnActivity(Client* c, const QString &activity, bool dont_activate); |
53 | |
54 | const QStringList &running() const; |
55 | const QStringList &all() const; |
56 | const QString ¤t() const; |
57 | const QString &previous() const; |
58 | |
59 | static QString nullUuid(); |
60 | |
61 | Q_SIGNALS: |
62 | /** |
63 | * This signal is emitted when the global |
64 | * activity is changed |
65 | * @param id id of the new current activity |
66 | */ |
67 | void currentChanged(const QString &id); |
68 | /** |
69 | * This signal is emitted when a new activity is added |
70 | * @param id id of the new activity |
71 | */ |
72 | void added(const QString &id); |
73 | /** |
74 | * This signal is emitted when the activity |
75 | * is removed |
76 | * @param id id of the removed activity |
77 | */ |
78 | void removed(const QString &id); |
79 | |
80 | private Q_SLOTS: |
81 | void slotRemoved(const QString &activity); |
82 | void slotAdded(const QString &activity); |
83 | void slotCurrentChanged(const QString &newActivity); |
84 | void reallyStop(const QString &id); //dbus deadlocks suck |
85 | void handleReply(); |
86 | |
87 | private: |
88 | QStringList m_running; |
89 | QStringList m_all; |
90 | QString m_current; |
91 | QString m_previous; |
92 | KActivities::Controller *m_controller; |
93 | |
94 | KWIN_SINGLETON(Activities) |
95 | }; |
96 | |
97 | inline |
98 | const QStringList &Activities::all() const |
99 | { |
100 | return m_all; |
101 | } |
102 | |
103 | inline |
104 | const QString &Activities::current() const |
105 | { |
106 | return m_current; |
107 | } |
108 | |
109 | inline |
110 | const QString &Activities::previous() const |
111 | { |
112 | return m_previous; |
113 | } |
114 | |
115 | inline |
116 | const QStringList &Activities::running() const |
117 | { |
118 | return m_running; |
119 | } |
120 | |
121 | inline |
122 | QString Activities::nullUuid() |
123 | { |
124 | // cloned from kactivities/src/lib/core/consumer.cpp |
125 | return QString("00000000-0000-0000-0000-000000000000" ); |
126 | } |
127 | |
128 | } |
129 | |
130 | #endif // KWIN_ACTIVITIES_H |
131 | |