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
******************************************************************/
32
bool Task::updateDemandsAttentionState( WId w )
34
const bool empty = d->transientsDemandingAttention.isEmpty();
36
// 'w' is a transient for this task
37
NETWinInfo i( QX11Info::display(), w, QX11Info::appRootWindow(), NET::WMState );
38
if (i.state() & NET::DemandsAttention) {
39
if (!d->transientsDemandingAttention.contains(w)) {
40
d->transientsDemandingAttention.insert(w);
43
d->transientsDemandingAttention.remove(w);
47
return empty != d->transientsDemandingAttention.isEmpty();
50
void Task::addTransient( WId w, const NETWinInfo& info )
52
d->transients.insert(w);
53
if (info.state() & NET::DemandsAttention) {
54
d->transientsDemandingAttention.insert(w);
55
emit changed(TransientsChanged | StateChanged | AttentionChanged);
59
QString Task::className() const
62
if(XGetClassHint(QX11Info::display(), d->win, &hint)) {
63
QString nh( hint.res_name );
64
XFree( hint.res_name );
65
XFree( hint.res_class );
71
QString Task::classClass() const
74
if(XGetClassHint(QX11Info::display(), d->win, &hint)) {
75
QString ch( hint.res_class );
76
XFree( hint.res_name );
77
XFree( hint.res_class );
85
bool on_current = d->info.isOnCurrentDesktop();
89
KWindowSystem::setCurrentDesktop(d->info.desktop());
90
KWindowSystem::forceActiveWindow(d->win);
93
if (d->info.isMinimized())
95
KWindowSystem::unminimizeWindow(d->win);
98
QRect geom = d->info.geometry();
99
QCursor::setPos(geom.center());
101
NETRootInfo ri(QX11Info::display(), NET::WMMoveResize);
102
ri.moveResizeRequest(d->win, geom.center().x(),
103
geom.center().y(), NET::Move);
108
bool on_current = d->info.isOnCurrentDesktop();
112
KWindowSystem::setCurrentDesktop(d->info.desktop());
113
KWindowSystem::forceActiveWindow(d->win);
116
if (d->info.isMinimized())
118
KWindowSystem::unminimizeWindow(d->win);
121
QRect geom = d->info.geometry();
122
QCursor::setPos(geom.bottomRight());
124
NETRootInfo ri(QX11Info::display(), NET::WMMoveResize);
125
ri.moveResizeRequest(d->win, geom.bottomRight().x(),
126
geom.bottomRight().y(), NET::BottomRight);
129
void Task::setMaximized(bool maximize)
131
KWindowInfo info = KWindowSystem::windowInfo(d->win, NET::WMState | NET::XAWMState | NET::WMDesktop);
132
bool on_current = info.isOnCurrentDesktop();
136
KWindowSystem::setCurrentDesktop(info.desktop());
139
if (info.isMinimized())
141
KWindowSystem::unminimizeWindow(d->win);
144
NETWinInfo ni(QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMState);
148
ni.setState(NET::Max, NET::Max);
152
ni.setState(0, NET::Max);
157
KWindowSystem::forceActiveWindow(d->win);
163
KWindowInfo info = KWindowSystem::windowInfo(d->win, NET::WMState | NET::XAWMState | NET::WMDesktop);
164
bool on_current = info.isOnCurrentDesktop();
168
KWindowSystem::setCurrentDesktop(info.desktop());
171
if( info.isMinimized())
173
KWindowSystem::unminimizeWindow(d->win);
176
NETWinInfo ni(QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMState);
177
ni.setState(0, NET::Max);
181
KWindowSystem::forceActiveWindow( d->win );
187
NETRootInfo ri( QX11Info::display(), NET::CloseWindow );
188
ri.closeWindowRequest( d->win );
191
void Task::toDesktop(int desk)
193
NETWinInfo ni(QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMDesktop);
195
if (isOnAllDesktops()) {
196
ni.setDesktop(KWindowSystem::currentDesktop());
197
KWindowSystem::forceActiveWindow(d->win);
199
ni.setDesktop(NETWinInfo::OnAllDesktops);
207
if (desk == KWindowSystem::currentDesktop()) {
208
KWindowSystem::forceActiveWindow(d->win);
212
void Task::setAlwaysOnTop(bool stay)
214
NETWinInfo ni( QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMState);
216
ni.setState( NET::StaysOnTop, NET::StaysOnTop );
218
ni.setState( 0, NET::StaysOnTop );
221
void Task::setKeptBelowOthers(bool below)
223
NETWinInfo ni(QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMState);
227
ni.setState(NET::KeepBelow, NET::KeepBelow);
231
ni.setState(0, NET::KeepBelow);
235
void Task::setFullScreen(bool fullscreen)
237
NETWinInfo ni(QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMState);
241
ni.setState(NET::FullScreen, NET::FullScreen);
245
ni.setState(0, NET::FullScreen);
249
void Task::setShaded(bool shade)
251
NETWinInfo ni( QX11Info::display(), d->win, QX11Info::appRootWindow(), NET::WMState);
253
ni.setState( NET::Shaded, NET::Shaded );
255
ni.setState( 0, NET::Shaded );
258
void Task::publishIconGeometry(QRect rect)
260
if (rect == d->iconGeometry)
265
d->iconGeometry = rect;
266
NETWinInfo ni(QX11Info::display(), d->win, QX11Info::appRootWindow(), 0);
273
r.size.width = rect.width();
274
r.size.height = rect.height();
276
ni.setIconGeometry(r);
279
void Task::refreshActivities()
281
unsigned long properties[] = { 0, NET::WM2Activities };
282
NETWinInfo info(QX11Info::display(), d->win, QX11Info::appRootWindow(), properties, 2);
283
QString result(info.activities());
284
if (result.isEmpty() || result == "ALL") {
285
d->activities.clear();
287
d->activities = result.split(',');