1
/*****************************************************************
3
Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
4
Copyright (c) 2001 Richard Moore <rich@kde.org>
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:
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
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.
23
******************************************************************/
33
#include <KWindowSystem>
39
typedef QSet<WId> WindowList;
42
typedef KSharedPtr<Task> TaskPtr;
43
typedef QVector<TaskPtr> TaskList;
44
typedef QHash<WId, TaskPtr> TaskDict;
47
typedef KSharedPtr<Startup> StartupPtr;
48
typedef QVector<StartupPtr> StartupList;
50
enum TaskChange { TaskUnchanged = 0,
55
WindowTypeChanged = 128,
57
TransientsChanged = 512,
60
ActivitiesChanged = 4096,
61
AttentionChanged = 8192,
62
EverythingChanged = 0xffff
64
Q_DECLARE_FLAGS(TaskChanges, TaskChange)
65
} // namespace TaskManager
68
#include <taskmanager/startup.h>
69
#include <taskmanager/task.h>
70
#include <taskmanager/taskmanager_export.h>
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.
83
class TASKMANAGER_EXPORT TaskManager : public QObject
86
Q_PROPERTY( int currentDesktop READ currentDesktop )
87
Q_PROPERTY( int numberOfDesktops READ numberOfDesktops )
88
Q_PROPERTY( QString currentActivity READ currentActivity )
91
static TaskManager* self();
97
* Returns the task for a given WId, or 0 if there is no such task.
99
TaskPtr findTask(WId w);
102
* Returns the task for a given location, or 0 if there is no such task.
104
TaskPtr findTask(int desktop, const QPoint& p);
107
* Returns a list of all current tasks.
109
TaskDict tasks() const;
112
* Returns a list of all current startups.
114
StartupList startups() const;
117
* Returns the name of the nth desktop.
119
QString desktopName(int n) const;
122
* Returns the number of virtual desktops.
124
int numberOfDesktops() const;
127
* Returns the number of the current desktop.
129
int currentDesktop() const;
132
* Returns the number of the current desktop.
134
QString currentActivity() const;
137
* Returns true if the specified task is on top.
139
bool isOnTop(const Task*) const;
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
146
void setTrackGeometry(bool track, const QUuid &token);
149
* @return true if geometry tracking is on
151
bool trackGeometry() const;
154
* Returns whether the Window with WId wid is on the screen screen
156
static bool isOnScreen(int screen, const WId wid);
160
* Emitted when a new task has started.
162
void taskAdded(TaskPtr);
165
* Emitted when a task has terminated.
167
void taskRemoved(TaskPtr);
170
* Emitted when a new task is expected.
172
void startupAdded(StartupPtr);
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.
179
void startupRemoved(StartupPtr);
182
* Emitted when the current desktop changes.
184
void desktopChanged(int desktop);
187
* Emitted when the current activity changes.
189
void activityChanged(const QString &activity);
192
* Emitted when a window changes desktop.
194
void windowChanged(TaskPtr task, ::TaskManager::TaskChanges change);
198
void windowAdded(WId);
200
void windowRemoved(WId);
202
void windowChanged(WId, const unsigned long*);
205
void activeWindowChanged(WId);
207
void currentDesktopChanged(int);
209
void currentActivityChanged(const QString&);
211
void killStartup( const KStartupInfoId& );
213
void killStartup(StartupPtr);
216
void gotNewStartup( const KStartupInfoId&, const KStartupInfoData& );
218
void gotStartupChange( const KStartupInfoId&, const KStartupInfoData& );
221
void taskChanged(::TaskManager::TaskChanges changes);
224
void configureStartup();
230
Q_PRIVATE_SLOT(d, void onAppExitCleanup())
233
} // TaskManager namespace
235
Q_DECLARE_OPERATORS_FOR_FLAGS(TaskManager::TaskChanges)