summaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2005-05-03 09:25:46 (GMT)
committerfluxgen <fluxgen>2005-05-03 09:25:46 (GMT)
commitbc3b377efb10dc4a3a084189657017fd0c9f23b6 (patch)
treedfd1521dbb674bae0c4504263ad073f24a979c22 /src/FbWinFrame.cc
parent86ee497b55d19c3384c913c9847a38ffc14a30ba (diff)
downloadfluxbox_lack-bc3b377efb10dc4a3a084189657017fd0c9f23b6.zip
fluxbox_lack-bc3b377efb10dc4a3a084189657017fd0c9f23b6.tar.bz2
code cleaning
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc175
1 files changed, 86 insertions, 89 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index fe33c09..cdbc6c1 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -407,118 +407,117 @@ void FbWinFrame::moveLabelButtonRight(const FbTk::TextButton &btn) {
407} 407}
408 408
409void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) { 409void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) {
410 Window parent_return=0, 410 Window parent_return=0,
411 root_return=75, 411 root_return=75,
412 *children_return=NULL; 412 *children_return = NULL;
413 unsigned int nchildren_return; 413
414 //get the root window 414 unsigned int nchildren_return;
415 if(!XQueryTree(FbTk::App::instance()->display(), window().window(), 415
416 &root_return, &parent_return, &children_return, &nchildren_return)) 416 // get the root window
417 parent_return=parent_return;//return; 417 if (!XQueryTree(window().display(), window().window(),
418 if(children_return!=NULL) 418 &root_return, &parent_return, &children_return, &nchildren_return))
419 XFree(children_return); 419 parent_return = parent_return;
420 int dest_x=0, dest_y=0; 420
421 Window labelbutton=0; 421 if (children_return != NULL)
422 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 422 XFree(children_return);
423 root_return, label().window(), 423
424 x,y, &dest_x, &dest_y, 424 int dest_x = 0, dest_y = 0;
425 &labelbutton)) 425 Window labelbutton = 0;
426 return; 426 if (!XTranslateCoordinates(window().display(),
427 LabelList::iterator it = m_labelbuttons.begin(); 427 root_return, label().window(),
428 LabelList::iterator it_end = m_labelbuttons.end(); 428 x, y, &dest_x, &dest_y,
429 //find the label button to move next to 429 &labelbutton))
430 for(; it!=it_end; it++) { 430 return;
431 if( (*it)->window()==labelbutton) 431
432 break; 432 LabelList::iterator it = find_if(m_labelbuttons.begin(),
433 } 433 m_labelbuttons.end(),
434 //label button not found 434 CompareWindow(&FbTk::Button::window,
435 if(it==it_end) 435 labelbutton));
436 return; 436 // label button not found
437 Window child_return=0; 437 if (it == m_labelbuttons.end())
438 //make x and y relative to our labelbutton 438 return;
439 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 439
440 label().window(),labelbutton, 440 Window child_return = 0;
441 dest_x,dest_y, &x, &y, 441 //make x and y relative to our labelbutton
442 &child_return)) 442 if (!XTranslateCoordinates(window().display(),
443 return; 443 label().window(),labelbutton,
444 if(x>(*it)->width()/2) 444 dest_x, dest_y, &x, &y,
445 moveLabelButtonRightOf(btn,**it); 445 &child_return))
446 else 446 return;
447 moveLabelButtonLeftOf(btn,**it); 447
448 if (x > (*it)->width() / 2)
449 moveLabelButtonRightOf(btn,**it);
450 else
451 moveLabelButtonLeftOf(btn,**it);
448 452
449} 453}
450 454
451 455
452 456
453void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { 457void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) {
454 LabelList::iterator it = find(m_labelbuttons.begin(), 458 LabelList::iterator it = find(m_labelbuttons.begin(),
455 m_labelbuttons.end(), 459 m_labelbuttons.end(),
456 &btn); 460 &btn);
457 LabelList::iterator new_pos = find(m_labelbuttons.begin(), 461 LabelList::iterator new_pos = find(m_labelbuttons.begin(),
458 m_labelbuttons.end(), 462 m_labelbuttons.end(),
459 &dest); 463 &dest);
460 464
461 // make sure we found them 465 // make sure we found them
462 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) { 466 if (it == m_labelbuttons.end() || new_pos == m_labelbuttons.end())
463 return; 467 return;
464 } 468
465 //moving a button to the left of itself results in no change 469 // moving a button to the left of itself results in no change
466 if( new_pos == it) { 470 if (new_pos == it)
467 return; 471 return;
468 } 472
469 FbTk::TextButton *item = *it; 473 FbTk::TextButton *item = *it;
470 //remove from list 474 // remove from list
471 m_labelbuttons.erase(it); 475 m_labelbuttons.erase(it);
472 //insert on the new place 476 // insert on the new place
473 m_labelbuttons.insert(new_pos, item); 477 m_labelbuttons.insert(new_pos, item);
474 //update titlebar 478 // update titlebar
475 redrawTitlebar(); 479 redrawTitlebar();
476} 480}
477 481
478void FbWinFrame::moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { 482void FbWinFrame::moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) {
479 LabelList::iterator it = find(m_labelbuttons.begin(), 483 LabelList::iterator it = find(m_labelbuttons.begin(),
480 m_labelbuttons.end(), 484 m_labelbuttons.end(),
481 &btn); 485 &btn);
482 LabelList::iterator new_pos = find(m_labelbuttons.begin(), 486 LabelList::iterator new_pos = find(m_labelbuttons.begin(),
483 m_labelbuttons.end(), 487 m_labelbuttons.end(),
484 &dest); 488 &dest);
485 489
486 // make sure we found them 490 // make sure we found them
487 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()){ 491 if (it == m_labelbuttons.end() || new_pos == m_labelbuttons.end())
488 return; 492 return;
489 } 493
490 //moving a button to the right of itself results in no change 494 //moving a button to the right of itself results in no change
491 if( new_pos == it){ 495 if (new_pos == it)
492 return; 496 return;
493 } 497
494 FbTk::TextButton *item = *it; 498 FbTk::TextButton *item = *it;
495 //remove from list 499 // remove from list
496 m_labelbuttons.erase(it); 500 m_labelbuttons.erase(it);
497 //need to insert into the next position 501 // need to insert into the next position
498 new_pos++; 502 new_pos++;
499 //insert on the new place 503 // insert on the new place
500 if(new_pos == m_labelbuttons.end()) 504 if (new_pos == m_labelbuttons.end())
501 m_labelbuttons.push_back(item); 505 m_labelbuttons.push_back(item);
502 else 506 else
503 m_labelbuttons.insert(new_pos, item); 507 m_labelbuttons.insert(new_pos, item);
504 //update titlebar 508 //update titlebar
505 redrawTitlebar(); 509 redrawTitlebar();
506} 510}
507 511
508void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { 512void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
509 if (&btn == currentLabel()) 513 if (&btn == currentLabel() || btn.parent() != &label())
510 return;
511 LabelList::iterator it = find(m_labelbuttons.begin(),
512 m_labelbuttons.end(),
513 &btn);
514 if (it == m_labelbuttons.end())
515 return; 514 return;
516 515
517 // render label buttons 516 // render label buttons
518 if (currentLabel() != 0) 517 if (currentLabel() != 0)
519 applyUnfocusLabel(*m_current_label); 518 applyUnfocusLabel(*m_current_label);
520 519
521 m_current_label = *it; // current focused button 520 m_current_label = &btn; // current focused button
522 521
523 if (m_focused) 522 if (m_focused)
524 applyFocusLabel(*m_current_label); 523 applyFocusLabel(*m_current_label);
@@ -528,11 +527,9 @@ void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
528 527
529void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { 528void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
530 529
531 Display *display = FbTk::App::instance()->display();
532
533 win.setBorderWidth(0); 530 win.setBorderWidth(0);
534 531
535 XChangeSaveSet(display, win.window(), SetModeInsert); 532 XChangeSaveSet(win.display(), win.window(), SetModeInsert);
536 533
537 m_window.setEventMask(NoEventMask); 534 m_window.setEventMask(NoEventMask);
538 535
@@ -546,14 +543,14 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
546 m_window.setEventMask(ButtonPressMask | ButtonReleaseMask | 543 m_window.setEventMask(ButtonPressMask | ButtonReleaseMask |
547 ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask); 544 ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask);
548 545
549 XFlush(display); 546 XFlush(win.display());
550 547
551 XSetWindowAttributes attrib_set; 548 XSetWindowAttributes attrib_set;
552 attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask; 549 attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask;
553 attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask | 550 attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
554 ButtonMotionMask; 551 ButtonMotionMask;
555 552
556 XChangeWindowAttributes(display, win.window(), CWEventMask|CWDontPropagate, &attrib_set); 553 XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set);
557 554
558 m_clientarea.raise(); 555 m_clientarea.raise();
559 win.raise(); 556 win.raise();