aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authormathias <mathias>2004-11-24 23:27:28 (GMT)
committermathias <mathias>2004-11-24 23:27:28 (GMT)
commita932a7a80169253fb29be8f1bed87f510cefad24 (patch)
tree401499971705355c9df550a640e5eccb885bbc08 /src/FbWinFrame.cc
parenta128e9829f704d9f30f1a0410fb56baca0662bae (diff)
downloadfluxbox-a932a7a80169253fb29be8f1bed87f510cefad24.zip
fluxbox-a932a7a80169253fb29be8f1bed87f510cefad24.tar.bz2
patch from Rob Stevens to add dragndrop-reordering of the tabs
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 06c53f6..7f4b4c8 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -357,6 +357,113 @@ void FbWinFrame::moveLabelButtonRight(const FbTk::TextButton &btn) {
357 redrawTitle(); 357 redrawTitle();
358} 358}
359 359
360void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) {
361 Window parent_return=0,
362 root_return=75,
363 *children_return=NULL;
364 unsigned int nchildren_return;
365 //get the root window
366 if(!XQueryTree(FbTk::App::instance()->display(), window().window(),
367 &root_return, &parent_return, &children_return, &nchildren_return))
368 parent_return=parent_return;//return;
369 if(children_return!=NULL)
370 XFree(children_return);
371 int dest_x=0, dest_y=0;
372 Window labelbutton=0;
373 if(!XTranslateCoordinates(FbTk::App::instance()->display(),
374 root_return, label().window(),
375 x,y, &dest_x, &dest_y,
376 &labelbutton))
377 return;
378 LabelList::iterator it = m_labelbuttons.begin();
379 LabelList::iterator it_end = m_labelbuttons.end();
380 //find the label button to move next to
381 for(; it!=it_end; it++) {
382 if( (*it)->window()==labelbutton)
383 break;
384 }
385 //label button not found
386 if(it==it_end)
387 return;
388 Window child_return=0;
389 //make x and y relative to our labelbutton
390 if(!XTranslateCoordinates(FbTk::App::instance()->display(),
391 label().window(),labelbutton,
392 dest_x,dest_y, &x, &y,
393 &child_return))
394 return;
395 if(x>(*it)->width()/2)
396 moveLabelButtonRightOf(btn,**it);
397 else
398 moveLabelButtonLeftOf(btn,**it);
399
400}
401
402
403
404void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) {
405 LabelList::iterator it = find(m_labelbuttons.begin(),
406 m_labelbuttons.end(),
407 &btn);
408 LabelList::iterator new_pos = find(m_labelbuttons.begin(),
409 m_labelbuttons.end(),
410 &dest);
411
412 // make sure we found them
413 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end())
414 {
415 cout<<"button to move not found"<<endl;
416 return;
417 }
418 //moving a button to the left of itself results in no change
419 if( new_pos == it)
420 {
421 cout<<"source and dest button are the same"<<endl;
422 return;
423 }
424 FbTk::TextButton *item = *it;
425 //remove from list
426 m_labelbuttons.erase(it);
427 //insert on the new place
428 m_labelbuttons.insert(new_pos, item);
429 //update titlebar
430 redrawTitle();
431}
432
433void FbWinFrame::moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) {
434 LabelList::iterator it = find(m_labelbuttons.begin(),
435 m_labelbuttons.end(),
436 &btn);
437 LabelList::iterator new_pos = find(m_labelbuttons.begin(),
438 m_labelbuttons.end(),
439 &dest);
440
441 // make sure we found them
442 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end())
443 {
444 cout<<"button to move not found"<<endl;
445 return;
446 }
447 //moving a button to the right of itself results in no change
448 if( new_pos == it)
449 {
450 cout<<"source and dest button are the same"<<endl;
451 return;
452 }
453 FbTk::TextButton *item = *it;
454 //remove from list
455 m_labelbuttons.erase(it);
456 //need to insert into the next position
457 new_pos++;
458 //insert on the new place
459 if(new_pos == m_labelbuttons.end())
460 m_labelbuttons.push_back(item);
461 else
462 m_labelbuttons.insert(new_pos, item);
463 //update titlebar
464 redrawTitle();
465}
466
360void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { 467void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
361 if (&btn == currentLabel()) 468 if (&btn == currentLabel())
362 return; 469 return;