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 ******************************************************************/
28 #include <QtCore/QHash>
29 #include <QtCore/QSet>
30 #include <QtCore/QVector>
32 #include <KDE/KSharedPtr>
33 #include <KDE/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 EverythingChanged
= 0xffff
62 Q_DECLARE_FLAGS(TaskChanges
, TaskChange
)
63 } // namespace TaskManager
66 #include <taskmanager/startup.h>
67 #include <taskmanager/task.h>
68 #include <taskmanager/taskmanager_export.h>
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.
81 class TASKMANAGER_EXPORT TaskManager
: public QObject
84 Q_PROPERTY( int currentDesktop READ currentDesktop
)
85 Q_PROPERTY( int numberOfDesktops READ numberOfDesktops
)
88 static TaskManager
* self();
94 * Returns the task for a given WId, or 0 if there is no such task.
96 TaskPtr
findTask(WId w
);
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
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
);
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
);
185 void windowAdded(WId
);
187 void windowRemoved(WId
);
189 void windowChanged(WId
, unsigned int);
192 void activeWindowChanged(WId
);
194 void currentDesktopChanged(int);
196 void killStartup( const KStartupInfoId
& );
198 void killStartup(StartupPtr
);
201 void gotNewStartup( const KStartupInfoId
&, const KStartupInfoData
& );
203 void gotStartupChange( const KStartupInfoId
&, const KStartupInfoData
& );
206 void taskChanged(::TaskManager::TaskChanges changes
);
209 void configureStartup();
216 } // TaskManager namespace
218 Q_DECLARE_OPERATORS_FOR_FLAGS(TaskManager::TaskChanges
)