• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
taskmanager.cpp
Go to the documentation of this file.
1 /*****************************************************************
2 
3 Copyright (c) 2000 Matthias Elter <elter@kde.org>
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11 
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14 
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22 ******************************************************************/
23 
24 #include "taskmanager.h"
25 #include "taskmanager.moc"
26 
27 #include <QApplication>
28 #include <QCursor>
29 #include <QImage>
30 #include <QTimer>
31 #include <QX11Info>
32 #include <QDesktopWidget>
33 #include <QPixmap>
34 #include <QList>
35 
36 #include <KGlobal>
37 #include <KIconLoader>
38 #include <KConfigGroup>
39 #include <KLocale>
40 #include <K3StaticDeleter>
41 #include <KWindowSystem>
42 
43 #include <kiconloader.h>
44 
45 TaskManager* TaskManager::m_self = 0;
46 static K3StaticDeleter<TaskManager> staticTaskManagerDeleter;
47 uint TaskManager::m_xCompositeEnabled = 0;
48 
49 TaskManager* TaskManager::self()
50 {
51  if (!m_self) {
52  staticTaskManagerDeleter.setObject(m_self, new TaskManager());
53  }
54  return m_self;
55 }
56 
57 TaskManager::TaskManager()
58  : QObject(),
59  _active(0),
60  _startup_info(0),
61  m_winModule(KWindowSystem::self()),
62  m_trackGeometry(false)
63 {
64  KGlobal::locale()->insertCatalog( QLatin1String( "libtaskmanager" ));
65  connect(m_winModule, SIGNAL(windowAdded(WId)),
66  this, SLOT(windowAdded(WId)));
67  connect(m_winModule, SIGNAL(windowRemoved(WId)),
68  this, SLOT(windowRemoved(WId)));
69  connect(m_winModule, SIGNAL(activeWindowChanged(WId)),
70  this, SLOT(activeWindowChanged(WId)));
71  connect(m_winModule, SIGNAL(currentDesktopChanged(int)),
72  this, SLOT(currentDesktopChanged(int)));
73  connect(m_winModule, SIGNAL(windowChanged(WId,uint)),
74  this, SLOT(windowChanged(WId,uint)));
75 
76  // register existing windows
77  const QList<WId> windows = m_winModule->windows();
78  QList<WId>::ConstIterator end(windows.end());
79  for (QList<WId>::ConstIterator it = windows.begin(); it != end; ++it) {
80  windowAdded(*it);
81  }
82 
83  // set active window
84  WId win = m_winModule->activeWindow();
85  activeWindowChanged(win);
86  configure_startup();
87 }
88 
89 TaskManager::~TaskManager()
90 {
91  KGlobal::locale()->removeCatalog("libtaskmanager");
92 }
93 
94 void TaskManager::configure_startup()
95 {
96  KConfig config("klaunchrc");
97  KConfigGroup c(&config, "FeedbackStyle");
98  if (!c.readEntry("TaskbarButton", true))
99  return;
100  _startup_info = new KStartupInfo(KStartupInfo::CleanOnCantDetect, this);
101  connect(_startup_info,
102  SIGNAL(gotNewStartup(KStartupInfoId,KStartupInfoData)),
103  SLOT(gotNewStartup(KStartupInfoId,KStartupInfoData)));
104  connect(_startup_info,
105  SIGNAL(gotStartupChange(KStartupInfoId,KStartupInfoData)),
106  SLOT(gotStartupChange(KStartupInfoId,KStartupInfoData)));
107  connect(_startup_info,
108  SIGNAL(gotRemoveStartup(KStartupInfoId,KStartupInfoData)),
109  SLOT(killStartup(KStartupInfoId)));
110  c = KConfigGroup(&config, "TaskbarButtonSettings");
111  _startup_info->setTimeout(c.readEntry("Timeout", 30));
112 }
113 
114 #ifdef THUMBNAILING_POSSIBLE
115 void TaskManager::setXCompositeEnabled(bool state)
116 {
117  Display *dpy = QPaintDevice::x11AppDisplay();
118 
119  if (!state) {
120  if (!--m_xCompositeEnabled) {
121  // unredirecting windows
122  for (int i = 0; i < ScreenCount(dpy); i++) {
123  XCompositeUnredirectSubwindows(dpy, RootWindow(dpy, i),
124  CompositeRedirectAutomatic);
125  }
126  }
127  return;
128  }
129 
130  if (m_xCompositeEnabled) {
131  // we don't unlearn riding bike ;)
132  m_xCompositeEnabled++;
133  return;
134  }
135 
136  // XComposite extension check
137  int event_base, error_base;
138  if (!XCompositeQueryExtension(dpy, &event_base, &error_base)) {
139  return;
140  }
141 
142  int major = 0, minor = 99; // The highest version we support
143  XCompositeQueryVersion(dpy, &major, &minor);
144 
145  // We use XCompositeNameWindowPixmap(), i.e. we need at least
146  // version 0.2.
147  if (major == 0 && minor < 2) {
148  return;
149  }
150 
151  // XRender extension check
152  if (!XRenderQueryExtension(dpy, &event_base, &error_base)) {
153  return;
154  }
155 
156  major = 0, minor = 99; // The highest version we support
157  XRenderQueryVersion(dpy, &major, &minor);
158 
159  // We use SetPictureTransform() and SetPictureFilter(), i.e. we
160  // need at least version 0.6.
161  if (major == 0 && minor < 6) {
162  return;
163  }
164 
165  // XFixes extension check
166  if (!XFixesQueryExtension(dpy, &event_base, &error_base)) {
167  return;
168  }
169 
170  major = 3, minor = 99; // The highest version we support
171  XFixesQueryVersion(dpy, &major, &minor);
172 
173  // We use Region objects, i.e. we need at least version 2.0.
174  if (major < 2) {
175  return;
176  }
177 
178  // if we get here, we've got usable extensions
179  m_xCompositeEnabled++;
180 
181  // redirecting windows to backing pixmaps
182  for (int i = 0; i < ScreenCount(dpy); i++) {
183  XCompositeRedirectSubwindows(dpy, RootWindow(dpy, i),
184  CompositeRedirectAutomatic);
185  }
186 
187  Task::Dict::iterator itEnd = m_tasksByWId.end();
188  for (Task::Dict::iterator it = m_tasksByWId.begin(); it != itEnd; ++it) {
189  it.data()->updateWindowPixmap();
190  }
191 }
192 #else // THUMBNAILING_POSSIBLE
193 void TaskManager::setXCompositeEnabled(bool)
194 {}
195 #endif // !THUMBNAILING_POSSIBLE
196 
197 Task::TaskPtr TaskManager::findTask(WId w)
198 {
199  // TODO: might be able to be made more efficient if
200  // we check to see if w is a transient first?
201  // profiling would say whether this is worth the effort
202 
203  Task::Dict::iterator it = m_tasksByWId.begin();
204  Task::Dict::iterator itEnd = m_tasksByWId.end();
205 
206  for (; it != itEnd; ++it) {
207  if (it.key() == w || it.value()->hasTransient(w)) {
208  return it.value();
209  }
210  }
211 
212  return Task::TaskPtr();
213 }
214 
215 Task::TaskPtr TaskManager::findTask(int desktop, const QPoint& p)
216 {
217  QList<WId> list = winModule()->stackingOrder();
218 
219  Task::TaskPtr task;
220  int currentIndex = -1;
221  Task::Dict::iterator itEnd = m_tasksByWId.end();
222  for (Task::Dict::iterator it = m_tasksByWId.begin(); it != itEnd; ++it) {
223  Task::TaskPtr t = it.value();
224  if (!t->isOnAllDesktops() && t->desktop() != desktop) {
225  continue;
226  }
227 
228  if (t->isIconified() || t->isShaded()) {
229  continue;
230  }
231 
232  if (t->geometry().contains(p)) {
233  int index = list.indexOf(t->window());
234  if (index > currentIndex) {
235  currentIndex = index;
236  task = t;
237  }
238  }
239  }
240 
241  return task;
242 }
243 
244 void TaskManager::windowAdded(WId w)
245 {
246  NETWinInfo info(QX11Info::display(), w, QX11Info::appRootWindow(),
247  NET::WMWindowType | NET::WMPid | NET::WMState);
248 
249  // ignore NET::Tool and other special window types
250  NET::WindowType wType =
251  info.windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask |
252  NET::ToolbarMask | NET::MenuMask | NET::DialogMask |
253  NET::OverrideMask | NET::TopMenuMask |
254  NET::UtilityMask | NET::SplashMask);
255 
256  if (wType != NET::Normal &&
257  wType != NET::Override &&
258  wType != NET::Unknown &&
259  wType != NET::Dialog &&
260  wType != NET::Utility) {
261  return;
262  }
263 
264  // ignore windows that want to be ignored by the taskbar
265  if ((info.state() & NET::SkipTaskbar) != 0) {
266  _skiptaskbar_windows.push_front(w); // remember them though
267  return;
268  }
269 
270  Window transient_for_tmp;
271  if (XGetTransientForHint(QX11Info::display(), (Window) w, &transient_for_tmp)) {
272  WId transient_for = (WId) transient_for_tmp;
273 
274  // check if it's transient for a skiptaskbar window
275  if (_skiptaskbar_windows.contains(transient_for))
276  return;
277 
278  // lets see if this is a transient for an existing task
279  if (transient_for != QX11Info::appRootWindow()
280  && transient_for != 0
281  && wType != NET::Utility) {
282  Task::TaskPtr t = findTask(transient_for);
283  if (t) {
284  if (t->window() != w) {
285  t->addTransient(w, info);
286  // kDebug() << "TM: Transient " << w << " added for Task: " << t->window() ;
287  }
288  return;
289  }
290  }
291  }
292 
293  Task::TaskPtr t(new Task(w, this));
294  m_tasksByWId[w] = t;
295 
296  // kDebug() << "TM: Task added for WId: " << w ;
297 
298  emit taskAdded(t);
299 }
300 
301 void TaskManager::windowRemoved(WId w)
302 {
303  _skiptaskbar_windows.removeAll(w);
304 
305  // find task
306  Task::TaskPtr t = findTask(w);
307  if (!t) {
308  return;
309  }
310 
311  if (t->window() == w) {
312  m_tasksByWId.remove(w);
313  emit taskRemoved(t);
314 
315  if (t == _active) {
316  _active = 0;
317  }
318 
319  //kDebug() << "TM: Task for WId " << w << " removed." ;
320  } else {
321  t->removeTransient(w);
322  //kDebug() << "TM: Transient " << w << " for Task " << t->window() << " removed." ;
323  }
324 }
325 
326 void TaskManager::windowChanged(WId w, unsigned int dirty)
327 {
328  if (dirty & NET::WMState) {
329  NETWinInfo info(QX11Info::display(), w, QX11Info::appRootWindow(),
330  NET::WMState | NET::XAWMState);
331  if (info.state() & NET::SkipTaskbar) {
332  windowRemoved(w);
333  _skiptaskbar_windows.push_front(w);
334  return;
335  } else {
336  _skiptaskbar_windows.removeAll(w);
337  if (info.mappingState() != NET::Withdrawn && !findTask(w)) {
338  // skipTaskBar state was removed and the window is still
339  // mapped, so add this window
340  windowAdded(w);
341  }
342  }
343  }
344 
345  // check if any state we are interested in is marked dirty
346  if (!(dirty & (NET::WMVisibleName | NET::WMName |
347  NET::WMState | NET::WMIcon |
348  NET::XAWMState | NET::WMDesktop) ||
349  (m_trackGeometry && dirty & NET::WMGeometry))) {
350  return;
351  }
352 
353  // find task
354  Task::TaskPtr t = findTask(w);
355  if (!t) {
356  return;
357  }
358 
359  //kDebug() << "TaskManager::windowChanged " << w << " " << dirty ;
360 
361  if (dirty & NET::WMState) {
362  t->updateDemandsAttentionState(w);
363  }
364 
365  // refresh icon pixmap if necessary
366  if (dirty & NET::WMIcon) {
367  t->refreshIcon();
368  dirty ^= NET::WMIcon;
369  }
370 
371  if (dirty) {
372  // only refresh this stuff if we have other changes besides icons
373  t->refresh(dirty);
374  }
375 
376  if (dirty & (NET::WMDesktop | NET::WMState | NET::XAWMState)) {
377  // moved to different desktop or is on all or change in iconification/withdrawnnes
378  emit windowChanged(t);
379 
380  if (m_xCompositeEnabled && dirty & NET::WMState) {
381  // update on restoring a minimized window
382  updateWindowPixmap(w);
383  }
384 
385  } else if (dirty & NET::WMGeometry) {
386  emit windowChangedGeometry(t);
387 
388  if (m_xCompositeEnabled) {
389  // update on size changes, not on task drags
390  updateWindowPixmap(w);
391  }
392 
393  }
394 }
395 
396 void TaskManager::updateWindowPixmap(WId w)
397 {
398  if (!m_xCompositeEnabled) {
399  return;
400  }
401 
402  Task::TaskPtr task = findTask(w);
403  if (task) {
404  task->updateWindowPixmap();
405  }
406 }
407 
408 void TaskManager::activeWindowChanged(WId w)
409 {
410  //kDebug() << "TaskManager::activeWindowChanged" ;
411 
412  Task::TaskPtr t = findTask(w);
413  if (!t) {
414  if (_active) {
415  _active->setActive(false);
416  _active = 0;
417 
418  // there is no active window at the moment
419  emit activeTaskChanged(Task::TaskPtr(0));
420  }
421  } else {
422  if (_active)
423  _active->setActive(false);
424 
425  _active = t;
426  _active->setActive(true);
427 
428  emit activeTaskChanged(_active);
429  }
430 }
431 
432 void TaskManager::currentDesktopChanged(int desktop)
433 {
434  emit desktopChanged(desktop);
435 }
436 
437 void TaskManager::gotNewStartup(const KStartupInfoId& id, const KStartupInfoData& data)
438 {
439  Startup::StartupPtr s(new Startup(id, data, this));
440  _startups.append(s);
441 
442  emit startupAdded(s);
443 }
444 
445 void TaskManager::gotStartupChange(const KStartupInfoId& id, const KStartupInfoData& data)
446 {
447  Startup::List::iterator itEnd = _startups.end();
448  for (Startup::List::iterator sIt = _startups.begin(); sIt != itEnd; ++sIt) {
449  if ((*sIt)->id() == id) {
450  (*sIt)->update(data);
451  return;
452  }
453  }
454 }
455 
456 void TaskManager::killStartup(const KStartupInfoId& id)
457 {
458  Startup::List::iterator sIt = _startups.begin();
459  Startup::List::iterator itEnd = _startups.end();
460  Startup::StartupPtr s;
461  for (; sIt != itEnd; ++sIt) {
462  if ((*sIt)->id() == id) {
463  s = *sIt;
464  break;
465  }
466  }
467 
468  if (!s) {
469  return;
470  }
471 
472  _startups.erase(sIt);
473  emit startupRemoved(s);
474 }
475 
476 void TaskManager::killStartup(Startup::StartupPtr s)
477 {
478  if (!s) {
479  return;
480  }
481 
482  Startup::List::iterator sIt = _startups.begin();
483  Startup::List::iterator itEnd = _startups.end();
484  for (; sIt != itEnd; ++sIt) {
485  if ((*sIt) == s) {
486  _startups.erase(sIt);
487  break;
488  }
489  }
490 
491  emit startupRemoved(s);
492 }
493 
494 QString TaskManager::desktopName(int desk) const
495 {
496  return m_winModule->desktopName(desk);
497 }
498 
499 int TaskManager::numberOfDesktops() const
500 {
501  return m_winModule->numberOfDesktops();
502 }
503 
504 bool TaskManager::isOnTop(const Task* task)
505 {
506  if (!task) {
507  return false;
508  }
509 
510  QList<WId> list = m_winModule->stackingOrder();
511  QList<WId>::const_iterator begin(list.constBegin());
512  QList<WId>::const_iterator it = list.constBegin() + (list.size() - 1);
513  do {
514  Task::Dict::iterator taskItEnd = m_tasksByWId.end();
515  for (Task::Dict::iterator taskIt = m_tasksByWId.begin();
516  taskIt != taskItEnd; ++taskIt) {
517  Task::TaskPtr t = taskIt.value();
518  if ((*it) == t->window()) {
519  if (t == task) {
520  return true;
521  }
522 
523  if (!t->isIconified() &&
524  (t->isAlwaysOnTop() == task->isAlwaysOnTop())) {
525  return false;
526  }
527 
528  break;
529  }
530  }
531  } while (it-- != begin);
532 
533  return false;
534 }
535 
536 bool TaskManager::isOnScreen(int screen, const WId wid)
537 {
538  if (screen == -1) {
539  return true;
540  }
541 
542  KWindowInfo wi = KWindowSystem::windowInfo(wid, NET::WMFrameExtents);
543 
544  // for window decos that fudge a bit and claim to extend beyond the
545  // edge of the screen, we just contract a bit.
546  QRect window = wi.frameGeometry();
547  QRect desktop = QApplication::desktop()->screenGeometry(screen);
548  desktop.adjust(5, 5, -5, -5);
549  return window.intersects(desktop);
550 }
551 
552 Task::Task(WId win, QObject *parent, const char *name)
553  : QObject(parent),
554  _active(false),
555  _win(win),
556  m_frameId(win),
557  _info(KWindowSystem::windowInfo(_win,
558  NET::WMState | NET::XAWMState | NET::WMDesktop | NET::WMVisibleName | NET::WMGeometry,
559  NET::WM2AllowedActions)),
560  _lastWidth(0),
561  _lastHeight(0),
562  _lastResize(false),
563  _lastIcon(),
564  _thumbSize(0.2),
565  _thumb(),
566  _grab()
567 {
568  setObjectName( QLatin1String( name ) );
569 
570  // try to load icon via net_wm
571  _pixmap = KWindowSystem::icon(_win, 16, 16, true);
572 
573  // try to guess the icon from the classhint
574  if (_pixmap.isNull()) {
575  KIconLoader::global()->loadIcon(className().toLower(),
576  KIconLoader::Small,
577  KIconLoader::Small,
578  KIconLoader::DefaultState,
579  QStringList(),0, true);
580  }
581 
582  // load xapp icon
583  if (_pixmap.isNull()) {
584  _pixmap = SmallIcon("kcmx");
585  }
586 
587 #ifdef THUMBNAILING_POSSIBLE
588  m_windowPixmap = 0;
589  findWindowFrameId();
590 
591  if (TaskManager::xCompositeEnabled()) {
592  updateWindowPixmap();
593  }
594 #endif // THUMBNAILING_POSSIBLE
595 }
596 
597 Task::~Task()
598 {
599 #ifdef THUMBNAILING_POSSIBLE
600  if (m_windowPixmap) {
601  XFreePixmap(QPaintDevice::x11AppDisplay(), m_windowPixmap);
602  }
603 #endif // THUMBNAILING_POSSIBLE
604 }
605 
606 // Task::findWindowFrameId()
607 // Code was copied from Kompose.
608 // Copyright (C) 2004 Hans Oischinger
609 // Permission granted on 2005-04-27.
610 void Task::findWindowFrameId()
611 {
612 #ifdef THUMBNAILING_POSSIBLE
613  Window target_win, parent, root;
614  Window *children;
615  uint nchildren;
616 
617  target_win = _win;
618  for (;;) {
619  if (!XQueryTree(QPaintDevice::x11AppDisplay(), target_win, &root,
620  &parent, &children, &nchildren)) {
621  break;
622  }
623 
624  if (children) {
625  XFree(children); // it's a list, that's deallocated!
626  }
627 
628  if (!parent || parent == root) {
629  break;
630  } else {
631  target_win = parent;
632  }
633  }
634 
635  m_frameId = target_win;
636 #endif // THUMBNAILING_POSSIBLE
637 }
638 
639 void Task::refreshIcon()
640 {
641  // try to load icon via net_wm
642  _pixmap = KWindowSystem::icon(_win, 16, 16, true);
643 
644  // try to guess the icon from the classhint
645  if (_pixmap.isNull()) {
646  KIconLoader::global()->loadIcon(className().toLower(),
647  KIconLoader::Small,
648  KIconLoader::Small,
649  KIconLoader::DefaultState,
650  QStringList(),0, true);
651  }
652 
653  // load xapp icon
654  if (_pixmap.isNull()) {
655  _pixmap = SmallIcon("kcmx");
656  }
657 
658  _lastIcon = QPixmap();
659  emit iconChanged();
660 }
661 
662 void Task::refresh(unsigned int dirty)
663 {
664  QString name = visibleName();
665  _info = KWindowSystem::windowInfo(_win,
666  NET::WMState | NET::XAWMState | NET::WMDesktop | NET::WMVisibleName | NET::WMGeometry,
667  NET::WM2AllowedActions);
668 
669  if (dirty != NET::WMName || name != visibleName()) {
670  emit changed();
671  }
672 }
673 
674 void Task::setActive(bool a)
675 {
676  _active = a;
677  emit changed();
678  if (a)
679  emit activated();
680  else
681  emit deactivated();
682 }
683 
684 bool Task::isMaximized() const
685 {
686  return _info.valid() && (_info.state() & NET::Max);
687 }
688 
689 bool Task::isMinimized() const
690 {
691  return _info.valid() && _info.isMinimized();
692 }
693 
694 bool Task::isIconified() const
695 {
696  return _info.valid() && _info.isMinimized();
697 }
698 
699 bool Task::isAlwaysOnTop() const
700 {
701  return _info.valid() && (_info.state() & NET::StaysOnTop);
702 }
703 
704 bool Task::isKeptBelowOthers() const
705 {
706  return _info.valid() && (_info.state() & NET::KeepBelow);
707 }
708 
709 bool Task::isFullScreen() const
710 {
711  return _info.valid() && (_info.state() & NET::FullScreen);
712 }
713 
714 bool Task::isShaded() const
715 {
716  return _info.valid() && (_info.state() & NET::Shaded);
717 }
718 
719 bool Task::isOnCurrentDesktop() const
720 {
721  return _info.valid() && _info.isOnCurrentDesktop();
722 }
723 
724 bool Task::isOnAllDesktops() const
725 {
726  return _info.valid() && _info.onAllDesktops();
727 }
728 
729 bool Task::isActive() const
730 {
731  return _active;
732 }
733 
734 bool Task::isOnTop() const
735 {
736  return TaskManager::self()->isOnTop(this);
737 }
738 
739 bool Task::isModified() const
740 {
741  static QString modStr = QString::fromUtf8("[") +
742  i18n("modified") +
743  QString::fromUtf8("]");
744  int modStrPos = _info.visibleName().indexOf(modStr);
745 
746  return (modStrPos != -1);
747 }
748 
749 bool Task::demandsAttention() const
750 {
751  return (_info.valid() && (_info.state() & NET::DemandsAttention)) ||
752  _transients_demanding_attention.count() > 0;
753 }
754 
755 bool Task::isOnScreen(int screen) const
756 {
757  return TaskManager::isOnScreen(screen, _win);
758 }
759 
760 void Task::updateDemandsAttentionState(WId w)
761 {
762  if (window() != w) {
763  // 'w' is a transient for this task
764  NETWinInfo i(QX11Info::display(), w, QX11Info::appRootWindow(), NET::WMState);
765  if (i.state() & NET::DemandsAttention) {
766  if (!_transients_demanding_attention.contains(w)) {
767  _transients_demanding_attention.append(w);
768  }
769  } else {
770  _transients_demanding_attention.removeAll(w);
771  }
772  }
773 }
774 
775 void Task::addTransient(WId w, const NETWinInfo& info)
776 {
777  _transients.append(w);
778  if (info.state() & NET::DemandsAttention) {
779  _transients_demanding_attention.append(w);
780  emit changed();
781  }
782 }
783 
784 void Task::removeTransient(WId w)
785 {
786  _transients.removeAll(w);
787  _transients_demanding_attention.removeAll(w);
788 }
789 
790 QString Task::className()
791 {
792  XClassHint hint;
793  if (XGetClassHint(QX11Info::display(), _win, &hint)) {
794  QString nh(hint.res_name);
795  XFree(hint.res_name);
796  XFree(hint.res_class);
797  return nh;
798  }
799  return QString();
800 }
801 
802 QString Task::classClass()
803 {
804  XClassHint hint;
805  if (XGetClassHint(QX11Info::display(), _win, &hint)) {
806  QString ch(hint.res_class);
807  XFree(hint.res_name);
808  XFree(hint.res_class);
809  return ch;
810  }
811  return QString();
812 }
813 
814 QPixmap Task::icon(int width, int height, bool allowResize)
815 {
816  if ((width == _lastWidth)
817  && (height == _lastHeight)
818  && (allowResize == _lastResize)
819  && (!_lastIcon.isNull()))
820  return _lastIcon;
821 
822  QPixmap newIcon = KWindowSystem::icon(_win, width, height, allowResize);
823  if (!newIcon.isNull()) {
824  _lastIcon = newIcon;
825  _lastWidth = width;
826  _lastHeight = height;
827  _lastResize = allowResize;
828  }
829 
830  return newIcon;
831 }
832 
833 QPixmap Task::bestIcon(int size, bool &isStaticIcon)
834 {
835  QPixmap pixmap;
836  isStaticIcon = false;
837 
838  switch (size) {
839  case KIconLoader::SizeSmall: {
840  pixmap = icon(16, 16, true);
841 
842  // Icon of last resort
843  if (pixmap.isNull()) {
844  pixmap = KIconLoader::global()->loadIcon("go",
845  KIconLoader::NoGroup,
846  KIconLoader::SizeSmall);
847  isStaticIcon = true;
848  }
849  }
850  break;
851  case KIconLoader::SizeMedium: {
852  //
853  // Try 34x34 first for KDE 2.1 icons with shadows, if we don't
854  // get one then try 32x32.
855  //
856  pixmap = icon(34, 34, false);
857 
858  if (((pixmap.width() != 34) || (pixmap.height() != 34)) &&
859  ((pixmap.width() != 32) || (pixmap.height() != 32))) {
860  pixmap = icon(32, 32, true);
861  }
862 
863  // Icon of last resort
864  if (pixmap.isNull()) {
865  pixmap = KIconLoader::global()->loadIcon("go",
866  KIconLoader::NoGroup,
867  KIconLoader::SizeMedium);
868  isStaticIcon = true;
869  }
870  }
871  break;
872  case KIconLoader::SizeLarge: {
873  // If there's a 48x48 icon in the hints then use it
874  pixmap = icon(size, size, false);
875 
876  // If not, try to get one from the classname
877  if (pixmap.isNull() || pixmap.width() != size || pixmap.height() != size) {
878  pixmap = KIconLoader::global()->loadIcon(className(),
879  KIconLoader::NoGroup,
880  size,
881  KIconLoader::DefaultState,
882  QStringList(),0L,
883  true);
884  isStaticIcon = true;
885  }
886 
887  // If we still don't have an icon then scale the one in the hints
888  if (pixmap.isNull() || (pixmap.width() != size) || (pixmap.height() != size)) {
889  pixmap = icon(size, size, true);
890  isStaticIcon = false;
891  }
892 
893  // Icon of last resort
894  if (pixmap.isNull()) {
895  pixmap = KIconLoader::global()->loadIcon("go",
896  KIconLoader::NoGroup,
897  size);
898  isStaticIcon = true;
899  }
900  }
901  }
902 
903  return pixmap;
904 }
905 
906 bool Task::idMatch(const QString& id1, const QString& id2)
907 {
908  if (id1.isEmpty() || id2.isEmpty())
909  return false;
910 
911  if (id1.contains(id2) > 0)
912  return true;
913 
914  if (id2.contains(id1) > 0)
915  return true;
916 
917  return false;
918 }
919 
920 
921 void Task::move()
922 {
923  bool on_current = _info.isOnCurrentDesktop();
924 
925  if (!on_current) {
926  KWindowSystem::setCurrentDesktop(_info.desktop());
927  KWindowSystem::forceActiveWindow(_win);
928  }
929 
930  if (_info.isMinimized()) {
931  KWindowSystem::unminimizeWindow(_win);
932  }
933 
934  QRect geom = _info.geometry();
935  QCursor::setPos(geom.center());
936 
937  NETRootInfo ri(QX11Info::display(), NET::WMMoveResize);
938  ri.moveResizeRequest(_win, geom.center().x(),
939  geom.center().y(), NET::Move);
940 }
941 
942 void Task::resize()
943 {
944  bool on_current = _info.isOnCurrentDesktop();
945 
946  if (!on_current) {
947  KWindowSystem::setCurrentDesktop(_info.desktop());
948  KWindowSystem::forceActiveWindow(_win);
949  }
950 
951  if (_info.isMinimized()) {
952  KWindowSystem::unminimizeWindow(_win);
953  }
954 
955  QRect geom = _info.geometry();
956  QCursor::setPos(geom.bottomRight());
957 
958  NETRootInfo ri(QX11Info::display(), NET::WMMoveResize);
959  ri.moveResizeRequest(_win, geom.bottomRight().x(),
960  geom.bottomRight().y(), NET::BottomRight);
961 }
962 
963 void Task::setMaximized(bool maximize)
964 {
965  KWindowInfo info = KWindowSystem::windowInfo(_win, NET::WMState | NET::XAWMState | NET::WMDesktop);
966  bool on_current = info.isOnCurrentDesktop();
967 
968  if (!on_current) {
969  KWindowSystem::setCurrentDesktop(info.desktop());
970  }
971 
972  if (info.isMinimized()) {
973  KWindowSystem::unminimizeWindow(_win);
974  }
975 
976  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMState);
977 
978  if (maximize) {
979  ni.setState(NET::Max, NET::Max);
980  } else {
981  ni.setState(0, NET::Max);
982  }
983 
984  if (!on_current) {
985  KWindowSystem::forceActiveWindow(_win);
986  }
987 }
988 
989 void Task::toggleMaximized()
990 {
991  setMaximized(!isMaximized());
992 }
993 
994 void Task::restore()
995 {
996  KWindowInfo info = KWindowSystem::windowInfo(_win, NET::WMState | NET::XAWMState | NET::WMDesktop);
997  bool on_current = info.isOnCurrentDesktop();
998 
999  if (!on_current) {
1000  KWindowSystem::setCurrentDesktop(info.desktop());
1001  }
1002 
1003  if (info.isMinimized()) {
1004  KWindowSystem::unminimizeWindow(_win);
1005  }
1006 
1007  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMState);
1008  ni.setState(0, NET::Max);
1009 
1010  if (!on_current) {
1011  KWindowSystem::forceActiveWindow(_win);
1012  }
1013 }
1014 
1015 void Task::setIconified(bool iconify)
1016 {
1017  if (iconify) {
1018  KWindowSystem::minimizeWindow(_win);
1019  } else {
1020  KWindowInfo info = KWindowSystem::windowInfo(_win, NET::WMState | NET::XAWMState | NET::WMDesktop);
1021  bool on_current = info.isOnCurrentDesktop();
1022 
1023  if (!on_current) {
1024  KWindowSystem::setCurrentDesktop(info.desktop());
1025  }
1026 
1027  KWindowSystem::unminimizeWindow(_win);
1028 
1029  if (!on_current) {
1030  KWindowSystem::forceActiveWindow(_win);
1031  }
1032  }
1033 }
1034 
1035 void Task::toggleIconified()
1036 {
1037  setIconified(!isIconified());
1038 }
1039 
1040 void Task::close()
1041 {
1042  NETRootInfo ri(QX11Info::display(), NET::CloseWindow);
1043  ri.closeWindowRequest(_win);
1044 }
1045 
1046 void Task::raise()
1047 {
1048 // kDebug(1210) << "Task::raise(): " << name() ;
1049  KWindowSystem::raiseWindow(_win);
1050 }
1051 
1052 void Task::lower()
1053 {
1054 // kDebug(1210) << "Task::lower(): " << name() ;
1055  KWindowSystem::lowerWindow(_win);
1056 }
1057 
1058 void Task::activate()
1059 {
1060 // kDebug(1210) << "Task::activate():" << name() ;
1061  WId w = _win;
1062  if (_transients_demanding_attention.count() > 0) {
1063  w = _transients_demanding_attention.last();
1064  }
1065  KWindowSystem::forceActiveWindow(w);
1066 }
1067 
1068 void Task::activateRaiseOrIconify()
1069 {
1070  if (!isActive() || isIconified()) {
1071  activate();
1072  } else if (!isOnTop()) {
1073  raise();
1074  } else {
1075  setIconified(true);
1076  }
1077 }
1078 
1079 void Task::toDesktop(int desk)
1080 {
1081  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMDesktop);
1082  if (desk == 0) {
1083  if (_info.valid() && _info.onAllDesktops()) {
1084  ni.setDesktop(TaskManager::self()->winModule()->currentDesktop());
1085  KWindowSystem::forceActiveWindow(_win);
1086  } else {
1087  ni.setDesktop(NETWinInfo::OnAllDesktops);
1088  }
1089 
1090  return;
1091  }
1092  ni.setDesktop(desk);
1093  if (desk == TaskManager::self()->winModule()->currentDesktop())
1094  KWindowSystem::forceActiveWindow(_win);
1095 }
1096 
1097 void Task::toCurrentDesktop()
1098 {
1099  toDesktop(TaskManager::self()->winModule()->currentDesktop());
1100 }
1101 
1102 void Task::setAlwaysOnTop(bool stay)
1103 {
1104  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMState);
1105  if (stay)
1106  ni.setState(NET::StaysOnTop, NET::StaysOnTop);
1107  else
1108  ni.setState(0, NET::StaysOnTop);
1109 }
1110 
1111 void Task::toggleAlwaysOnTop()
1112 {
1113  setAlwaysOnTop(!isAlwaysOnTop());
1114 }
1115 
1116 void Task::setKeptBelowOthers(bool below)
1117 {
1118  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMState);
1119 
1120  if (below) {
1121  ni.setState(NET::KeepBelow, NET::KeepBelow);
1122  } else {
1123  ni.setState(0, NET::KeepBelow);
1124  }
1125 }
1126 
1127 void Task::toggleKeptBelowOthers()
1128 {
1129  setKeptBelowOthers(!isKeptBelowOthers());
1130 }
1131 
1132 void Task::setFullScreen(bool fullscreen)
1133 {
1134  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMState);
1135 
1136  if (fullscreen) {
1137  ni.setState(NET::FullScreen, NET::FullScreen);
1138  } else {
1139  ni.setState(0, NET::FullScreen);
1140  }
1141 }
1142 
1143 void Task::toggleFullScreen()
1144 {
1145  setFullScreen(!isFullScreen());
1146 }
1147 
1148 void Task::setShaded(bool shade)
1149 {
1150  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), NET::WMState);
1151  if (shade)
1152  ni.setState(NET::Shaded, NET::Shaded);
1153  else
1154  ni.setState(0, NET::Shaded);
1155 }
1156 
1157 void Task::toggleShaded()
1158 {
1159  setShaded(!isShaded());
1160 }
1161 
1162 void Task::publishIconGeometry(QRect rect)
1163 {
1164  if (rect == m_iconGeometry) {
1165  return;
1166  }
1167 
1168  m_iconGeometry = rect;
1169  NETWinInfo ni(QX11Info::display(), _win, QX11Info::appRootWindow(), 0);
1170  NETRect r;
1171 
1172  if (rect.isValid()) {
1173  r.pos.x = rect.x();
1174  r.pos.y = rect.y();
1175  r.size.width = rect.width();
1176  r.size.height = rect.height();
1177  }
1178  ni.setIconGeometry(r);
1179 }
1180 
1181 void Task::updateThumbnail()
1182 {
1183  if (!_info.valid() ||
1184  !isOnCurrentDesktop() ||
1185  !isActive() ||
1186  !_grab.isNull()) // We're already processing one...
1187  {
1188  return;
1189  }
1190 
1191  //
1192  // We do this as a two stage process to remove the delay caused
1193  // by the thumbnail generation. This makes things much smoother
1194  // on slower machines.
1195  //
1196  QWidget *rootWin = qApp->desktop();
1197  QRect geom = _info.geometry();
1198  _grab = QPixmap::grabWindow(rootWin->winId(),
1199  geom.x(), geom.y(),
1200  geom.width(), geom.height());
1201 
1202  if (!_grab.isNull()) {
1203  QTimer::singleShot(200, this, SLOT(generateThumbnail()));
1204  }
1205 }
1206 
1207 void Task::generateThumbnail()
1208 {
1209  if (_grab.isNull())
1210  return;
1211 
1212  double width = _grab.width();
1213  double height = _grab.height();
1214  width = width * _thumbSize;
1215  height = height * _thumbSize;
1216 
1217  _thumb = _grab.scaled(qRound(width), qRound(height), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
1218  _grab = QPixmap(); // Makes grab a null image.
1219 
1220  emit thumbnailChanged();
1221 }
1222 
1223 #ifdef THUMBNAILING_POSSIBLE
1224 QPixmap Task::thumbnail(int maxDimension)
1225 {
1226  if (!TaskManager::xCompositeEnabled() || !m_windowPixmap) {
1227  return QPixmap();
1228  }
1229 
1230  Display *dpy = QPaintDevice::x11AppDisplay();
1231 
1232  XWindowAttributes winAttr;
1233  XGetWindowAttributes(dpy, m_frameId, &winAttr);
1234  XRenderPictFormat *format = XRenderFindVisualFormat(dpy, winAttr.visual);
1235 
1236  XRenderPictureAttributes picAttr;
1237  picAttr.subwindow_mode = IncludeInferiors; // Don't clip child widgets
1238 
1239  Picture picture = XRenderCreatePicture(dpy, m_windowPixmap, format,
1240  CPSubwindowMode, &picAttr);
1241 
1242  // Get shaped windows handled correctly.
1243  XserverRegion region = XFixesCreateRegionFromWindow(dpy, m_frameId,
1244  WindowRegionBounding);
1245  XFixesSetPictureClipRegion(dpy, picture, 0, 0, region);
1246  XFixesDestroyRegion(dpy, region);
1247 
1248  double factor;
1249  if (winAttr.width > winAttr.height) {
1250  factor = (double)maxDimension / (double)winAttr.width;
1251  } else {
1252  factor = (double)maxDimension / (double)winAttr.height;
1253  }
1254  int thumbnailWidth = (int)(winAttr.width * factor);
1255  int thumbnailHeight = (int)(winAttr.height * factor);
1256 
1257  QPixmap thumbnail(thumbnailWidth, thumbnailHeight);
1258  thumbnail.fill(QApplication::palette().active().background());
1259 
1260 #if 0 // QImage::smoothScale() scaling
1261  QPixmap full(winAttr.width, winAttr.height);
1262  full.fill(QApplication::palette().active().background());
1263 
1264  bool hasAlpha = format->type == PictTypeDirect && format->direct.alphaMask;
1265 
1266  XRenderComposite(dpy,
1267  hasAlpha ? PictOpOver : PictOpSrc,
1268  picture, // src
1269  None, // mask
1270  full.x11RenderHandle(), // dst
1271  0, 0, // src offset
1272  0, 0, // mask offset
1273  0, 0, // dst offset
1274  winAttr.width, winAttr.height);
1275 
1276  KPixmapIO io;
1277  QImage image = io.toImage(full);
1278  thumbnail = io.convertToPixmap(image.smoothScale(thumbnailWidth,
1279  thumbnailHeight));
1280 #else // XRENDER scaling
1281  // Scaling matrix
1282  XTransform transformation = {{
1283  { XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0) },
1284  { XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0) },
1285  { XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(factor) }
1286  }};
1287 
1288  XRenderSetPictureTransform(dpy, picture, &transformation);
1289  XRenderSetPictureFilter(dpy, picture, FilterBest, 0, 0);
1290 
1291  XRenderComposite(QPaintDevice::x11AppDisplay(),
1292  PictOpOver, // we're filtering, alpha values are probable
1293  picture, // src
1294  None, // mask
1295  thumbnail.x11PictureHandle(), // dst
1296  0, 0, // src offset
1297  0, 0, // mask offset
1298  0, 0, // dst offset
1299  thumbnailWidth, thumbnailHeight);
1300 #endif
1301  XRenderFreePicture(dpy, picture);
1302 
1303  return thumbnail;
1304 }
1305 #else // THUMBNAILING_POSSIBLE
1306 QPixmap Task::thumbnail(int /* maxDimension */)
1307 {
1308  return QPixmap();
1309 }
1310 #endif // THUMBNAILING_POSSIBLE
1311 
1312 void Task::updateWindowPixmap()
1313 {
1314 #ifdef THUMBNAILING_POSSIBLE
1315  if (!TaskManager::xCompositeEnabled() || !isOnCurrentDesktop() ||
1316  isMinimized()) {
1317  return;
1318  }
1319 
1320  Display *dpy = QPaintDevice::x11AppDisplay();
1321 
1322  if (m_windowPixmap) {
1323  XFreePixmap(dpy, m_windowPixmap);
1324  }
1325 
1326  m_windowPixmap = XCompositeNameWindowPixmap(dpy, m_frameId);
1327 #endif // THUMBNAILING_POSSIBLE
1328 }
1329 
1330 Startup::Startup(const KStartupInfoId& id, const KStartupInfoData& data,
1331  QObject * parent, const char *name)
1332  : QObject(parent), _id(id), _data(data)
1333 {
1334  setObjectName( QLatin1String( name ) );
1335 }
1336 
1337 Startup::~Startup()
1338 {}
1339 
1340 void Startup::update(const KStartupInfoData& data)
1341 {
1342  _data.update(data);
1343  emit changed();
1344 }
1345 
1346 int TaskManager::currentDesktop() const
1347 {
1348  return m_winModule->currentDesktop();
1349 }
1350 
1351 TaskDrag::TaskDrag(const Task::List& tasks, QWidget* source)
1352  : QDrag(source)
1353 {
1354  QByteArray data;
1355  QDataStream stream(&data, QIODevice::WriteOnly);
1356 
1357  stream.setVersion(QDataStream::Qt_3_1);
1358 
1359  Task::List::const_iterator itEnd = tasks.constEnd();
1360  for (Task::List::const_iterator it = tasks.constBegin(); it != itEnd; ++it) {
1361  stream << (quint32)(*it)->window();
1362  }
1363 
1364  QMimeData* mimeData = new QMimeData();
1365  mimeData->setData("taskbar/task", data);
1366  setMimeData(mimeData);
1367 }
1368 
1369 TaskDrag::~TaskDrag()
1370 {}
1371 
1372 bool TaskDrag::canDecode(const QMimeData* e)
1373 {
1374  return e->hasFormat("taskbar/task");
1375 }
1376 
1377 Task::List TaskDrag::decode(const QMimeData* e)
1378 {
1379  QByteArray data(e->data("taskbar/task"));
1380  Task::List tasks;
1381 
1382  if (data.size()) {
1383  QDataStream stream(data);
1384  while (!stream.atEnd()) {
1385  quint32 id;
1386  stream >> id;
1387  if (Task::TaskPtr task = TaskManager::self()->findTask(id)) {
1388  tasks.append(task);
1389  }
1390  }
1391  }
1392 
1393  return tasks;
1394 }
1395 
Task::setAlwaysOnTop
void setAlwaysOnTop(bool)
If true, the task's window will remain at the top of the stacking order.
Definition: taskmanager.cpp:1102
TaskManager::killStartup
void killStartup(const KStartupInfoId &)
Definition: taskmanager.cpp:456
Task::activateRaiseOrIconify
void activateRaiseOrIconify()
Perform the action that is most appropriate for this task.
Definition: taskmanager.cpp:1068
Task::iconChanged
void iconChanged()
Indicates that the icon for this task has changed.
TaskManager::isOnTop
bool isOnTop(const Task *)
Returns true if the specified task is on top.
Definition: taskmanager.cpp:504
Task::changed
void changed()
Indicates that this task has changed in some way.
Task::thumbnail
const QPixmap & thumbnail() const
Returns the thumbnail for this task (or a null image if there is none).
Definition: taskmanager.h:344
TaskManager::taskAdded
void taskAdded(Task::TaskPtr)
Emitted when a new task has started.
Task::isAlwaysOnTop
bool isAlwaysOnTop() const
Returns true if the task's window will remain at the top of the stacking order.
Definition: taskmanager.cpp:699
QDrag
Task::toggleMaximized
void toggleMaximized()
Definition: taskmanager.cpp:989
Task::thumbnailChanged
void thumbnailChanged()
Indicates that the thumbnail for this task has changed.
Task::move
void move()
Move the window of this task.
Definition: taskmanager.cpp:921
TaskManager::gotStartupChange
void gotStartupChange(const KStartupInfoId &, const KStartupInfoData &)
Definition: taskmanager.cpp:445
Task::activated
void activated()
Indicates that this task is now the active task.
TaskManager::desktopName
QString desktopName(int n) const
Returns the name of the nth desktop.
Definition: taskmanager.cpp:494
Task::isOnCurrentDesktop
bool isOnCurrentDesktop() const
Returns true if the task's window is on the current virtual desktop.
Definition: taskmanager.cpp:719
Startup::changed
void changed()
Indicates that this startup has changed in some way.
TaskManager::windowAdded
void windowAdded(WId)
Definition: taskmanager.cpp:244
Task::name
QString name() const
Definition: taskmanager.h:121
TaskManager::setXCompositeEnabled
void setXCompositeEnabled(bool state)
Definition: taskmanager.cpp:193
Task::setMaximized
void setMaximized(bool)
Maximise the main window of this task.
Definition: taskmanager.cpp:963
Task::toDesktop
void toDesktop(int)
Moves the task's window to the specified virtual desktop.
Definition: taskmanager.cpp:1079
Startup
Represents a task which is in the process of starting.
Definition: taskmanager.h:547
Task::bestIcon
QPixmap bestIcon(int size, bool &isStaticIcon)
Returns the best icon for any of the KIconLoader::StdSizes.
Definition: taskmanager.cpp:833
staticTaskManagerDeleter
static K3StaticDeleter< TaskManager > staticTaskManagerDeleter
Definition: taskmanager.cpp:46
TaskManager::numberOfDesktops
int numberOfDesktops() const
Returns the number of virtual desktops.
TaskManager::configure_startup
void configure_startup()
Definition: taskmanager.cpp:94
Task::isModified
bool isModified() const
Returns true if the document the task is editing has been modified.
Definition: taskmanager.cpp:739
TaskManager::taskRemoved
void taskRemoved(Task::TaskPtr)
Emitted when a task has terminated.
Task::isOnScreen
bool isOnScreen(int screen) const
Returns true if the window is on the specified screen of a multihead configuration.
Definition: taskmanager.cpp:755
Task::findWindowFrameId
void findWindowFrameId()
Definition: taskmanager.cpp:610
Task::toggleAlwaysOnTop
void toggleAlwaysOnTop()
Definition: taskmanager.cpp:1111
QWidget
Task::isMaximized
bool isMaximized() const
Returns true if the task's window is maximized.
Definition: taskmanager.cpp:684
TaskManager
A generic API for task managers.
Definition: taskmanager.h:613
Task::updateDemandsAttentionState
void updateDemandsAttentionState(WId w)
Definition: taskmanager.cpp:760
Task::pixmap
QPixmap pixmap() const
Returns a 16x16 (KIconLoader::Small) icon for the task.
Definition: taskmanager.h:142
TaskManager::currentDesktop
int currentDesktop() const
Returns the number of the current desktop.
Task::isKeptBelowOthers
bool isKeptBelowOthers() const
Returns true if the task's window will remain at the bottom of the stacking order.
Definition: taskmanager.cpp:704
TaskManager::~TaskManager
~TaskManager()
Definition: taskmanager.cpp:89
taskmanager.h
QObject
Task::isOnTop
bool isOnTop() const
Returns true if the task's window is the topmost non-iconified, non-always-on-top window...
Definition: taskmanager.cpp:734
TaskManager::desktopChanged
void desktopChanged(int desktop)
Emitted when the current desktop changes.
Task::publishIconGeometry
void publishIconGeometry(QRect)
This method informs the window manager of the location at which this task will be displayed when icon...
Definition: taskmanager.cpp:1162
Startup::StartupPtr
KSharedPtr< Startup > StartupPtr
Definition: taskmanager.h:555
Task::List
QVector< Task::TaskPtr > List
Definition: taskmanager.h:98
TaskManager::isOnScreen
static bool isOnScreen(int screen, const WId wid)
Returns whether the Window with WId wid is on the screen screen.
Definition: taskmanager.cpp:536
Task::className
QString className()
Definition: taskmanager.cpp:790
Task::toggleKeptBelowOthers
void toggleKeptBelowOthers()
Definition: taskmanager.cpp:1127
TaskManager::windowChanged
void windowChanged(Task::TaskPtr)
Emitted when a window changes desktop.
Task::setIconified
void setIconified(bool)
Iconify the task.
Definition: taskmanager.cpp:1015
Task::generateThumbnail
void generateThumbnail()
Definition: taskmanager.cpp:1207
Task::setShaded
void setShaded(bool)
If true then the task's window will be shaded.
Definition: taskmanager.cpp:1148
TaskManager::winModule
KWindowSystem * winModule() const
Definition: taskmanager.h:684
TaskManager::xCompositeEnabled
static bool xCompositeEnabled()
Definition: taskmanager.h:690
TaskDrag::~TaskDrag
~TaskDrag()
Definition: taskmanager.cpp:1369
Task::resize
void resize()
Resize the window of this task.
Definition: taskmanager.cpp:942
TaskManager::windowRemoved
void windowRemoved(WId)
Definition: taskmanager.cpp:301
TaskManager::gotNewStartup
void gotNewStartup(const KStartupInfoId &, const KStartupInfoData &)
Definition: taskmanager.cpp:437
Task::toggleShaded
void toggleShaded()
Definition: taskmanager.cpp:1157
Task::setFullScreen
void setFullScreen(bool)
If true, the task's window will enter full screen mode.
Definition: taskmanager.cpp:1132
Task::isActive
bool isActive() const
Returns true if the task's window is the active window.
Definition: taskmanager.cpp:729
Task::setActive
void setActive(bool a)
Definition: taskmanager.cpp:674
Startup::update
void update(const KStartupInfoData &data)
Definition: taskmanager.cpp:1340
Task::toggleIconified
void toggleIconified()
Definition: taskmanager.cpp:1035
Task::info
KWindowInfo info() const
Definition: taskmanager.h:108
TaskManager::activeTaskChanged
void activeTaskChanged(Task::TaskPtr)
Emitted when the active window changed.
Task::close
void close()
Close the task's window.
Definition: taskmanager.cpp:1040
Task::icon
QPixmap icon(int width, int height, bool allowResize=false)
Tries to find an icon for the task with the specified size.
Definition: taskmanager.cpp:814
Startup::~Startup
virtual ~Startup()
Definition: taskmanager.cpp:1337
Task::isMinimized
bool isMinimized() const
Returns true if the task's window is minimized.
Definition: taskmanager.cpp:689
Task::raise
void raise()
Raise the task's window.
Definition: taskmanager.cpp:1046
TaskManager::currentDesktopChanged
void currentDesktopChanged(int)
Definition: taskmanager.cpp:432
Task::activate
void activate()
Activate the task's window.
Definition: taskmanager.cpp:1058
TaskManager::activeWindowChanged
void activeWindowChanged(WId)
Definition: taskmanager.cpp:408
TaskDrag::canDecode
static bool canDecode(const QMimeData *e)
Returns true if the mime source can be decoded to a TaskDrag.
Definition: taskmanager.cpp:1372
TaskManager::self
static TaskManager * self()
Definition: taskmanager.cpp:49
Task::isOnAllDesktops
bool isOnAllDesktops() const
Returns true if the task's window is on all virtual desktops.
Definition: taskmanager.cpp:724
Task::addTransient
void addTransient(WId w, const NETWinInfo &info)
Definition: taskmanager.cpp:775
Task::isFullScreen
bool isFullScreen() const
Returns true if the task's window is in full screen mode.
Definition: taskmanager.cpp:709
Task::updateThumbnail
void updateThumbnail()
Tells the task to generate a new thumbnail.
Definition: taskmanager.cpp:1181
Task::setKeptBelowOthers
void setKeptBelowOthers(bool)
If true, the task's window will remain at the bottom of the stacking order.
Definition: taskmanager.cpp:1116
Task::visibleName
QString visibleName() const
Definition: taskmanager.h:113
Task::refresh
void refresh(unsigned int dirty)
Definition: taskmanager.cpp:662
Task::restore
void restore()
Restore the main window of the task (if it was iconified).
Definition: taskmanager.cpp:994
Task::toggleFullScreen
void toggleFullScreen()
Definition: taskmanager.cpp:1143
Task::updateWindowPixmap
void updateWindowPixmap()
Definition: taskmanager.cpp:1312
Task::active
bool active
Definition: taskmanager.h:85
Task::deactivated
void deactivated()
Indicates that this task is no longer the active task.
TaskManager::updateWindowPixmap
void updateWindowPixmap(WId)
Definition: taskmanager.cpp:396
Task::demandsAttention
bool demandsAttention() const
Returns true if the task is not active but demands user's attention.
Task::Task
Task(WId win, QObject *parent, const char *name=0)
Definition: taskmanager.cpp:552
TaskManager::startupAdded
void startupAdded(Startup::StartupPtr)
Emitted when a new task is expected.
TaskManager::findTask
Task::TaskPtr findTask(WId w)
Returns the task for a given WId, or 0 if there is no such task.
Definition: taskmanager.cpp:197
Task::~Task
virtual ~Task()
Definition: taskmanager.cpp:597
Task::toCurrentDesktop
void toCurrentDesktop()
Moves the task's window to the current virtual desktop.
Definition: taskmanager.cpp:1097
Task::removeTransient
void removeTransient(WId w)
Definition: taskmanager.cpp:784
Task::isIconified
bool isIconified() const
Definition: taskmanager.cpp:694
TaskManager::windowChangedGeometry
void windowChangedGeometry(Task::TaskPtr)
Task::TaskPtr
KSharedPtr< Task > TaskPtr
Definition: taskmanager.h:97
Startup::Startup
Startup(const KStartupInfoId &id, const KStartupInfoData &data, QObject *parent, const char *name=0)
Definition: taskmanager.cpp:1330
Task
A dynamic interface to a task (main window).
Definition: taskmanager.h:73
Task::idMatch
static bool idMatch(const QString &, const QString &)
Returns true iff the windows with the specified ids should be grouped together in the task list...
Definition: taskmanager.cpp:906
Task::window
WId window() const
Definition: taskmanager.h:104
Task::lower
void lower()
Lower the task's window.
Definition: taskmanager.cpp:1052
TaskManager::startupRemoved
void startupRemoved(Startup::StartupPtr)
Emitted when a startup item should be removed.
Task::classClass
QString classClass()
Definition: taskmanager.cpp:802
Task::refreshIcon
void refreshIcon()
Definition: taskmanager.cpp:639
TaskDrag::decode
static Task::List decode(const QMimeData *e)
Decodes the tasks from the mime source and returns them if successful.
Definition: taskmanager.cpp:1377
TaskDrag::TaskDrag
TaskDrag(const Task::List &tasks, QWidget *source=0)
Constructs a task drag object for a task list.
Definition: taskmanager.cpp:1351
Task::isShaded
bool isShaded() const
Returns true if the task's window is shaded.
Definition: taskmanager.cpp:714
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal