//============== // 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; //Get the current window list QList<WId> winlist = LX11::WindowList(); //qDebug() << "Update Buttons:" << winlist; //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; for(int w=0; w<WI.length(); w++){ 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 }else{ //Window was closed - remove it if(WI.length()==1){ //Remove the entire 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{ 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(!updated){ 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) //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(BUTTONS[b]->text().section("(",0,0).simplified() == ctxt){ found = true; BUTTONS[b]->addWindow(winlist[i]); break; } } if(!found){ //No group, create a new button LTaskButton *but = new LTaskButton(this); but->addWindow( LWinInfo(winlist[i]) ); this->layout()->addWidget(but); BUTTONS << but; } } updating=false; }
void LTaskButton::winClicked(QAction* act){ //Get the window from the action if(act->data().toInt() < WINLIST.length()){ cWin = WINLIST[act->data().toInt()]; }else{ cWin = LWinInfo(); } //clear it //Now trigger the window triggerWindow(); }
void LTaskButton::openActionMenu(){ //Get the Window the mouse is currently over QAction *act = winMenu->actionAt(QCursor::pos()); if( act != 0 && winMenu->isVisible() ){ //Get the window from the action if(act->data().toInt() < WINLIST.length()){ cWin = WINLIST[act->data().toInt()]; }else{ cWin = LWinInfo(); } //clear it } //Now show the action menu actMenu->popup(QCursor::pos()); }
void LTaskButton::triggerWindow(){ LWinInfo win = currentWindow(); //Check which state the window is currently in and flip it to the other LX11::WINDOWSTATE state = LX11::GetWindowState(win.windowID()); if(state == LX11::ACTIVE){ qDebug() << "Minimize Window:" << this->text(); LX11::IconifyWindow(win.windowID()); }else if(state == LX11::VISIBLE){ qDebug() << "Activate Window:" << this->text(); LX11::ActivateWindow(win.windowID()); }else{ qDebug() << "Restore Window:" << this->text(); LX11::RestoreWindow(win.windowID()); } cWin = LWinInfo(); //clear the current }
void LTaskButton::closeWindow(){ if(winMenu->isVisible()){ winMenu->hide(); } LWinInfo win = currentWindow(); LX11::CloseWindow(win.windowID()); cWin = LWinInfo(); //clear the current }