• 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.h
Go to the documentation of this file.
1 /*****************************************************************
2 
3 Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
4 Copyright (c) 2001 Richard Moore <rich@kde.org>
5 
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:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
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.
22 
23 ******************************************************************/
24 
25 #ifndef __taskmanager_h__
26 #define __taskmanager_h__
27 
28 #include <sys/types.h>
29 
30 #include <netwm.h>
31 
32 #include <QObject>
33 #include <QPixmap>
34 #include <QPoint>
35 #include <QMimeData>
36 #include <QMap>
37 #include <QDrag>
38 #include <QRect>
39 #include <QVector>
40 
41 #include <KSharedPtr>
42 #include <KStartupInfo>
43 #include <KWindowSystem>
44 
45 #if defined(HAVE_XCOMPOSITE) && \
46  defined(HAVE_XRENDER) && \
47  defined(HAVE_XFIXES)
48 #include <X11/Xlib.h>
49 #include <X11/extensions/Xcomposite.h>
50 #include <X11/extensions/Xfixes.h>
51 #include <X11/extensions/Xrender.h>
52 #include <fixx11h.h>
53 #if XCOMPOSITE_VERSION >= 00200 && \
54  XFIXES_VERSION >= 20000 && \
55  (RENDER_MAJOR > 0 || RENDER_MINOR >= 6)
56 #define THUMBNAILING_POSSIBLE
57 #endif
58 #endif
59 
60 #include "superkaramba_export.h"
61 
62 class KWindowSystem;
63 class TaskManager;
64 
65 typedef QList<WId> WindowList;
66 
73 class SUPERKARAMBA_EXPORT Task: public QObject, public KShared
74 {
75  Q_OBJECT
76  Q_PROPERTY(QString visibleName READ visibleName)
77  Q_PROPERTY(QString name READ name)
78  Q_PROPERTY(QString visibleNameWithState READ visibleNameWithState)
79  Q_PROPERTY(QPixmap pixmap READ pixmap)
80  Q_PROPERTY(bool maximized READ isMaximized)
81  Q_PROPERTY(bool minimized READ isMinimized)
82  // KDE4 deprecated
83  Q_PROPERTY(bool iconified READ isIconified)
84  Q_PROPERTY(bool shaded READ isShaded WRITE setShaded)
85  Q_PROPERTY(bool active READ isActive)
86  Q_PROPERTY(bool onCurrentDesktop READ isOnCurrentDesktop)
87  Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops)
88  Q_PROPERTY(bool alwaysOnTop READ isAlwaysOnTop WRITE setAlwaysOnTop)
89  Q_PROPERTY(bool modified READ isModified)
90  Q_PROPERTY(bool demandsAttention READ demandsAttention)
91  Q_PROPERTY(int desktop READ desktop)
92  Q_PROPERTY(double thumbnailSize READ thumbnailSize WRITE setThumbnailSize)
93  Q_PROPERTY(bool hasThumbnail READ hasThumbnail)
94  Q_PROPERTY(QPixmap thumbnail READ thumbnail)
95 
96 public:
97  typedef KSharedPtr<Task> TaskPtr;
98  typedef QVector<Task::TaskPtr> List;
99  typedef QMap<WId, Task::TaskPtr> Dict;
100 
101  Task(WId win, QObject *parent, const char *name = 0);
102  virtual ~Task();
103 
104  WId window() const
105  {
106  return _win;
107  }
108  KWindowInfo info() const
109  {
110  return _info;
111  }
112 
113  QString visibleName() const
114  {
115  return _info.visibleName();
116  }
117  QString visibleNameWithState() const
118  {
119  return _info.visibleNameWithState();
120  }
121  QString name() const
122  {
123  return _info.name();
124  }
125  QString className();
126  QString classClass();
127 
132  WindowList transients() const
133  {
134  return _transients;
135  }
136 
142  QPixmap pixmap() const
143  {
144  return _pixmap;
145  }
146 
160  QPixmap bestIcon(int size, bool &isStaticIcon);
161 
171  QPixmap icon(int width, int height, bool allowResize = false);
172 
177  static bool idMatch(const QString &, const QString &);
178 
179  // state
180 
184  bool isMaximized() const;
185 
189  bool isMinimized() const;
190 
195  bool isIconified() const;
196 
200  bool isShaded() const;
201 
205  bool isActive() const;
206 
211  bool isOnTop() const;
212 
216  bool isOnCurrentDesktop() const;
217 
221  bool isOnAllDesktops() const;
222 
227  bool isAlwaysOnTop() const;
228 
233  bool isKeptBelowOthers() const;
234 
238  bool isFullScreen() const;
239 
246  bool isModified() const ;
247 
251  int desktop() const
252  {
253  return _info.desktop();
254  }
255 
259  bool demandsAttention() const;
260 
261 
265  bool isOnScreen(int screen) const;
266 
270  bool showInTaskbar() const
271  {
272  return _info.state() ^ NET::SkipTaskbar;
273  }
274 
278  bool showInPager() const
279  {
280  return _info.state() ^ NET::SkipPager;
281  }
282 
286  QRect geometry() const
287  {
288  return _info.geometry();
289  }
290 
291  // internal
292 
293  //* @internal
294  void refresh(unsigned int dirty);
295  //* @internal
296  void refreshIcon();
297  //* @internal
298  void addTransient(WId w, const NETWinInfo& info);
299  //* @internal
300  void removeTransient(WId w);
301  //* @internal
302  bool hasTransient(WId w) const
303  {
304  return _transients.indexOf(w) != -1;
305  }
306  //* @internal
307  void updateDemandsAttentionState(WId w);
308  //* @internal
309  void setActive(bool a);
310 
311  // For thumbnails
312 
316  double thumbnailSize() const
317  {
318  return _thumbSize;
319  }
320 
326  void setThumbnailSize(double size)
327  {
328  _thumbSize = size;
329  }
330 
335  bool hasThumbnail() const
336  {
337  return !_thumb.isNull();
338  }
339 
344  const QPixmap &thumbnail() const
345  {
346  return _thumb;
347  }
348 
349  QPixmap thumbnail(int maxDimension);
350 
351  void updateWindowPixmap();
352 
353 public Q_SLOTS:
354  // actions
355 
359  void setMaximized(bool);
360  void toggleMaximized();
361 
365  void restore();
366 
370  void move();
371 
375  void resize();
376 
380  void setIconified(bool);
381  void toggleIconified();
382 
386  void close();
387 
391  void raise();
392 
396  void lower();
397 
401  void activate();
402 
408  void activateRaiseOrIconify();
409 
413  void setAlwaysOnTop(bool);
414  void toggleAlwaysOnTop();
415 
419  void setKeptBelowOthers(bool);
420  void toggleKeptBelowOthers();
421 
425  void setFullScreen(bool);
426  void toggleFullScreen();
427 
432  void setShaded(bool);
433  void toggleShaded();
434 
438  void toDesktop(int);
439 
443  void toCurrentDesktop();
444 
450  void publishIconGeometry(QRect);
451 
456  void updateThumbnail();
457 
458 Q_SIGNALS:
462  void changed();
463 
467  void iconChanged();
468 
472  void activated();
473 
477  void deactivated();
478 
482  void thumbnailChanged();
483 
484 protected Q_SLOTS:
485  //* @internal
486  void generateThumbnail();
487 
488 protected:
489  void findWindowFrameId();
490 
491 private:
492  bool _active;
493  WId _win;
494  WId m_frameId;
495  QPixmap _pixmap;
496  KWindowInfo _info;
497  WindowList _transients;
498  WindowList _transients_demanding_attention;
499 
500  int _lastWidth;
501  int _lastHeight;
502  bool _lastResize;
503  QPixmap _lastIcon;
504 
505  double _thumbSize;
506  QPixmap _thumb;
507  QPixmap _grab;
508  QRect m_iconGeometry;
509 #ifdef THUMBNAILING_POSSIBLE
510  Pixmap m_windowPixmap;
511 #endif // THUMBNAILING_POSSIBLE
512 };
513 
514 
520 class SUPERKARAMBA_EXPORT TaskDrag : public QDrag
521 {
522 public:
526  explicit TaskDrag(const Task::List& tasks, QWidget* source = 0);
527  ~TaskDrag();
528 
532  static bool canDecode(const QMimeData* e);
533 
538  static Task::List decode(const QMimeData* e);
539 };
540 
541 
547 class SUPERKARAMBA_EXPORT Startup: public QObject, public KShared
548 {
549  Q_OBJECT
550  Q_PROPERTY(QString text READ text)
551  Q_PROPERTY(QString bin READ bin)
552  Q_PROPERTY(QString icon READ icon)
553 
554 public:
555  typedef KSharedPtr<Startup> StartupPtr;
556  typedef QVector<Startup::StartupPtr> List;
557 
558  Startup(const KStartupInfoId& id, const KStartupInfoData& data, QObject * parent,
559  const char *name = 0);
560  virtual ~Startup();
561 
565  QString text() const
566  {
567  return _data.findName();
568  }
569 
573  QString bin() const
574  {
575  return _data.bin();
576  }
577 
581  QString icon() const
582  {
583  return _data.findIcon();
584  }
585  void update(const KStartupInfoData& data);
586  const KStartupInfoId& id() const
587  {
588  return _id;
589  }
590 
591 Q_SIGNALS:
595  void changed();
596 
597 private:
598  KStartupInfoId _id;
599  KStartupInfoData _data;
600  class StartupPrivate *d;
601 };
602 
603 
613 class SUPERKARAMBA_EXPORT TaskManager : public QObject
614 {
615  Q_OBJECT
616  Q_PROPERTY(int currentDesktop READ currentDesktop)
617  Q_PROPERTY(int numberOfDesktops READ numberOfDesktops)
618 
619 public:
620  static TaskManager* self();
621  ~TaskManager();
622 
626  Task::TaskPtr findTask(WId w);
627 
631  Task::TaskPtr findTask(int desktop, const QPoint& p);
632 
636  Task::Dict tasks() const
637  {
638  return m_tasksByWId;
639  }
640 
644  Startup::List startups() const
645  {
646  return _startups;
647  }
648 
652  QString desktopName(int n) const;
653 
657  int numberOfDesktops() const;
658 
662  int currentDesktop() const;
663 
667  bool isOnTop(const Task*);
668 
674  void trackGeometry()
675  {
676  m_trackGeometry = true;
677  }
678 
682  static bool isOnScreen(int screen, const WId wid);
683 
684  KWindowSystem* winModule() const
685  {
686  return m_winModule;
687  }
688 
689  void setXCompositeEnabled(bool state);
690  static bool xCompositeEnabled()
691  {
692  return m_xCompositeEnabled != 0;
693  }
694 
695 Q_SIGNALS:
699  void activeTaskChanged(Task::TaskPtr);
700 
704  void taskAdded(Task::TaskPtr);
705 
709  void taskRemoved(Task::TaskPtr);
710 
714  void startupAdded(Startup::StartupPtr);
715 
721  void startupRemoved(Startup::StartupPtr);
722 
726  void desktopChanged(int desktop);
727 
731  void windowChanged(Task::TaskPtr);
732  void windowChangedGeometry(Task::TaskPtr);
733 
734 protected Q_SLOTS:
735  //* @internal
736  void windowAdded(WId);
737  //* @internal
738  void windowRemoved(WId);
739  //* @internal
740  void windowChanged(WId, unsigned int);
741 
742  //* @internal
743  void activeWindowChanged(WId);
744  //* @internal
745  void currentDesktopChanged(int);
746  //* @internal
747  void killStartup(const KStartupInfoId&);
748  //* @internal
749  void killStartup(Startup::StartupPtr);
750 
751  //* @internal
752  void gotNewStartup(const KStartupInfoId&, const KStartupInfoData&);
753  //* @internal
754  void gotStartupChange(const KStartupInfoId&, const KStartupInfoData&);
755 
756 protected:
757  void configure_startup();
758  void updateWindowPixmap(WId);
759 
760 private:
761  TaskManager();
762 
763  Task::TaskPtr _active;
764  Task::Dict m_tasksByWId;
765  WindowList _skiptaskbar_windows;
766  Startup::List _startups;
767  KStartupInfo* _startup_info;
768  KWindowSystem* m_winModule;
769  bool m_trackGeometry;
770 
771  static TaskManager* m_self;
772  static uint m_xCompositeEnabled;
773 
774  class TaskManagerPrivate *d;
775 };
776 
777 #endif
superkaramba_export.h
Task::thumbnail
const QPixmap & thumbnail() const
Returns the thumbnail for this task (or a null image if there is none).
Definition: taskmanager.h:344
Task::showInPager
bool showInPager() const
Returns true if the task should be shown in pager-like apps.
Definition: taskmanager.h:278
TaskDrag
Provids a drag object for tasks across desktops.
Definition: taskmanager.h:520
QDrag
Task::desktop
int desktop() const
Returns the desktop on which this task's window resides.
Definition: taskmanager.h:251
Task::name
QString name() const
Definition: taskmanager.h:121
Startup
Represents a task which is in the process of starting.
Definition: taskmanager.h:547
Task::Dict
QMap< WId, Task::TaskPtr > Dict
Definition: taskmanager.h:99
Task::visibleNameWithState
QString visibleNameWithState() const
Definition: taskmanager.h:117
QWidget
TaskManager
A generic API for task managers.
Definition: taskmanager.h:613
Task::pixmap
QPixmap pixmap() const
Returns a 16x16 (KIconLoader::Small) icon for the task.
Definition: taskmanager.h:142
Task::transients
WindowList transients() const
A list of the window ids of all transient windows (dialogs) associated with this task.
Definition: taskmanager.h:132
QObject
TaskManager::trackGeometry
void trackGeometry()
Tells the task manager whether or not we care about geometry updates.
Definition: taskmanager.h:674
Startup::StartupPtr
KSharedPtr< Startup > StartupPtr
Definition: taskmanager.h:555
Task::List
QVector< Task::TaskPtr > List
Definition: taskmanager.h:98
Startup::icon
QString icon() const
The name of the icon to be used for the starting task.
Definition: taskmanager.h:581
Startup::bin
QString bin() const
The name of the executable of the starting task.
Definition: taskmanager.h:573
WindowList
QList< WId > WindowList
Definition: taskmanager.h:63
TaskManager::winModule
KWindowSystem * winModule() const
Definition: taskmanager.h:684
TaskManager::xCompositeEnabled
static bool xCompositeEnabled()
Definition: taskmanager.h:690
Task::thumbnailSize
double thumbnailSize() const
Returns the current thumbnail size.
Definition: taskmanager.h:316
Task::hasThumbnail
bool hasThumbnail() const
Returns true if this task has a thumbnail.
Definition: taskmanager.h:335
Task::info
KWindowInfo info() const
Definition: taskmanager.h:108
TaskManager::startups
Startup::List startups() const
Returns a list of all current startups.
Definition: taskmanager.h:644
Task::geometry
QRect geometry() const
Returns the geometry for this window.
Definition: taskmanager.h:286
Task::visibleName
QString visibleName() const
Definition: taskmanager.h:113
Task::hasTransient
bool hasTransient(WId w) const
Definition: taskmanager.h:302
SUPERKARAMBA_EXPORT
#define SUPERKARAMBA_EXPORT
Definition: superkaramba_export.h:32
Startup::id
const KStartupInfoId & id() const
Definition: taskmanager.h:586
Task::showInTaskbar
bool showInTaskbar() const
Returns true if the task should be shown in taskbar-like apps.
Definition: taskmanager.h:270
Startup::List
QVector< Startup::StartupPtr > List
Definition: taskmanager.h:556
Task::TaskPtr
KSharedPtr< Task > TaskPtr
Definition: taskmanager.h:97
Task
A dynamic interface to a task (main window).
Definition: taskmanager.h:73
Task::setThumbnailSize
void setThumbnailSize(double size)
Sets the size for the window thumbnail.
Definition: taskmanager.h:326
KShared
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