diff options
-rw-r--r-- | src/Tab.cc | 255 | ||||
-rw-r--r-- | src/Tab.hh | 5 |
2 files changed, 157 insertions, 103 deletions
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Tab.cc,v 1.17 2002/01/26 11:16:25 fluxgen Exp $ | 22 | // $Id: Tab.cc,v 1.18 2002/01/27 12:52:02 fluxgen Exp $ |
23 | 23 | ||
24 | #include "Tab.hh" | 24 | #include "Tab.hh" |
25 | 25 | ||
@@ -275,14 +275,11 @@ void Tab::withdraw() { | |||
275 | // Set/reset the the sticky on all windows in the list | 275 | // Set/reset the the sticky on all windows in the list |
276 | //--------------------------------------- | 276 | //--------------------------------------- |
277 | void Tab::stick() { | 277 | void Tab::stick() { |
278 | Tab *tab; | ||
278 | 279 | ||
279 | //get first tab | ||
280 | Tab *first = 0; | ||
281 | first = getFirst(this); | ||
282 | |||
283 | //now do stick for all windows in the list | 280 | //now do stick for all windows in the list |
284 | for (; first!=0; first = first->m_next) { | 281 | for (tab = getFirst(this); tab != 0; tab = tab->m_next) { |
285 | FluxboxWindow *win = first->m_win; //just for convenient | 282 | FluxboxWindow *win = tab->m_win; //just for convenient |
286 | if (win->isStuck()) { | 283 | if (win->isStuck()) { |
287 | win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; | 284 | win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; |
288 | win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; | 285 | win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; |
@@ -305,12 +302,12 @@ void Tab::stick() { | |||
305 | // Resize the window's in the tablist | 302 | // Resize the window's in the tablist |
306 | //---------------------------------- | 303 | //---------------------------------- |
307 | void Tab::resize() { | 304 | void Tab::resize() { |
308 | Tab *first = getFirst(this); | 305 | Tab *tab; |
309 | 306 | ||
310 | //now move and resize the windows in the list | 307 | //now move and resize the windows in the list |
311 | for (; first != 0; first = first->m_next) { | 308 | for (tab = getFirst(this); tab != 0; tab = tab->m_next) { |
312 | if (first!=this) { | 309 | if (tab!=this) { |
313 | first->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), | 310 | tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), |
314 | m_win->getWidth(), m_win->getHeight()); | 311 | m_win->getWidth(), m_win->getHeight()); |
315 | } | 312 | } |
316 | } | 313 | } |
@@ -326,10 +323,12 @@ void Tab::resize() { | |||
326 | // Shades the windows in the tablist | 323 | // Shades the windows in the tablist |
327 | //-------------------------------- | 324 | //-------------------------------- |
328 | void Tab::shade() { | 325 | void Tab::shade() { |
329 | for(Tab *first = getFirst(this); first != 0; first = first->m_next) { | 326 | Tab *tab; |
330 | if (first==this) | 327 | |
328 | for(tab = getFirst(this); tab != 0; tab = tab->m_next) { | ||
329 | if (tab==this) | ||
331 | continue; | 330 | continue; |
332 | first->m_win->shade(); | 331 | tab->m_win->shade(); |
333 | } | 332 | } |
334 | 333 | ||
335 | if (m_win->getScreen()->getTabPlacement() == PLEFT || | 334 | if (m_win->getScreen()->getTabPlacement() == PLEFT || |
@@ -390,6 +389,75 @@ void Tab::draw(bool pressed) { | |||
390 | } | 389 | } |
391 | } | 390 | } |
392 | 391 | ||
392 | //----------------------------------------------- | ||
393 | //Helper for the Tab::setPosition() call | ||
394 | //returns the y position component correctly | ||
395 | //according to shading in cases PBOTTOM and | ||
396 | //isShaded() | ||
397 | //----------------------------------------------- | ||
398 | int Tab::setPositionShadingHelper(bool shaded) { | ||
399 | if (shaded) { | ||
400 | return m_win->getYFrame() + m_win->getTitleHeight() + | ||
401 | m_win->getScreen()->getBorderWidth2x(); | ||
402 | } else { | ||
403 | return m_win->getYFrame() + m_win->getHeight() + | ||
404 | m_win->getScreen()->getBorderWidth2x(); | ||
405 | } | ||
406 | } | ||
407 | |||
408 | //----------------------------------------------- | ||
409 | //Helpers for correct alignment of tabs used | ||
410 | //by the setPosition() call | ||
411 | //return x/y positions correctly according to | ||
412 | //alignment, the 1st for cases PTOP and PBOTTOM | ||
413 | //the 2nd for cases PLEFT and PRIGHT | ||
414 | //----------------------------------------------- | ||
415 | int Tab::setPositionTBAlignHelper(Alignment align) { | ||
416 | switch(align) { | ||
417 | |||
418 | case ARELATIVE: | ||
419 | case ALEFT: | ||
420 | return m_win->getXFrame(); | ||
421 | break; | ||
422 | case ACENTER: | ||
423 | return calcCenterXPos(); | ||
424 | break; | ||
425 | case ARIGHT: | ||
426 | return m_win->getXFrame() + m_win->getWidth() + | ||
427 | m_win->getScreen()->getBorderWidth2x() - m_size_w; | ||
428 | default: | ||
429 | #ifdef DEBUG | ||
430 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | ||
431 | "Unsupported Alignment" << endl; | ||
432 | #endif //DEBUG | ||
433 | return 0; | ||
434 | break; | ||
435 | } | ||
436 | } | ||
437 | |||
438 | int Tab::setPositionLRAlignHelper(Alignment align) { | ||
439 | switch(align) { | ||
440 | case ALEFT: | ||
441 | return m_win->getYFrame() - m_size_h + m_win->getHeight() + | ||
442 | m_win->getScreen()->getBorderWidth2x(); | ||
443 | break; | ||
444 | case ACENTER: | ||
445 | return calcCenterYPos(); | ||
446 | break; | ||
447 | case ARELATIVE: | ||
448 | case ARIGHT: | ||
449 | return m_win->getYFrame(); | ||
450 | break; | ||
451 | default: | ||
452 | #ifdef DEBUG | ||
453 | cerr << __FILE__ << ":"<< __LINE__ << ": " << | ||
454 | "Unsupported Alignment" << endl; | ||
455 | #endif //DEBUG | ||
456 | return 0; | ||
457 | break; | ||
458 | } | ||
459 | } | ||
460 | |||
393 | //------------- setPosition ----------------- | 461 | //------------- setPosition ----------------- |
394 | // Position tab ( follow the m_win pos ). | 462 | // Position tab ( follow the m_win pos ). |
395 | // (and resize) | 463 | // (and resize) |
@@ -400,85 +468,62 @@ void Tab::setPosition() { | |||
400 | if (m_stoptabs) | 468 | if (m_stoptabs) |
401 | return; | 469 | return; |
402 | 470 | ||
403 | Tab *first = 0; | 471 | Tab *tab; |
404 | int pos_x = 0, pos_y = 0; | 472 | int pos_x = 0, pos_y = 0; |
405 | 473 | ||
406 | m_stoptabs = true; //freeze tablist | 474 | m_stoptabs = true; //freeze tablist |
407 | 475 | ||
408 | //and check for max tabs | 476 | //and check for max tabs |
409 | //TODO: optimize! There is many ways to implement this... | ||
410 | //posible movement to a static member function | ||
411 | |||
412 | //Tab placement | ||
413 | if (m_win->getScreen()->getTabPlacement() == PTOP) { | ||
414 | pos_y = m_win->getYFrame() - m_size_h; | ||
415 | 477 | ||
416 | } else if (m_win->getScreen()->getTabPlacement() == PBOTTOM || | 478 | //Tab placement + alignment |
417 | m_win->isShaded()) { | 479 | switch (m_win->getScreen()->getTabPlacement()) { |
418 | if (m_win->isShaded()) | 480 | case PTOP: |
419 | pos_y = m_win->getYFrame() + m_win->getTitleHeight() + | 481 | pos_y = m_win->getYFrame() - m_size_h; |
420 | m_win->getScreen()->getBorderWidth2x(); | 482 | pos_x = setPositionTBAlignHelper( |
421 | 483 | m_win->getScreen()->getTabAlignment()); | |
422 | else | 484 | break; |
423 | pos_y = m_win->getYFrame() + m_win->getHeight() + | 485 | case PBOTTOM: |
424 | m_win->getScreen()->getBorderWidth2x(); | 486 | pos_y = setPositionShadingHelper(m_win->isShaded()); |
425 | 487 | pos_x = setPositionTBAlignHelper( | |
426 | } else if (m_win->getScreen()->getTabPlacement() == PLEFT) { | 488 | m_win->getScreen()->getTabAlignment()); |
489 | break; | ||
490 | case PLEFT: | ||
427 | pos_x = m_win->getXFrame() - m_size_w; | 491 | pos_x = m_win->getXFrame() - m_size_w; |
428 | 492 | pos_y = setPositionLRAlignHelper( | |
429 | } else if (m_win->getScreen()->getTabPlacement() == PRIGHT) { | 493 | m_win->getScreen()->getTabAlignment()); |
430 | pos_x = m_win->getXFrame() + m_win->getWidth() + | 494 | break; |
431 | m_win->getScreen()->getBorderWidth2x(); | 495 | case PRIGHT: |
432 | } | 496 | pos_x = m_win->getXFrame() + m_win->getWidth() + |
433 | 497 | m_win->getScreen()->getBorderWidth2x(); | |
434 | //Tab alignment | 498 | pos_y = setPositionLRAlignHelper( |
435 | if (m_win->getScreen()->getTabPlacement() == PTOP || | 499 | m_win->getScreen()->getTabAlignment()); |
436 | m_win->getScreen()->getTabPlacement() == PBOTTOM || | 500 | break; |
437 | m_win->isShaded()) { | 501 | default: |
438 | switch(m_win->getScreen()->getTabAlignment()) { | 502 | if(m_win->isShaded()) { |
439 | case ARELATIVE: | 503 | pos_y = setPositionShadingHelper(true); |
440 | case ALEFT: | 504 | pos_x = setPositionTBAlignHelper( |
441 | pos_x = m_win->getXFrame(); | 505 | m_win->getScreen()->getTabAlignment()); |
442 | break; | 506 | } else { |
443 | case ACENTER: | 507 | setPositionShadingHelper(false); |
444 | pos_x = calcCenterXPos(); | ||
445 | break; | ||
446 | case ARIGHT: | ||
447 | pos_x = m_win->getXFrame() + m_win->getWidth() + | ||
448 | m_win->getScreen()->getBorderWidth2x() - m_size_w; | ||
449 | break; | ||
450 | } | ||
451 | } else { //PLeft | PRight | ||
452 | switch(m_win->getScreen()->getTabAlignment()) { | ||
453 | case ALEFT: | ||
454 | pos_y = m_win->getYFrame() - m_size_h + m_win->getHeight() + | ||
455 | m_win->getScreen()->getBorderWidth2x(); | ||
456 | break; | ||
457 | case ACENTER: | ||
458 | pos_y = calcCenterYPos(); | ||
459 | break; | ||
460 | case ARELATIVE: | ||
461 | case ARIGHT: | ||
462 | pos_y = m_win->getYFrame(); | ||
463 | break; | ||
464 | } | 508 | } |
509 | break; | ||
465 | } | 510 | } |
466 | 511 | ||
467 | for (first = getFirst(this); | 512 | for (tab = getFirst(this); |
468 | first!=0; | 513 | tab!=0; |
469 | pos_x += first->m_inc_x, pos_y += first->m_inc_y, | 514 | pos_x += tab->m_inc_x, pos_y += tab->m_inc_y, |
470 | first = first->m_next){ | 515 | tab = tab->m_next){ |
471 | 516 | ||
472 | XMoveWindow(m_display, first->m_tabwin, pos_x, pos_y); | 517 | XMoveWindow(m_display, tab->m_tabwin, pos_x, pos_y); |
473 | 518 | ||
474 | //dont move fluxboxwindow if the itterator = this | 519 | //dont move FluxboxWindow if the iterator = this |
475 | if (first!=this) { | 520 | if (tab!=this) { |
476 | first->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), | 521 | tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), |
477 | m_win->getWidth(), m_win->getHeight()); | 522 | m_win->getWidth(), m_win->getHeight()); |
478 | } | 523 | } |
479 | } | 524 | } |
480 | 525 | ||
481 | m_stoptabs = false; | 526 | m_stoptabs = false;//thaw tablist |
482 | } | 527 | } |
483 | 528 | ||
484 | //------------- calcIncrease ---------------- | 529 | //------------- calcIncrease ---------------- |
@@ -490,7 +535,7 @@ void Tab::calcIncrease(void) { | |||
490 | cerr << "Calculating tab increase" << endl; | 535 | cerr << "Calculating tab increase" << endl; |
491 | #endif // DEBUG | 536 | #endif // DEBUG |
492 | 537 | ||
493 | Tab *first; | 538 | Tab *tab; |
494 | int inc_x = 0, inc_y = 0; | 539 | int inc_x = 0, inc_y = 0; |
495 | unsigned int tabs = 0, i = 0; | 540 | unsigned int tabs = 0, i = 0; |
496 | 541 | ||
@@ -512,6 +557,8 @@ void Tab::calcIncrease(void) { | |||
512 | case ARELATIVE: | 557 | case ARELATIVE: |
513 | inc_x = calcRelativeWidth(); | 558 | inc_x = calcRelativeWidth(); |
514 | break; | 559 | break; |
560 | default: | ||
561 | break; | ||
515 | } | 562 | } |
516 | } else if (m_win->getScreen()->getTabPlacement() == PLEFT || | 563 | } else if (m_win->getScreen()->getTabPlacement() == PLEFT || |
517 | m_win->getScreen()->getTabPlacement() == PRIGHT) { | 564 | m_win->getScreen()->getTabPlacement() == PRIGHT) { |
@@ -530,12 +577,14 @@ void Tab::calcIncrease(void) { | |||
530 | case ARELATIVE: | 577 | case ARELATIVE: |
531 | inc_y = calcRelativeHeight(); | 578 | inc_y = calcRelativeHeight(); |
532 | break; | 579 | break; |
580 | default: | ||
581 | break; | ||
533 | } | 582 | } |
534 | } | 583 | } |
535 | 584 | ||
536 | for (first = getFirst(this); first!=0; first = first->m_next, tabs++); | 585 | for (tab = getFirst(this); tab!=0; tab = tab->m_next, tabs++); |
537 | 586 | ||
538 | for (first = getFirst(this); first!=0; first = first->m_next, i++){ | 587 | for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++){ |
539 | 588 | ||
540 | //TODO: move this out from here? | 589 | //TODO: move this out from here? |
541 | if ((m_win->getScreen()->getTabPlacement() == PTOP || | 590 | if ((m_win->getScreen()->getTabPlacement() == PTOP || |
@@ -546,30 +595,30 @@ void Tab::calcIncrease(void) { | |||
546 | m_win->getScreen()->getBorderWidth2x()) % tabs) || | 595 | m_win->getScreen()->getBorderWidth2x()) % tabs) || |
547 | i >= ((m_win->getWidth() + | 596 | i >= ((m_win->getWidth() + |
548 | m_win->getScreen()->getBorderWidth2x()) % tabs)) { | 597 | m_win->getScreen()->getBorderWidth2x()) % tabs)) { |
549 | first->setTabWidth(inc_x); | 598 | tab->setTabWidth(inc_x); |
550 | first->m_inc_x = inc_x; | 599 | tab->m_inc_x = inc_x; |
551 | } else { // adding 1 extra pixel to get tabs like win width | 600 | } else { // adding 1 extra pixel to get tabs like win width |
552 | first->setTabWidth(inc_x + 1); | 601 | tab->setTabWidth(inc_x + 1); |
553 | first->m_inc_x = inc_x + 1; | 602 | tab->m_inc_x = inc_x + 1; |
554 | } | 603 | } |
555 | first->m_inc_y = inc_y; | 604 | tab->m_inc_y = inc_y; |
556 | } else if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { | 605 | } else if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { |
557 | if (!((m_win->getHeight() + | 606 | if (!((m_win->getHeight() + |
558 | m_win->getScreen()->getBorderWidth2x()) % tabs) || | 607 | m_win->getScreen()->getBorderWidth2x()) % tabs) || |
559 | i >= ((m_win->getHeight() + | 608 | i >= ((m_win->getHeight() + |
560 | m_win->getScreen()->getBorderWidth2x()) % tabs)) { | 609 | m_win->getScreen()->getBorderWidth2x()) % tabs)) { |
561 | 610 | ||
562 | first->setTabHeight(inc_y); | 611 | tab->setTabHeight(inc_y); |
563 | first->m_inc_y = inc_y; | 612 | tab->m_inc_y = inc_y; |
564 | } else { | 613 | } else { |
565 | // adding 1 extra pixel to get tabs match window width | 614 | // adding 1 extra pixel to get tabs match window width |
566 | first->setTabHeight(inc_y + 1); | 615 | tab->setTabHeight(inc_y + 1); |
567 | first->m_inc_y = inc_y + 1; | 616 | tab->m_inc_y = inc_y + 1; |
568 | } | 617 | } |
569 | first->m_inc_x = inc_x; | 618 | tab->m_inc_x = inc_x; |
570 | } else { // non relative modes | 619 | } else { // non relative modes |
571 | first->m_inc_x = inc_x; | 620 | tab->m_inc_x = inc_x; |
572 | first->m_inc_y = inc_y; | 621 | tab->m_inc_y = inc_y; |
573 | } | 622 | } |
574 | } | 623 | } |
575 | } | 624 | } |
@@ -617,13 +666,11 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) { | |||
617 | m_win->getScreen()->getRootWindow(), | 666 | m_win->getScreen()->getRootWindow(), |
618 | be->x_root, be->y_root, &dest_x, &dest_y, &child)) { | 667 | be->x_root, be->y_root, &dest_x, &dest_y, &child)) { |
619 | 668 | ||
620 | Tab *tab = 0; | 669 | Tab *tab = Fluxbox::instance()->searchTab(child); |
621 | FluxboxWindow *win = 0; | 670 | FluxboxWindow *win = Fluxbox::instance()->searchWindow(child); |
622 | //search tablist for a tabwindow | 671 | //search tablist for a tabwindow |
623 | if (((tab = Fluxbox::instance()->searchTab(child))!=0) || | 672 | if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() && |
624 | (m_win->getScreen()->isSloppyWindowGrouping() && | 673 | (win!=0) && (tab = win->getTab())!=0)) { |
625 | ((win = Fluxbox::instance()->searchWindow(child))!=0) && | ||
626 | (tab = win->getTab())!=0)) { | ||
627 | 674 | ||
628 | if (tab == this) // inserting ourself to ourself causes a disconnect | 675 | if (tab == this) // inserting ourself to ourself causes a disconnect |
629 | return; | 676 | return; |
@@ -639,7 +686,7 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) { | |||
639 | } else { | 686 | } else { |
640 | disconnect(); | 687 | disconnect(); |
641 | 688 | ||
642 | // convinience | 689 | // convenience |
643 | unsigned int placement = m_win->getScreen()->getTabPlacement(); | 690 | unsigned int placement = m_win->getScreen()->getTabPlacement(); |
644 | 691 | ||
645 | // (ab)using dest_x and dest_y | 692 | // (ab)using dest_x and dest_y |
@@ -661,6 +708,8 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) { | |||
661 | case ARIGHT: | 708 | case ARIGHT: |
662 | dest_x -= m_win->getWidth() - m_size_w; | 709 | dest_x -= m_win->getWidth() - m_size_w; |
663 | break; | 710 | break; |
711 | default: | ||
712 | break; | ||
664 | } | 713 | } |
665 | 714 | ||
666 | } else { // PLEFT & PRIGHT | 715 | } else { // PLEFT & PRIGHT |
@@ -674,6 +723,8 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) { | |||
674 | case ALEFT: | 723 | case ALEFT: |
675 | dest_y -= m_win->getHeight() - m_size_h; | 724 | dest_y -= m_win->getHeight() - m_size_h; |
676 | break; | 725 | break; |
726 | default: | ||
727 | break; | ||
677 | } | 728 | } |
678 | } | 729 | } |
679 | //TODO: this causes an calculate increase event, even if we | 730 | //TODO: this causes an calculate increase event, even if we |
@@ -979,7 +1030,7 @@ void Tab::setTabHeight(unsigned int h) { | |||
979 | // --------------------------------------- | 1030 | // --------------------------------------- |
980 | void Tab::resizeGroup(void) { | 1031 | void Tab::resizeGroup(void) { |
981 | #ifdef DEBUG | 1032 | #ifdef DEBUG |
982 | cerr << "Resising group" << endl; | 1033 | cerr <<__FILE__<<"("<<__LINE__<<"): Resizing group"<<endl; |
983 | #endif //DEBUG | 1034 | #endif //DEBUG |
984 | Tab *first; | 1035 | Tab *first; |
985 | for (first = getFirst(this); first != 0; first = first->m_next) { | 1036 | for (first = getFirst(this); first != 0; first = first->m_next) { |
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Tab.hh,v 1.8 2002/01/20 02:15:23 fluxgen Exp $ | 22 | // $Id: Tab.hh,v 1.9 2002/01/27 12:52:02 fluxgen Exp $ |
23 | 23 | ||
24 | #ifndef _TAB_HH_ | 24 | #ifndef _TAB_HH_ |
25 | #define _TAB_HH_ | 25 | #define _TAB_HH_ |
@@ -95,6 +95,9 @@ private: | |||
95 | bool m_focus, m_moving; // moving and focus | 95 | bool m_focus, m_moving; // moving and focus |
96 | void createTabWindow(); // creates the X win of tab | 96 | void createTabWindow(); // creates the X win of tab |
97 | void loadTheme(); // loads the textures with right width and height | 97 | void loadTheme(); // loads the textures with right width and height |
98 | int setPositionShadingHelper(bool shaded); | ||
99 | int setPositionTBAlignHelper(Alignment align); | ||
100 | int setPositionLRAlignHelper(Alignment align); | ||
98 | void setTabWidth(unsigned int w); | 101 | void setTabWidth(unsigned int w); |
99 | void setTabHeight(unsigned int h); | 102 | void setTabHeight(unsigned int h); |
100 | unsigned int calcRelativeWidth(); | 103 | unsigned int calcRelativeWidth(); |