all repos — fluxbox @ a932a7a80169253fb29be8f1bed87f510cefad24

custom fork of the fluxbox windowmanager

patch from Rob Stevens to add dragndrop-reordering of the tabs
mathias mathias
commit

a932a7a80169253fb29be8f1bed87f510cefad24

parent

a128e9829f704d9f30f1a0410fb56baca0662bae

2 files changed, 113 insertions(+), 0 deletions(-)

jump to
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -357,6 +357,113 @@ // update titlebar

redrawTitle(); } +void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) { + Window parent_return=0, + root_return=75, + *children_return=NULL; + unsigned int nchildren_return; + //get the root window + if(!XQueryTree(FbTk::App::instance()->display(), window().window(), + &root_return, &parent_return, &children_return, &nchildren_return)) + parent_return=parent_return;//return; + if(children_return!=NULL) + XFree(children_return); + int dest_x=0, dest_y=0; + Window labelbutton=0; + if(!XTranslateCoordinates(FbTk::App::instance()->display(), + root_return, label().window(), + x,y, &dest_x, &dest_y, + &labelbutton)) + return; + LabelList::iterator it = m_labelbuttons.begin(); + LabelList::iterator it_end = m_labelbuttons.end(); + //find the label button to move next to + for(; it!=it_end; it++) { + if( (*it)->window()==labelbutton) + break; + } + //label button not found + if(it==it_end) + return; + Window child_return=0; + //make x and y relative to our labelbutton + if(!XTranslateCoordinates(FbTk::App::instance()->display(), + label().window(),labelbutton, + dest_x,dest_y, &x, &y, + &child_return)) + return; + if(x>(*it)->width()/2) + moveLabelButtonRightOf(btn,**it); + else + moveLabelButtonLeftOf(btn,**it); + +} + + + +void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { + LabelList::iterator it = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &btn); + LabelList::iterator new_pos = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &dest); + + // make sure we found them + if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) + { + cout<<"button to move not found"<<endl; + return; + } + //moving a button to the left of itself results in no change + if( new_pos == it) + { + cout<<"source and dest button are the same"<<endl; + return; + } + FbTk::TextButton *item = *it; + //remove from list + m_labelbuttons.erase(it); + //insert on the new place + m_labelbuttons.insert(new_pos, item); + //update titlebar + redrawTitle(); +} + +void FbWinFrame::moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { + LabelList::iterator it = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &btn); + LabelList::iterator new_pos = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &dest); + + // make sure we found them + if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) + { + cout<<"button to move not found"<<endl; + return; + } + //moving a button to the right of itself results in no change + if( new_pos == it) + { + cout<<"source and dest button are the same"<<endl; + return; + } + FbTk::TextButton *item = *it; + //remove from list + m_labelbuttons.erase(it); + //need to insert into the next position + new_pos++; + //insert on the new place + if(new_pos == m_labelbuttons.end()) + m_labelbuttons.push_back(item); + else + m_labelbuttons.insert(new_pos, item); + //update titlebar + redrawTitle(); +} + void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { if (&btn == currentLabel()) return;
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -105,6 +105,12 @@ /// move label button to the left

void moveLabelButtonLeft(const FbTk::TextButton &btn); /// move label button to the right void moveLabelButtonRight(const FbTk::TextButton &btn); + /// move label button to the given location( x and y are relative to the root window) + void moveLabelButtonTo(FbTk::TextButton &btn, int x, int y); + /// move the first label button to the left of the second + void moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest); + //move the first label button to the right of the second + void moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest); /// which button is to be rendered focused void setLabelButtonFocus(FbTk::TextButton &btn); /// attach a client window for client area