diff options
Diffstat (limited to 'lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp')
-rw-r--r-- | lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp index 8f131c9e..3f223a63 100644 --- a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp +++ b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp @@ -8,7 +8,6 @@ #include "../../LSession.h" LTaskManagerPlugin::LTaskManagerPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ - updating=false; timer = new QTimer(this); timer->setSingleShot(true); timer->setInterval(10); // 1/100 second @@ -27,18 +26,22 @@ LTaskManagerPlugin::~LTaskManagerPlugin(){ // PRIVATE SLOTS //============== void LTaskManagerPlugin::UpdateButtons(){ - if(updating){ timer->start(); return; } //check again in a moment - //Make sure this only runs one at a time - updating=true; + updating = QDateTime::currentDateTime(); //global time stamp + QDateTime ctime = updating; //current thread time stamp + //Get the current window list QList<WId> winlist = LSession::handle()->XCB->WindowList(); //qDebug() << "Update Buttons:" << winlist; + if(updating > ctime){ return; } //another thread kicked off already - stop this one //Now go through all the current buttons first for(int i=0; i<BUTTONS.length(); i++){ //Get the windows managed in this button QList<LWinInfo> WI = BUTTONS[i]->windows(); bool updated=false; + if(updating > ctime){ return; } //another thread kicked off already - stop this one + //Loop over all the windows for this button for(int w=0; w<WI.length(); w++){ + if(updating > ctime){ return; } //another thread kicked off already - stop this one if( winlist.contains( WI[w].windowID() ) ){ //Still current window - update it later winlist.removeAll(WI[w].windowID()); //remove this window from the list since it is done @@ -46,42 +49,48 @@ void LTaskManagerPlugin::UpdateButtons(){ //Window was closed - remove it if(WI.length()==1){ //Remove the entire button + qDebug() << "Window Closed: Remove Button" ; this->layout()->takeAt(i); //remove from the layout delete BUTTONS.takeAt(i); i--; updated = true; //prevent updating a removed button break; //break out of the button->window loop }else{ - //qDebug() << "Remove Window:" << WI[w].windowID() << "Button:" << w; + qDebug() << "Window Closed: Remove from button:" << WI[w].windowID() << "Button:" << w; BUTTONS[i]->rmWindow(WI[w]); // one of the multiple windows for the button WI.removeAt(w); //remove this window from the list w--; } updated=true; //button already changed } + if(updating > ctime){ return; } //another thread kicked off already - stop this one } if(!updated){ - //qDebug() << "Update Button:" << i; + qDebug() << "Update Button:" << i; + if(updating > ctime){ return; } //another thread kicked off already - stop this one QTimer::singleShot(1,BUTTONS[i], SLOT(UpdateButton()) ); //keep moving on } } //Now go through the remaining windows for(int i=0; i<winlist.length(); i++){ //New windows, create buttons for each (add grouping later) + if(updating > ctime){ return; } //another thread kicked off already - stop this one //Check for a button that this can just be added to QString ctxt = LX11::WindowClass(winlist[i]); bool found = false; for(int b=0; b<BUTTONS.length(); b++){ + if(updating > ctime){ return; } //another thread kicked off already - stop this one if(BUTTONS[b]->classname()== ctxt){ found = true; - //qDebug() << "Add Window to Button:" << b; + qDebug() << "Add Window to Button:" << b; BUTTONS[b]->addWindow(winlist[i]); break; } } if(!found){ + if(updating > ctime){ return; } //another thread kicked off already - stop this one //No group, create a new button - //qDebug() << "New Button"; + qDebug() << "New Button"; LTaskButton *but = new LTaskButton(this); but->addWindow( LWinInfo(winlist[i]) ); if(this->layout()->direction()==QBoxLayout::LeftToRight){ @@ -93,7 +102,6 @@ void LTaskManagerPlugin::UpdateButtons(){ BUTTONS << but; } } - updating=false; //flag that we are done updating the buttons } void LTaskManagerPlugin::checkWindows(){ |