00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __taskmanager_h__
00026 #define __taskmanager_h__
00027
00028 #include <sys/types.h>
00029
00030 #include <tqobject.h>
00031 #include <tqpixmap.h>
00032 #include <tqpoint.h>
00033 #include <tqptrlist.h>
00034 #include <tqpixmap.h>
00035 #include <tqdragobject.h>
00036 #include <tqrect.h>
00037 #include <tqvaluelist.h>
00038 #include <tqvaluevector.h>
00039
00040 #include <ksharedptr.h>
00041 #include <kstartupinfo.h>
00042 #include <kwin.h>
00043
00044 #include <config.h>
00045
00046 #if defined(HAVE_XCOMPOSITE) && \
00047 defined(HAVE_XRENDER) && \
00048 defined(HAVE_XFIXES)
00049 #include <X11/Xlib.h>
00050 #include <X11/extensions/Xcomposite.h>
00051 #include <X11/extensions/Xfixes.h>
00052 #include <X11/extensions/Xrender.h>
00053 #if XCOMPOSITE_VERSION >= 00200 && \
00054 XFIXES_VERSION >= 20000 && \
00055 (RENDER_MAJOR > 0 || RENDER_MINOR >= 6)
00056 #define THUMBNAILING_POSSIBLE
00057 #endif
00058 #endif
00059
00060 class KWinModule;
00061 class TaskManager;
00062
00063 typedef TQValueList<WId> WindowList;
00064
00071 class KDE_EXPORT Task: public TQObject, public KShared
00072 {
00073 Q_OBJECT
00074 Q_PROPERTY( TQString visibleIconicName READ visibleIconicName )
00075 Q_PROPERTY( TQString iconicName READ iconicName )
00076 Q_PROPERTY( TQString visibleIconicNameWithState READ visibleIconicNameWithState )
00077 Q_PROPERTY( TQString visibleName READ visibleName )
00078 Q_PROPERTY( TQString name READ name )
00079 Q_PROPERTY( TQString visibleNameWithState READ visibleNameWithState )
00080 Q_PROPERTY( TQPixmap pixmap READ pixmap )
00081 Q_PROPERTY( bool maximized READ isMaximized )
00082 Q_PROPERTY( bool minimized READ isMinimized )
00083
00084 Q_PROPERTY( bool iconified READ isIconified )
00085 Q_PROPERTY( bool shaded READ isShaded WRITE setShaded )
00086 Q_PROPERTY( bool active READ isActive )
00087 Q_PROPERTY( bool onCurrentDesktop READ isOnCurrentDesktop )
00088 Q_PROPERTY( bool onAllDesktops READ isOnAllDesktops )
00089 Q_PROPERTY( bool alwaysOnTop READ isAlwaysOnTop WRITE setAlwaysOnTop )
00090 Q_PROPERTY( bool modified READ isModified )
00091 Q_PROPERTY( bool demandsAttention READ demandsAttention )
00092 Q_PROPERTY( int desktop READ desktop )
00093 Q_PROPERTY( double thumbnailSize READ thumbnailSize WRITE setThumbnailSize )
00094 Q_PROPERTY( bool hasThumbnail READ hasThumbnail )
00095 Q_PROPERTY( TQPixmap thumbnail READ thumbnail )
00096
00097 public:
00098 typedef KSharedPtr<Task> Ptr;
00099 typedef TQValueVector<Task::Ptr> List;
00100 typedef TQMap<WId, Task::Ptr> Dict;
00101
00102 Task(WId win, TQObject *parent, const char *name = 0);
00103 virtual ~Task();
00104
00105 WId window() const { return _win; }
00106 KWin::WindowInfo info() const { return _info; }
00107
00108 #if 0 // this would use (_NET_)WM_ICON_NAME, which is shorter, but can be different from window name
00109 TQString visibleIconicName() const { return _info.visibleIconName(); }
00110 TQString visibleIconicNameWithState() const { return _info.visibleIconNameWithState(); }
00111 TQString iconicName() const { return _info.iconName(); }
00112 #else
00113 TQString visibleIconicName() const { return _info.visibleName(); }
00114 TQString visibleIconicNameWithState() const { return _info.visibleNameWithState(); }
00115 TQString iconicName() const { return _info.name(); }
00116 #endif
00117 TQString visibleName() const { return _info.visibleName(); }
00118 TQString visibleNameWithState() const { return _info.visibleNameWithState(); }
00119 TQString name() const { return _info.name(); }
00120 TQString className();
00121 TQString classClass();
00122
00127 WindowList transients() const { return _transients; }
00128
00134 TQPixmap pixmap() const { return _pixmap; }
00135
00150 TQPixmap bestIcon( int size, bool &isStaticIcon );
00151
00161 TQPixmap icon( int width, int height, bool allowResize = false );
00162
00167 static bool idMatch(const TQString &, const TQString &);
00168
00169
00170
00174 bool isMaximized() const;
00175
00179 bool isMinimized() const;
00180
00185 bool isIconified() const;
00186
00190 bool isShaded() const;
00191
00195 bool isActive() const;
00196
00201 bool isOnTop() const;
00202
00206 bool isOnCurrentDesktop() const;
00207
00211 bool isOnAllDesktops() const;
00212
00217 bool isAlwaysOnTop() const;
00218
00223 bool isKeptBelowOthers() const;
00224
00228 bool isFullScreen() const;
00229
00236 bool isModified() const ;
00237
00241 int desktop() const { return _info.desktop(); }
00242
00246 bool demandsAttention() const;
00247
00248
00252 bool isOnScreen( int screen ) const;
00253
00257 bool showInTaskbar() const { return _info.state() ^ NET::SkipTaskbar; }
00258
00262 bool showInPager() const { return _info.state() ^ NET::SkipPager; }
00263
00267 TQRect geometry() const { return _info.geometry(); }
00268
00272 TQRect frameGeometry() const { return _info.frameGeometry(); }
00273
00274
00275
00276
00277 void refresh(unsigned int dirty);
00278
00279 void refreshIcon();
00280
00281 void addTransient( WId w, const NETWinInfo& info );
00282
00283 void removeTransient( WId w );
00284
00285 bool hasTransient(WId w) const { return _transients.find(w) != _transients.end(); }
00286
00287 void updateDemandsAttentionState( WId w );
00288
00289 void setActive(bool a);
00290
00291
00292
00296 double thumbnailSize() const { return _thumbSize; }
00297
00303 void setThumbnailSize( double size ) { _thumbSize = size; }
00304
00309 bool hasThumbnail() const { return !_thumb.isNull(); }
00310
00315 const TQPixmap &thumbnail() const { return _thumb; }
00316
00317 TQPixmap thumbnail(int maxDimension);
00318
00319 void updateWindowPixmap();
00320
00321 public slots:
00322
00323
00327 void setMaximized(bool);
00328 void toggleMaximized();
00329
00333 void restore();
00334
00338 void move();
00339
00343 void resize();
00344
00348 void setIconified(bool);
00349 void toggleIconified();
00350
00354 void close();
00355
00359 void raise();
00360
00364 void lower();
00365
00369 void activate();
00370
00376 void activateRaiseOrIconify();
00377
00381 void setAlwaysOnTop(bool);
00382 void toggleAlwaysOnTop();
00383
00387 void setKeptBelowOthers(bool);
00388 void toggleKeptBelowOthers();
00389
00393 void setFullScreen(bool);
00394 void toggleFullScreen();
00395
00400 void setShaded(bool);
00401 void toggleShaded();
00402
00406 void toDesktop(int);
00407
00411 void toCurrentDesktop();
00412
00418 void publishIconGeometry(TQRect);
00419
00424 void updateThumbnail();
00425
00426 signals:
00430 void changed(bool geometryChangeOnly);
00431
00435 void iconChanged();
00436
00440 void activated();
00441
00445 void deactivated();
00446
00450 void thumbnailChanged();
00451
00452 protected slots:
00453
00454 void generateThumbnail();
00455
00456 protected:
00457 void findWindowFrameId();
00458
00459 private:
00460 bool _active;
00461 WId _win;
00462 WId m_frameId;
00463 TQPixmap _pixmap;
00464 KWin::WindowInfo _info;
00465 WindowList _transients;
00466 WindowList _transients_demanding_attention;
00467
00468 int _lastWidth;
00469 int _lastHeight;
00470 bool _lastResize;
00471 TQPixmap _lastIcon;
00472
00473 double _thumbSize;
00474 TQPixmap _thumb;
00475 TQPixmap _grab;
00476 TQRect m_iconGeometry;
00477 #ifdef THUMBNAILING_POSSIBLE
00478 Pixmap m_windowPixmap;
00479 #endif // THUMBNAILING_POSSIBLE
00480 };
00481
00482
00486 class KDE_EXPORT TaskDrag : public QStoredDrag
00487 {
00488 public:
00492 TaskDrag(const Task::List& tasks, TQWidget* source = 0,
00493 const char* name = 0);
00494 ~TaskDrag();
00495
00499 static bool canDecode( const TQMimeSource* e );
00500
00505 static Task::List decode( const TQMimeSource* e );
00506 };
00507
00508
00514 class KDE_EXPORT Startup: public TQObject, public KShared
00515 {
00516 Q_OBJECT
00517 Q_PROPERTY( TQString text READ text )
00518 Q_PROPERTY( TQString bin READ bin )
00519 Q_PROPERTY( TQString icon READ icon )
00520
00521 public:
00522 typedef KSharedPtr<Startup> Ptr;
00523 typedef TQValueVector<Startup::Ptr> List;
00524
00525 Startup( const KStartupInfoId& id, const KStartupInfoData& data, TQObject * parent,
00526 const char *name = 0);
00527 virtual ~Startup();
00528
00532 TQString text() const { return _data.findName(); }
00533
00537 TQString bin() const { return _data.bin(); }
00538
00542 TQString icon() const { return _data.findIcon(); }
00543 void update( const KStartupInfoData& data );
00544 const KStartupInfoId& id() const { return _id; }
00545
00546 signals:
00550 void changed();
00551
00552 private:
00553 KStartupInfoId _id;
00554 KStartupInfoData _data;
00555 class StartupPrivate *d;
00556 };
00557
00558
00568 class KDE_EXPORT TaskManager : public QObject
00569 {
00570 Q_OBJECT
00571 Q_PROPERTY( int currentDesktop READ currentDesktop )
00572 Q_PROPERTY( int numberOfDesktops READ numberOfDesktops )
00573
00574 public:
00575 static TaskManager* the();
00576 ~TaskManager();
00577
00581 Task::Ptr findTask(WId w);
00582
00586 Task::Ptr findTask(int desktop, const TQPoint& p);
00587
00591 Task::Dict tasks() const { return m_tasksByWId; }
00592
00596 Startup::List startups() const { return _startups; }
00597
00601 TQString desktopName(int n) const;
00602
00606 int numberOfDesktops() const;
00607
00611 int currentDesktop() const;
00612
00616 bool isOnTop(const Task*);
00617
00623 void trackGeometry() { m_trackGeometry = true; }
00624 void trackGeometry(bool track) { m_trackGeometry = track; }
00625
00629 static bool isOnScreen( int screen, const WId wid );
00630
00631 KWinModule* winModule() const { return m_winModule; }
00632
00633 void setXCompositeEnabled(bool state);
00634 static bool xCompositeEnabled() { return m_xCompositeEnabled != 0; }
00635
00636 signals:
00640 void taskAdded(Task::Ptr);
00641
00645 void taskRemoved(Task::Ptr);
00646
00650 void startupAdded(Startup::Ptr);
00651
00657 void startupRemoved(Startup::Ptr);
00658
00662 void desktopChanged(int desktop);
00663
00667 void windowChanged(Task::Ptr);
00668 void windowChangedGeometry(Task::Ptr);
00669
00670 protected slots:
00671
00672 void windowAdded(WId);
00673
00674 void windowRemoved(WId);
00675
00676 void windowChanged(WId, unsigned int);
00677
00678
00679 void activeWindowChanged(WId);
00680
00681 void currentDesktopChanged(int);
00682
00683 void killStartup( const KStartupInfoId& );
00684
00685 void killStartup(Startup::Ptr);
00686
00687
00688 void gotNewStartup( const KStartupInfoId&, const KStartupInfoData& );
00689
00690 void gotStartupChange( const KStartupInfoId&, const KStartupInfoData& );
00691
00692 protected:
00693 void configure_startup();
00694 void updateWindowPixmap(WId);
00695
00696 private:
00697 TaskManager();
00698
00699 Task::Ptr _active;
00700 Task::Dict m_tasksByWId;
00701 WindowList _skiptaskbar_windows;
00702 Startup::List _startups;
00703 KStartupInfo* _startup_info;
00704 KWinModule* m_winModule;
00705 bool m_trackGeometry;
00706
00707 static TaskManager* m_self;
00708 static uint m_xCompositeEnabled;
00709
00710 class TaskManagerPrivate *d;
00711 };
00712
00713 #endif