6 #include "desktoptracker.h"
9 const int minimumInterval = 5;
11 DesktopTracker::DesktopTracker ()
14 connect( &kWinModule, TQ_SIGNAL( currentDesktopChanged(
int) ),
15 this, TQ_SLOT( handleDesktopChange(
int) ));
17 _desktopCount = kWinModule.numberOfDesktops();
18 _previousDesktop = kWinModule.currentDesktop()-1;
21 if( _previousDesktop < 0 ) _previousDesktop = 0;
23 _timer =
new TQTimer(
this);
24 connect( _timer, TQ_SIGNAL( timeout() ),
this, TQ_SLOT( changeTimers() ) );
27 void DesktopTracker::handleDesktopChange(
int desktop )
35 if ( !_timer->start( minimumInterval * 1000,
true ) ) changeTimers();
38 void DesktopTracker::changeTimers()
42 TaskVector::iterator it;
45 TaskVector tv = desktopTracker[_previousDesktop];
46 for (it = tv.begin(); it != tv.end(); ++it) {
47 emit leftActiveDesktop(*it);
51 tv = desktopTracker[_desktop];
52 for (it = tv.begin(); it != tv.end(); ++it) {
53 emit reachedtActiveDesktop(*it);
55 _previousDesktop = _desktop;
60 TQString DesktopTracker::startTracking()
63 int currentDesktop = kWinModule.currentDesktop() -1;
66 if ( currentDesktop < 0 ) currentDesktop = 0;
67 if ( currentDesktop < maxDesktops )
69 TaskVector &tv = desktopTracker[ currentDesktop ];
70 TaskVector::iterator tit = tv.begin();
73 emit reachedtActiveDesktop(*tit);
77 else err=
"ETooHighDeskTopNumber";
81 void DesktopTracker::registerForDesktops(
Task* task, DesktopList desktopList)
84 if (desktopList.size()==0) {
85 for (
int i=0; i<maxDesktops; i++) {
86 TaskVector *v = &(desktopTracker[i]);
87 TaskVector::iterator tit = std::find(v->begin(), v->end(), task);
89 desktopTracker[i].erase(tit);
92 if( i == kWinModule.currentDesktop() -1)
93 emit leftActiveDesktop(task);
102 if (desktopList.size()>0) {
103 for (
int i=0; i<maxDesktops; i++) {
104 TaskVector& v = desktopTracker[i];
105 TaskVector::iterator tit = std::find(v.begin(), v.end(), task);
107 if ( std::find( desktopList.begin(), desktopList.end(), i)
108 != desktopList.end()) {
118 if( i == kWinModule.currentDesktop() -1)
119 emit leftActiveDesktop(task);
127 void DesktopTracker::printTrackers() {
128 TaskVector::iterator it;
129 for (
int i=0; i<maxDesktops; i++) {
130 TaskVector& start = desktopTracker[i];
132 while (it != start.end()) {
137 #include "desktoptracker.moc"
A class representing a task.