~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/taskmanager/taskmanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 
 
3
Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
 
4
Copyright (c) 2001 Richard Moore <rich@kde.org>
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining a copy
 
7
of this software and associated documentation files (the "Software"), to deal
 
8
in the Software without restriction, including without limitation the rights
 
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
10
copies of the Software, and to permit persons to whom the Software is
 
11
furnished to do so, subject to the following conditions:
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
******************************************************************/
 
24
 
 
25
#ifndef TASKMANAGER_H
 
26
#define TASKMANAGER_H
 
27
 
 
28
#include <QHash>
 
29
#include <QSet>
 
30
#include <QVector>
 
31
 
 
32
#include <KSharedPtr>
 
33
#include <KWindowSystem>
 
34
 
 
35
struct QUuid;
 
36
 
 
37
namespace TaskManager
 
38
{
 
39
typedef QSet<WId> WindowList;
 
40
 
 
41
class Task;
 
42
typedef KSharedPtr<Task> TaskPtr;
 
43
typedef QVector<TaskPtr> TaskList;
 
44
typedef QHash<WId, TaskPtr> TaskDict;
 
45
 
 
46
class Startup;
 
47
typedef KSharedPtr<Startup> StartupPtr;
 
48
typedef QVector<StartupPtr> StartupList;
 
49
 
 
50
enum TaskChange { TaskUnchanged = 0,
 
51
                  NameChanged = 1,
 
52
                  StateChanged = 2,
 
53
                  DesktopChanged = 32,
 
54
                  GeometryChanged = 64,
 
55
                  WindowTypeChanged = 128,
 
56
                  ActionsChanged = 256,
 
57
                  TransientsChanged = 512,
 
58
                  IconChanged = 1024,
 
59
                  ColorChanged = 2048,
 
60
                  ActivitiesChanged = 4096,
 
61
                  AttentionChanged = 8192,
 
62
                  EverythingChanged = 0xffff
 
63
                };
 
64
Q_DECLARE_FLAGS(TaskChanges, TaskChange)
 
65
} // namespace TaskManager
 
66
 
 
67
// Own
 
68
#include <taskmanager/startup.h>
 
69
#include <taskmanager/task.h>
 
70
#include <taskmanager/taskmanager_export.h>
 
71
 
 
72
namespace TaskManager
 
73
{
 
74
 
 
75
/**
 
76
 * A generic API for task managers. This class provides an easy way to
 
77
 * build NET compliant task managers. It provides support for startup
 
78
 * notification, virtual desktops and the full range of WM properties.
 
79
 *
 
80
 * @see Task
 
81
 * @see Startup
 
82
 */
 
83
class TASKMANAGER_EXPORT TaskManager : public QObject
 
84
{
 
85
    Q_OBJECT
 
86
    Q_PROPERTY( int currentDesktop READ currentDesktop )
 
87
    Q_PROPERTY( int numberOfDesktops READ numberOfDesktops )
 
88
    Q_PROPERTY( QString currentActivity READ currentActivity )
 
89
 
 
90
public:
 
91
    static TaskManager* self();
 
92
 
 
93
    TaskManager();
 
94
    ~TaskManager();
 
95
 
 
96
    /**
 
97
     * Returns the task for a given WId, or 0 if there is no such task.
 
98
     */
 
99
    TaskPtr findTask(WId w);
 
100
 
 
101
    /**
 
102
     * Returns the task for a given location, or 0 if there is no such task.
 
103
     */
 
104
    TaskPtr findTask(int desktop, const QPoint& p);
 
105
 
 
106
    /**
 
107
     * Returns a list of all current tasks.
 
108
     */
 
109
    TaskDict tasks() const;
 
110
 
 
111
    /**
 
112
     * Returns a list of all current startups.
 
113
     */
 
114
    StartupList startups() const;
 
115
 
 
116
    /**
 
117
     * Returns the name of the nth desktop.
 
118
     */
 
119
    QString desktopName(int n) const;
 
120
 
 
121
    /**
 
122
     * Returns the number of virtual desktops.
 
123
     */
 
124
    int numberOfDesktops() const;
 
125
 
 
126
    /**
 
127
     * Returns the number of the current desktop.
 
128
     */
 
129
    int currentDesktop() const;
 
130
 
 
131
    /**
 
132
     * Returns the number of the current desktop.
 
133
     */
 
134
    QString currentActivity() const;
 
135
 
 
136
    /**
 
137
     * Returns true if the specified task is on top.
 
138
     */
 
139
    bool isOnTop(const Task*) const;
 
140
 
 
141
    /**
 
142
     * Tells the task manager whether or not we care about geometry
 
143
     * updates. This generates a lot of activity so should only be used
 
144
     * when necessary.
 
145
     */
 
146
    void setTrackGeometry(bool track, const QUuid &token);
 
147
 
 
148
    /**
 
149
     * @return true if geometry tracking is on
 
150
     */
 
151
    bool trackGeometry() const;
 
152
 
 
153
    /**
 
154
    * Returns whether the Window with WId wid is on the screen screen
 
155
    */
 
156
    static bool isOnScreen(int screen, const WId wid);
 
157
 
 
158
Q_SIGNALS:
 
159
    /**
 
160
     * Emitted when a new task has started.
 
161
     */
 
162
    void taskAdded(TaskPtr);
 
163
 
 
164
    /**
 
165
     * Emitted when a task has terminated.
 
166
     */
 
167
    void taskRemoved(TaskPtr);
 
168
 
 
169
    /**
 
170
     * Emitted when a new task is expected.
 
171
     */
 
172
    void startupAdded(StartupPtr);
 
173
 
 
174
    /**
 
175
     * Emitted when a startup item should be removed. This could be because
 
176
     * the task has started, because it is known to have died, or simply
 
177
     * as a result of a timeout.
 
178
     */
 
179
    void startupRemoved(StartupPtr);
 
180
 
 
181
    /**
 
182
     * Emitted when the current desktop changes.
 
183
     */
 
184
    void desktopChanged(int desktop);
 
185
 
 
186
    /**
 
187
     * Emitted when the current activity changes.
 
188
     */
 
189
    void activityChanged(const QString &activity);
 
190
 
 
191
    /**
 
192
     * Emitted when a window changes desktop.
 
193
     */
 
194
    void windowChanged(TaskPtr task, ::TaskManager::TaskChanges change);
 
195
 
 
196
protected Q_SLOTS:
 
197
    //* @internal
 
198
    void windowAdded(WId);
 
199
    //* @internal
 
200
    void windowRemoved(WId);
 
201
    //* @internal
 
202
    void windowChanged(WId, const unsigned long*);
 
203
 
 
204
    //* @internal
 
205
    void activeWindowChanged(WId);
 
206
    //* @internal
 
207
    void currentDesktopChanged(int);
 
208
    //* @internal
 
209
    void currentActivityChanged(const QString&);
 
210
    //* @internal
 
211
    void killStartup( const KStartupInfoId& );
 
212
    //* @internal
 
213
    void killStartup(StartupPtr);
 
214
 
 
215
    //* @internal
 
216
    void gotNewStartup( const KStartupInfoId&, const KStartupInfoData& );
 
217
    //* @internal
 
218
    void gotStartupChange( const KStartupInfoId&, const KStartupInfoData& );
 
219
 
 
220
    //* @internal
 
221
    void taskChanged(::TaskManager::TaskChanges changes);
 
222
 
 
223
protected Q_SLOTS:
 
224
    void configureStartup();
 
225
 
 
226
private:
 
227
    class Private;
 
228
    Private * const d;
 
229
 
 
230
    Q_PRIVATE_SLOT(d, void onAppExitCleanup())
 
231
};
 
232
 
 
233
} // TaskManager namespace
 
234
 
 
235
Q_DECLARE_OPERATORS_FOR_FLAGS(TaskManager::TaskChanges)
 
236
 
 
237
#endif