add more spacing
[personal-kdebase.git] / workspace / libs / taskmanager / taskmanager.h
blob42e84c1a80733c300b00ce4a85b3e29d906660d5
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 ******************************************************************/
25 #ifndef TASKMANAGER_H
26 #define TASKMANAGER_H
28 #include <QtCore/QHash>
29 #include <QtCore/QSet>
30 #include <QtCore/QVector>
32 #include <KDE/KSharedPtr>
33 #include <KDE/KWindowSystem>
35 class QUuid;
37 namespace TaskManager
39 typedef QSet<WId> WindowList;
41 class Task;
42 typedef KSharedPtr<Task> TaskPtr;
43 typedef QVector<TaskPtr> TaskList;
44 typedef QHash<WId, TaskPtr> TaskDict;
46 class Startup;
47 typedef KSharedPtr<Startup> StartupPtr;
48 typedef QVector<StartupPtr> StartupList;
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 EverythingChanged = 0xffff
62 Q_DECLARE_FLAGS(TaskChanges, TaskChange)
63 } // namespace TaskManager
65 // Own
66 #include <taskmanager/startup.h>
67 #include <taskmanager/task.h>
68 #include <taskmanager/taskmanager_export.h>
70 namespace TaskManager
73 /**
74 * A generic API for task managers. This class provides an easy way to
75 * build NET compliant task managers. It provides support for startup
76 * notification, virtual desktops and the full range of WM properties.
78 * @see Task
79 * @see Startup
81 class TASKMANAGER_EXPORT TaskManager : public QObject
83 Q_OBJECT
84 Q_PROPERTY( int currentDesktop READ currentDesktop )
85 Q_PROPERTY( int numberOfDesktops READ numberOfDesktops )
87 public:
88 static TaskManager* self();
90 TaskManager();
91 ~TaskManager();
93 /**
94 * Returns the task for a given WId, or 0 if there is no such task.
96 TaskPtr findTask(WId w);
98 /**
99 * Returns the task for a given location, or 0 if there is no such task.
101 TaskPtr findTask(int desktop, const QPoint& p);
104 * Returns a list of all current tasks.
106 TaskDict tasks() const;
109 * Returns a list of all current startups.
111 StartupList startups() const;
114 * Returns the name of the nth desktop.
116 QString desktopName(int n) const;
119 * Returns the number of virtual desktops.
121 int numberOfDesktops() const;
124 * Returns the number of the current desktop.
126 int currentDesktop() const;
129 * Returns true if the specified task is on top.
131 bool isOnTop(const Task*) const;
134 * Tells the task manager whether or not we care about geometry
135 * updates. This generates a lot of activity so should only be used
136 * when necessary.
138 void setTrackGeometry(bool track, const QUuid &token);
141 * @return true if geometry tracking is on
143 bool trackGeometry() const;
146 * Returns whether the Window with WId wid is on the screen screen
148 static bool isOnScreen(int screen, const WId wid);
150 Q_SIGNALS:
152 * Emitted when a new task has started.
154 void taskAdded(TaskPtr);
157 * Emitted when a task has terminated.
159 void taskRemoved(TaskPtr);
162 * Emitted when a new task is expected.
164 void startupAdded(StartupPtr);
167 * Emitted when a startup item should be removed. This could be because
168 * the task has started, because it is known to have died, or simply
169 * as a result of a timeout.
171 void startupRemoved(StartupPtr);
174 * Emitted when the current desktop changes.
176 void desktopChanged(int desktop);
179 * Emitted when a window changes desktop.
181 void windowChanged(TaskPtr task, ::TaskManager::TaskChanges change);
183 protected Q_SLOTS:
184 //* @internal
185 void windowAdded(WId);
186 //* @internal
187 void windowRemoved(WId);
188 //* @internal
189 void windowChanged(WId, unsigned int);
191 //* @internal
192 void activeWindowChanged(WId);
193 //* @internal
194 void currentDesktopChanged(int);
195 //* @internal
196 void killStartup( const KStartupInfoId& );
197 //* @internal
198 void killStartup(StartupPtr);
200 //* @internal
201 void gotNewStartup( const KStartupInfoId&, const KStartupInfoData& );
202 //* @internal
203 void gotStartupChange( const KStartupInfoId&, const KStartupInfoData& );
205 //* @internal
206 void taskChanged(::TaskManager::TaskChanges changes);
208 protected:
209 void configureStartup();
211 private:
212 class Private;
213 Private * const d;
216 } // TaskManager namespace
218 Q_DECLARE_OPERATORS_FOR_FLAGS(TaskManager::TaskChanges)
220 #endif