• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

  • superkaramba
  • src
taskmanager.cpp
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 <tdeglobal.h>
25 #include <tdelocale.h>
26 #include <kdebug.h>
27 #include <tdeconfig.h>
28 #include <kiconloader.h>
29 #include <twinmodule.h>
30 #include <netwm.h>
31 #include <tqtimer.h>
32 #include <tqimage.h>
33 
34 #include <X11/X.h>
35 #include <X11/Xlib.h>
36 #include <X11/Xutil.h>
37 
38 #include "taskmanager.h"
39 #include "taskmanager.moc"
40 
41 template class TQPtrList<Task>;
42 
43 // Hack: create a global KWinModule without a parent. We
44 // can't make it a child of TaskManager because more than one
45 // TaskManager might be created. We can't make it a class
46 // variable without changing Task, which also uses it.
47 // So, we'll leak a little memory, but it's better than crashing.
48 // The real problem is that KWinModule should be a singleton.
49 KWinModule* twin_module = 0;
50 
51 TaskManager::TaskManager(TQObject *parent, const char *name)
52  : TQObject(parent, name), _active(0), _startup_info( NULL )
53 {
54 
55  twin_module = new KWinModule();
56 
57 // TDEGlobal::locale()->insertCatalogue("libtaskmanager");
58  connect(twin_module, TQ_SIGNAL(windowAdded(WId)), TQ_SLOT(windowAdded(WId)));
59  connect(twin_module, TQ_SIGNAL(windowRemoved(WId)), TQ_SLOT(windowRemoved(WId)));
60  connect(twin_module, TQ_SIGNAL(activeWindowChanged(WId)), TQ_SLOT(activeWindowChanged(WId)));
61  connect(twin_module, TQ_SIGNAL(currentDesktopChanged(int)), TQ_SLOT(currentDesktopChanged(int)));
62  connect(twin_module, TQ_SIGNAL(windowChanged(WId,unsigned int)), TQ_SLOT(windowChanged(WId,unsigned int)));
63 
64  // register existing windows
65  const TQValueList<WId> windows = twin_module->windows();
66  TQValueList<WId>::ConstIterator end( windows.end() );
67  for (TQValueList<WId>::ConstIterator it = windows.begin(); it != end; ++it )
68  windowAdded(*it);
69 
70  // set active window
71  WId win = twin_module->activeWindow();
72  activeWindowChanged(win);
73 
74  configure_startup();
75 }
76 
77 TaskManager::~TaskManager()
78 {
79 }
80 
81 void TaskManager::configure_startup()
82 {
83  TDEConfig c("tdelaunchrc", true);
84  c.setGroup("FeedbackStyle");
85  if (!c.readBoolEntry("TaskbarButton", true))
86  return;
87  _startup_info = new TDEStartupInfo( true, this );
88  connect( _startup_info,
89  TQ_SIGNAL( gotNewStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )),
90  TQ_SLOT( gotNewStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )));
91  connect( _startup_info,
92  TQ_SIGNAL( gotStartupChange( const TDEStartupInfoId&, const TDEStartupInfoData& )),
93  TQ_SLOT( gotStartupChange( const TDEStartupInfoId&, const TDEStartupInfoData& )));
94  connect( _startup_info,
95  TQ_SIGNAL( gotRemoveStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )),
96  TQ_SLOT( gotRemoveStartup( const TDEStartupInfoId& )));
97  c.setGroup( "TaskbarButtonSettings" );
98  _startup_info->setTimeout( c.readUnsignedNumEntry( "Timeout", 30 ));
99 }
100 
101 Task* TaskManager::findTask(WId w)
102 {
103  for (Task* t = _tasks.first(); t != 0; t = _tasks.next())
104  if (t->window() == w || t->hasTransient(w))
105  return t;
106  return 0;
107 }
108 
109 #ifdef KDE_3_3
110 #define NET_ALL_TYPES_MASK (NET::AllTypesMask)
111 #else
112 #define NET_ALL_TYPES_MASK (-1LU)
113 #endif
114 
115 void TaskManager::windowAdded(WId w )
116 {
117  NETWinInfo info(tqt_xdisplay(), w, tqt_xrootwin(),
118  NET::WMWindowType | NET::WMPid | NET::WMState );
119  #ifdef KDE_3_2
120  NET::WindowType windowType = info.windowType(NET_ALL_TYPES_MASK);
121  #else
122  NET::WindowType windowType = info.windowType();
123  #endif
124  // ignore NET::Tool and other special window types
125  if (windowType != NET::Normal && windowType != NET::Override
126  && windowType != NET::Unknown && windowType != NET::Dialog)
127  return;
128  // ignore windows that want to be ignored by the taskbar
129  if ((info.state() & NET::SkipTaskbar) != 0)
130  {
131  _skiptaskbar_windows.push_front( w ); // remember them though
132  return;
133  }
134 
135  Window transient_for_tmp;
136  if (XGetTransientForHint(tqt_xdisplay(), (Window) w, &transient_for_tmp))
137  {
138  WId transient_for = (WId) transient_for_tmp;
139 
140  // check if it's transient for a skiptaskbar window
141  if (_skiptaskbar_windows.contains(transient_for))
142  return;
143 
144  // lets see if this is a transient for an existing task
145  if (transient_for != tqt_xrootwin() && transient_for != 0 )
146  {
147  Task* t = findTask(transient_for);
148  if (t)
149  {
150  if (t->window() != w)
151  {
152  t->addTransient(w);
153  // kdDebug() << "TM: Transient " << w << " added for Task: " << t->window() << endl;
154  }
155  return;
156  }
157  }
158  }
159  Task* t = new Task(w, this);
160  _tasks.append(t);
161 
162  // kdDebug() << "TM: Task added for WId: " << w << endl;
163  emit taskAdded(t);
164 }
165 
166 void TaskManager::windowRemoved(WId w )
167 {
168  _skiptaskbar_windows.remove( w );
169  // find task
170  Task* t = findTask(w);
171  if (!t) return;
172 
173  if (t->window() == w) {
174  _tasks.removeRef(t);
175 
176  emit taskRemoved(t);
177 
178  if(t == _active) _active = 0;
179  delete t;
180  //kdDebug() << "TM: Task for WId " << w << " removed." << endl;
181  }
182  else {
183  t->removeTransient( w );
184  //kdDebug() << "TM: Transient " << w << " for Task " << t->window() << " removed." << endl;
185  }
186 }
187 
188 void TaskManager::windowChanged(WId w, unsigned int dirty)
189 {
190  if( dirty & NET::WMState ) {
191  NETWinInfo info ( tqt_xdisplay(), w, tqt_xrootwin(), NET::WMState );
192  if ( (info.state() & NET::SkipTaskbar) != 0 ) {
193  windowRemoved( w );
194  _skiptaskbar_windows.push_front( w );
195  return;
196  }
197  else {
198  _skiptaskbar_windows.remove( w );
199  if( !findTask( w ))
200  windowAdded( w ); // skipTaskBar state was removed, so add this window
201  }
202  }
203 
204  // check if any state we are interested in is marked dirty
205  if(!(dirty & (NET::WMVisibleName|NET::WMName|NET::WMState|NET::WMIcon|NET::XAWMState|NET::WMDesktop)) )
206  return;
207 
208  // find task
209  Task* t = findTask( w );
210  if (!t) return;
211 
212  //kdDebug() << "TaskManager::windowChanged " << w << " " << dirty << endl;
213 
214 
215  // refresh icon pixmap if necessary
216  if (dirty & NET::WMIcon)
217  t->refresh(true);
218  else
219  t->refresh();
220 
221  if(dirty & (NET::WMDesktop|NET::WMState|NET::XAWMState))
222  emit windowChanged(w); // moved to different desktop or is on all or change in iconification/withdrawnnes
223 }
224 
225 void TaskManager::activeWindowChanged(WId w )
226 {
227  //kdDebug() << "TaskManager::activeWindowChanged" << endl;
228 
229  Task* t = findTask( w );
230  if (!t) {
231  if (_active) {
232  _active->setActive(false);
233  _active = 0;
234 
235  // there is no active window at the moment
236  emit activeTaskChanged(0);
237  }
238  }
239  else {
240  if (_active)
241  _active->setActive(false);
242 
243  _active = t;
244  _active->setActive(true);
245 
246  emit activeTaskChanged(_active);
247  }
248 }
249 
250 void TaskManager::currentDesktopChanged(int desktop)
251 {
252  emit desktopChanged(desktop);
253 }
254 
255 void TaskManager::gotNewStartup( const TDEStartupInfoId& id, const TDEStartupInfoData& data )
256 {
257  Startup* s = new Startup( id, data, this );
258  _startups.append(s);
259 
260  emit startupAdded(s);
261 }
262 
263 void TaskManager::gotStartupChange( const TDEStartupInfoId& id, const TDEStartupInfoData& data )
264 {
265  for( Startup* s = _startups.first(); s != 0; s = _startups.next()) {
266  if ( s->id() == id ) {
267  s->update( data );
268  return;
269  }
270  }
271 }
272 
273 void TaskManager::gotRemoveStartup( const TDEStartupInfoId& id )
274 {
275  killStartup( id );
276 }
277 
278 void TaskManager::killStartup( const TDEStartupInfoId& id )
279 {
280  Startup* s = 0;
281  for(s = _startups.first(); s != 0; s = _startups.next()) {
282  if (s->id() == id)
283  break;
284  }
285  if (s == 0) return;
286 
287  _startups.removeRef(s);
288  emit startupRemoved(s);
289  delete s;
290 }
291 
292 void TaskManager::killStartup(Startup* s)
293 {
294  if (s == 0) return;
295 
296  _startups.removeRef(s);
297  emit startupRemoved(s);
298  delete s;
299 }
300 
301 TQString TaskManager::desktopName(int desk) const
302 {
303  return twin_module->desktopName(desk);
304 }
305 
306 int TaskManager::numberOfDesktops() const
307 {
308  return twin_module->numberOfDesktops();
309 }
310 
311 bool TaskManager::isOnTop(const Task* task)
312 {
313  if(!task) return false;
314 
315  for (TQValueList<WId>::ConstIterator it = twin_module->stackingOrder().fromLast();
316  it != twin_module->stackingOrder().end(); --it ) {
317  for (Task* t = _tasks.first(); t != 0; t = _tasks.next() ) {
318  if ( (*it) == t->window() ) {
319  if ( t == task )
320  return true;
321  if ( !t->isIconified() && (t->isAlwaysOnTop() == task->isAlwaysOnTop()) )
322  return false;
323  break;
324  }
325  }
326  }
327  return false;
328 }
329 
330 
331 Task::Task(WId win, TaskManager * parent, const char *name) :
332  TQObject(parent, name),
333  _active(false), _win(win),
334  _lastWidth(0), _lastHeight(0), _lastResize(false), _lastIcon(),
335  _thumbSize(0.2), _thumb(), _grab()
336 {
337 #ifdef KDE_3_2
338  _info = KWin::windowInfo(_win, 0, 0);
339 #else
340  _info = KWin::info(_win);
341 #endif
342  // try to load icon via net_wm
343  _pixmap = KWin::icon(_win, 16, 16, true);
344 
345  // try to guess the icon from the classhint
346  if(_pixmap.isNull())
347  TDEGlobal::instance()->iconLoader()->loadIcon(className().lower(),
348  TDEIcon::Small,TDEIcon::Small,
349  TDEIcon::DefaultState, 0, true);
350 
351  // load xapp icon
352  if (_pixmap.isNull())
353  _pixmap = SmallIcon("kcmx");
354 }
355 
356 Task::~Task()
357 {
358 }
359 
360 void Task::refresh(bool icon)
361 {
362 #ifdef KDE_3_2
363  _info = KWin::windowInfo(_win, 0, 0);
364 #else
365  _info = KWin::info(_win);
366 #endif
367  if (icon)
368  {
369  // try to load icon via net_wm
370  _pixmap = KWin::icon(_win, 16, 16, true);
371 
372  // try to guess the icon from the classhint
373  if(_pixmap.isNull())
374  {
375  TDEGlobal::instance()->iconLoader()->loadIcon(className().lower(),
376  TDEIcon::Small, TDEIcon::Small, TDEIcon::DefaultState, 0, true);
377  }
378 
379  // load xapp icon
380  if (_pixmap.isNull())
381  _pixmap = SmallIcon("kcmx");
382 
383  _lastIcon.resize(0,0);
384  emit iconChanged();
385  }
386  emit changed();
387 }
388 
389 void Task::setActive(bool a)
390 {
391  _active = a;
392  emit changed();
393  if ( a )
394  emit activated();
395  else
396  emit deactivated();
397 }
398 
399 bool Task::isMaximized() const
400 {
401 #ifdef KDE_3_2
402  return(_info.state() & NET::Max);
403 #else
404  return(_info.state & NET::Max);
405 #endif
406 }
407 
408 bool Task::isIconified() const
409 {
410 #ifdef KDE_3_2
411  return (_info.mappingState() == NET::Iconic);
412 #else
413  return (_info.mappingState == NET::Iconic);
414 #endif
415 }
416 
417 bool Task::isAlwaysOnTop() const
418 {
419 #ifdef KDE_3_2
420  return (_info.state() & NET::StaysOnTop);
421 #else
422  return (_info.state & NET::StaysOnTop);
423 #endif
424 }
425 
426 bool Task::isShaded() const
427 {
428 #ifdef KDE_3_2
429  return (_info.state() & NET::Shaded);
430 #else
431  return (_info.state & NET::Shaded);
432 #endif
433 }
434 
435 bool Task::isOnCurrentDesktop() const
436 {
437 #ifdef KDE_3_2
438  return (_info.onAllDesktops() || _info.desktop() == twin_module->currentDesktop());
439 #else
440  return (_info.onAllDesktops || _info.desktop == twin_module->currentDesktop());
441 #endif
442 }
443 
444 bool Task::isOnAllDesktops() const
445 {
446 #ifdef KDE_3_2
447  return _info.onAllDesktops();
448 #else
449  return _info.onAllDesktops;
450 #endif
451 }
452 
453 bool Task::isActive() const
454 {
455  return _active;
456 }
457 
458 bool Task::isOnTop() const
459 {
460  return taskManager()->isOnTop( this );
461 }
462 
463 bool Task::isModified() const
464 {
465  static TQString modStr = TQString::fromUtf8("[") + i18n("modified") + TQString::fromUtf8("]");
466 #ifdef KDE_3_2
467  int modStrPos = _info.visibleName().find(modStr);
468 #else
469  int modStrPos = _info.visibleName.find(modStr);
470 #endif
471 
472  return ( modStrPos != -1 );
473 }
474 
475 TQString Task::iconName() const
476 {
477  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMIconName);
478  return TQString::fromUtf8(ni.iconName());
479 }
480 TQString Task::visibleIconName() const
481 {
482  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMVisibleIconName);
483  return TQString::fromUtf8(ni.visibleIconName());
484 }
485 
486 TQString Task::className()
487 {
488  XClassHint hint;
489  if(XGetClassHint(tqt_xdisplay(), _win, &hint)) {
490  TQString nh( hint.res_name );
491  XFree( hint.res_name );
492  XFree( hint.res_class );
493  return nh;
494  }
495  return TQString();
496 }
497 
498 TQString Task::classClass()
499 {
500  XClassHint hint;
501  if(XGetClassHint(tqt_xdisplay(), _win, &hint)) {
502  TQString ch( hint.res_class );
503  XFree( hint.res_name );
504  XFree( hint.res_class );
505  return ch;
506  }
507  return TQString();
508 }
509 
510 TQPixmap Task::icon( int width, int height, bool allowResize )
511 {
512  if ( (width == _lastWidth)
513  && (height == _lastHeight)
514  && (allowResize == _lastResize )
515  && (!_lastIcon.isNull()) )
516  return _lastIcon;
517 
518  TQPixmap newIcon = KWin::icon( _win, width, height, allowResize );
519  if ( !newIcon.isNull() ) {
520  _lastIcon = newIcon;
521  _lastWidth = width;
522  _lastHeight = height;
523  _lastResize = allowResize;
524  }
525 
526  return newIcon;
527 }
528 
529 TQPixmap Task::bestIcon( int size, bool &isStaticIcon )
530 {
531  TQPixmap pixmap;
532  isStaticIcon = false;
533 
534  switch( size ) {
535  case TDEIcon::SizeSmall:
536  {
537  pixmap = icon( 16, 16, true );
538 
539  // Icon of last resort
540  if( pixmap.isNull() ) {
541  pixmap = TDEGlobal::iconLoader()->loadIcon( "go",
542  TDEIcon::NoGroup,
543  TDEIcon::SizeSmall );
544  isStaticIcon = true;
545  }
546  }
547  break;
548  case TDEIcon::SizeMedium:
549  {
550  //
551  // Try 34x34 first for KDE 2.1 icons with shadows, if we don't
552  // get one then try 32x32.
553  //
554  pixmap = icon( 34, 34, false );
555 
556  if ( ( pixmap.width() != 34 ) || ( pixmap.height() != 34 ) ) {
557  if ( ( pixmap.width() != 32 ) || ( pixmap.height() != 32 ) ) {
558  pixmap = icon( 32, 32, true );
559  }
560  }
561 
562  // Icon of last resort
563  if( pixmap.isNull() ) {
564  pixmap = TDEGlobal::iconLoader()->loadIcon( "go",
565  TDEIcon::NoGroup,
566  TDEIcon::SizeMedium );
567  isStaticIcon = true;
568  }
569  }
570  break;
571  case TDEIcon::SizeLarge:
572  {
573  // If there's a 48x48 icon in the hints then use it
574  pixmap = icon( size, size, false );
575 
576  // If not, try to get one from the classname
577  if ( pixmap.isNull() || pixmap.width() != size || pixmap.height() != size ) {
578  pixmap = TDEGlobal::iconLoader()->loadIcon( className(),
579  TDEIcon::NoGroup,
580  size,
581  TDEIcon::DefaultState,
582  0L,
583  true );
584  isStaticIcon = true;
585  }
586 
587  // If we still don't have an icon then scale the one in the hints
588  if ( pixmap.isNull() || ( pixmap.width() != size ) || ( pixmap.height() != size ) ) {
589  pixmap = icon( size, size, true );
590  isStaticIcon = false;
591  }
592 
593  // Icon of last resort
594  if( pixmap.isNull() ) {
595  pixmap = TDEGlobal::iconLoader()->loadIcon( "go",
596  TDEIcon::NoGroup,
597  size );
598  isStaticIcon = true;
599  }
600  }
601  }
602 
603  return pixmap;
604 }
605 
606 bool Task::idMatch( const TQString& id1, const TQString& id2 )
607 {
608  if ( id1.isEmpty() || id2.isEmpty() )
609  return false;
610 
611  if ( id1.contains( id2 ) > 0 )
612  return true;
613 
614  if ( id2.contains( id1 ) > 0 )
615  return true;
616 
617  return false;
618 }
619 
620 
621 void Task::maximize()
622 {
623  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMState);
624  ni.setState( NET::Max, NET::Max );
625 
626 #ifdef KDE_3_2
627  if (_info.mappingState() == NET::Iconic)
628 #else
629  if (_info.mappingState == NET::Iconic)
630 #endif
631  activate();
632 }
633 
634 void Task::restore()
635 {
636  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMState);
637  ni.setState( 0, NET::Max );
638 #ifdef KDE_3_2
639  if (_info.mappingState() == NET::Iconic)
640 #else
641  if (_info.mappingState == NET::Iconic)
642 #endif
643  activate();
644 }
645 
646 void Task::iconify()
647 {
648  XIconifyWindow( tqt_xdisplay(), _win, tqt_xscreen() );
649 }
650 
651 void Task::close()
652 {
653  NETRootInfo ri( tqt_xdisplay(), NET::CloseWindow );
654  ri.closeWindowRequest( _win );
655 }
656 
657 void Task::raise()
658 {
659 // kdDebug(1210) << "Task::raise(): " << name() << endl;
660  XRaiseWindow( tqt_xdisplay(), _win );
661 }
662 
663 void Task::lower()
664 {
665 // kdDebug(1210) << "Task::lower(): " << name() << endl;
666  XLowerWindow( tqt_xdisplay(), _win );
667 }
668 
669 void Task::activate()
670 {
671 // kdDebug(1210) << "Task::activate():" << name() << endl;
672  NETRootInfo ri( tqt_xdisplay(), 0 );
673  ri.setActiveWindow( _win );
674 }
675 
676 void Task::activateRaiseOrIconify()
677 {
678  if ( !isActive() || isIconified() ) {
679  activate();
680  } else if ( !isOnTop() ) {
681  raise();
682  } else {
683  iconify();
684  }
685 }
686 
687 void Task::toDesktop(int desk)
688 {
689  NETWinInfo ni(tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMDesktop);
690  if (desk == 0)
691  {
692 #ifdef KDE_3_2
693  if (_info.onAllDesktops())
694  {
695  ni.setDesktop(twin_module->currentDesktop());
696  KWin::forceActiveWindow(_win);
697  }
698 #else
699  if (_info.onAllDesktops)
700  {
701  ni.setDesktop(twin_module->currentDesktop());
702  KWin::setActiveWindow(_win);
703  }
704 #endif
705  else
706  ni.setDesktop(NETWinInfo::OnAllDesktops);
707  return;
708  }
709  ni.setDesktop(desk);
710  if (desk == twin_module->currentDesktop())
711 #ifdef KDE_3_2
712  KWin::forceActiveWindow(_win);
713 #else
714  KWin::setActiveWindow(_win);
715 #endif
716 }
717 
718 void Task::toCurrentDesktop()
719 {
720  toDesktop(twin_module->currentDesktop());
721 }
722 
723 void Task::setAlwaysOnTop(bool stay)
724 {
725  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMState);
726  if(stay)
727  ni.setState( NET::StaysOnTop, NET::StaysOnTop );
728  else
729  ni.setState( 0, NET::StaysOnTop );
730 }
731 
732 void Task::toggleAlwaysOnTop()
733 {
734  setAlwaysOnTop( !isAlwaysOnTop() );
735 }
736 
737 void Task::setShaded(bool shade)
738 {
739  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMState);
740  if(shade)
741  ni.setState( NET::Shaded, NET::Shaded );
742  else
743  ni.setState( 0, NET::Shaded );
744 }
745 
746 void Task::toggleShaded()
747 {
748  setShaded( !isShaded() );
749 }
750 
751 void Task::publishIconGeometry(TQRect rect)
752 {
753  NETWinInfo ni( tqt_xdisplay(), _win, tqt_xrootwin(), NET::WMIconGeometry);
754  NETRect r;
755  r.pos.x = rect.x();
756  r.pos.y = rect.y();
757  r.size.width = rect.width();
758  r.size.height = rect.height();
759  ni.setIconGeometry(r);
760 }
761 
762 void Task::updateThumbnail()
763 {
764  if ( !isOnCurrentDesktop() )
765  return;
766  if ( !isActive() )
767  return;
768  if ( !_grab.isNull() ) // We're already processing one...
769  return;
770 
771  //
772  // We do this as a two stage process to remove the delay caused
773  // by the thumbnail generation. This makes things much smoother
774  // on slower machines.
775  //
776  TQWidget *rootWin = tqApp->desktop();
777  TQRect geom = _info.geometry();
778  _grab = TQPixmap::grabWindow( rootWin->winId(),
779  geom.x(), geom.y(),
780  geom.width(), geom.height() );
781 
782  if ( !_grab.isNull() )
783  TQTimer::singleShot( 200, this, TQ_SLOT( generateThumbnail() ) );
784 }
785 
786 void Task::generateThumbnail()
787 {
788  if ( _grab.isNull() )
789  return;
790 
791  TQImage img = _grab.convertToImage();
792 
793  double width = img.width();
794  double height = img.height();
795  width = width * _thumbSize;
796  height = height * _thumbSize;
797 
798  img = img.smoothScale( (int) width, (int) height );
799  _thumb = img;
800  _grab.resize( 0, 0 ); // Makes grab a null image.
801 
802  emit thumbnailChanged();
803 }
804 
805 Startup::Startup( const TDEStartupInfoId& id, const TDEStartupInfoData& data,
806  TQObject * parent, const char *name)
807  : TQObject(parent, name), _id( id ), _data( data )
808 {
809 }
810 
811 Startup::~Startup()
812 {
813 
814 }
815 
816 void Startup::update( const TDEStartupInfoData& data )
817 {
818  _data.update( data );
819  emit changed();
820 }
821 
822 int TaskManager::currentDesktop() const
823 {
824  return twin_module->currentDesktop();
825 }
Task::bestIcon
TQPixmap bestIcon(int size, bool &isStaticIcon)
Returns the best icon for any of the TDEIcon::StdSizes.
Definition: taskmanager.cpp:529
Task::setAlwaysOnTop
void setAlwaysOnTop(bool)
If true, the task&#39;s window will remain at the top of the stacking order.
Definition: taskmanager.cpp:723
Task::activateRaiseOrIconify
void activateRaiseOrIconify()
Perform the action that is most appropriate for this task.
Definition: taskmanager.cpp:676
TaskManager::isOnTop
bool isOnTop(const Task *)
Returns true if the specified task is on top.
Definition: taskmanager.cpp:311
TaskManager::currentDesktop
int currentDesktop() const
Returns the number of the current desktop.
Definition: taskmanager.cpp:822
Task::maximize
void maximize()
Maximise the main window of this task.
Definition: taskmanager.cpp:621
Task::toDesktop
void toDesktop(int)
Moves the task&#39;s window to the specified virtual desktop.
Definition: taskmanager.cpp:687
Startup
Represents a task which is in the process of starting.
Definition: taskmanager.h:376
Task::isOnCurrentDesktop
bool isOnCurrentDesktop() const
Returns true if the task&#39;s window is on the current virtual desktop.
Definition: taskmanager.cpp:435
Task::isOnAllDesktops
bool isOnAllDesktops() const
Returns true if the task&#39;s window is on all virtual desktops.
Definition: taskmanager.cpp:444
Task::icon
TQPixmap icon(int width, int height, bool allowResize=false)
Tries to find an icon for the task with the specified size.
Definition: taskmanager.cpp:510
TaskManager
A generic API for task managers.
Definition: taskmanager.h:432
Task::isIconified
bool isIconified() const
Returns true if the task&#39;s window is iconified.
Definition: taskmanager.cpp:408
Task::isAlwaysOnTop
bool isAlwaysOnTop() const
Returns true if the task&#39;s window will remain at the top of the stacking order.
Definition: taskmanager.cpp:417
Task::isOnTop
bool isOnTop() const
Returns true if the task&#39;s window is the topmost non-iconified, non-always-on-top window...
Definition: taskmanager.cpp:458
TaskManager::findTask
Task * findTask(WId w)
Returns the task for a given WId, or 0 if there is no such task.
Definition: taskmanager.cpp:101
Task::setShaded
void setShaded(bool)
If true then the task&#39;s window will be shaded.
Definition: taskmanager.cpp:737
Task::publishIconGeometry
void publishIconGeometry(TQRect)
This method informs the window manager of the location at which this task will be displayed when icon...
Definition: taskmanager.cpp:751
Task::isShaded
bool isShaded() const
Returns true if the task&#39;s window is shaded.
Definition: taskmanager.cpp:426
TaskManager::numberOfDesktops
int numberOfDesktops() const
Returns the number of virtual desktops.
Definition: taskmanager.cpp:306
Task::idMatch
static bool idMatch(const TQString &, const TQString &)
Returns true iff the windows with the specified ids should be grouped together in the task list...
Definition: taskmanager.cpp:606
Task::close
void close()
Activate the task&#39;s window.
Definition: taskmanager.cpp:651
Task::isModified
bool isModified() const
Returns true if the document the task is editing has been modified.
Definition: taskmanager.cpp:463
TaskManager::windowChanged
void windowChanged(WId)
Emitted when a window changes desktop.
Task::raise
void raise()
Raise the task&#39;s window.
Definition: taskmanager.cpp:657
Task::activate
void activate()
Activate the task&#39;s window.
Definition: taskmanager.cpp:669
Task::iconify
void iconify()
Iconify the task.
Definition: taskmanager.cpp:646
Task::updateThumbnail
void updateThumbnail()
Tells the task to generate a new thumbnail.
Definition: taskmanager.cpp:762
Task::restore
void restore()
Restore the main window of the task (if it was iconified).
Definition: taskmanager.cpp:634
TaskManager::desktopName
TQString desktopName(int n) const
Returns the name of the nth desktop.
Definition: taskmanager.cpp:301
Task::isActive
bool isActive() const
Returns true if the task&#39;s window is the active window.
Definition: taskmanager.cpp:453
Task::toCurrentDesktop
void toCurrentDesktop()
Moves the task&#39;s window to the current virtual desktop.
Definition: taskmanager.cpp:718
Task
A dynamic interface to a task (main window).
Definition: taskmanager.h:49
Task::isMaximized
bool isMaximized() const
Returns true if the task&#39;s window is maximized.
Definition: taskmanager.cpp:399
Task::lower
void lower()
Lower the task&#39;s window.
Definition: taskmanager.cpp:663

superkaramba

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

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.8.13
This website is maintained by Timothy Pearson.