diff options
author | rathnor <rathnor> | 2003-06-05 13:21:10 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-06-05 13:21:10 (GMT) |
commit | a5e8987acd27107581901e5c451450ed9f2ce30c (patch) | |
tree | 7fc22dd810d159fb0033fbc8106e9ce6dab665a3 /src | |
parent | 72479063aacfdaceb7bc6a4cfe9f263b78860aae (diff) | |
download | fluxbox_lack-a5e8987acd27107581901e5c451450ed9f2ce30c.zip fluxbox_lack-a5e8987acd27107581901e5c451450ed9f2ce30c.tar.bz2 |
much improved window placement algorithm
Diffstat (limited to 'src')
-rw-r--r-- | src/Workspace.cc | 123 |
1 files changed, 93 insertions, 30 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc index ef2429f..11a972b 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Workspace.cc,v 1.69 2003/05/21 23:59:54 rathnor Exp $ | 25 | // $Id: Workspace.cc,v 1.70 2003/06/05 13:21:10 rathnor Exp $ |
26 | 26 | ||
27 | #include "Workspace.hh" | 27 | #include "Workspace.hh" |
28 | 28 | ||
@@ -545,28 +545,37 @@ void Workspace::placeWindow(FluxboxWindow &win) { | |||
545 | } // end case UNDERMOUSEPLACEMENT | 545 | } // end case UNDERMOUSEPLACEMENT |
546 | 546 | ||
547 | case BScreen::ROWSMARTPLACEMENT: { | 547 | case BScreen::ROWSMARTPLACEMENT: { |
548 | int next_x, next_y; | ||
549 | bool top_bot = screen().getColPlacementDirection() == BScreen::TOPBOTTOM; | ||
550 | bool left_right = screen().getRowPlacementDirection() == BScreen::LEFTRIGHT; | ||
548 | 551 | ||
549 | test_y = 0; | 552 | if (top_bot) |
550 | 553 | test_y = head_top; | |
551 | if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) | 554 | else |
552 | test_y = head_bot - win_h - test_y; | 555 | test_y = head_bot - win_h; |
553 | |||
554 | |||
555 | while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ? | ||
556 | test_y > 0 : test_y + win_h < head_bot) && | ||
557 | ! placed) { | ||
558 | 556 | ||
559 | test_x = 0; | 557 | while (!placed && |
558 | (top_bot ? test_y + win_h < head_bot | ||
559 | : test_y > head_top)) { | ||
560 | 560 | ||
561 | if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) | 561 | if (left_right) |
562 | test_x = head_right - win_w - test_x; | 562 | test_x = head_left; |
563 | else | ||
564 | test_x = head_right - win_w; | ||
563 | 565 | ||
566 | if (top_bot) | ||
567 | next_y = head_right; // it will get shrunk | ||
568 | else | ||
569 | next_y = head_left; | ||
564 | 570 | ||
565 | while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 571 | while (!placed && |
566 | test_x > 0 : test_x + win_w < head_right) && ! placed) { | 572 | (left_right ? test_x + win_w < head_right |
573 | : test_x > head_left)) { | ||
567 | 574 | ||
568 | placed = true; | 575 | placed = true; |
569 | 576 | ||
577 | next_x = test_x + change_x; | ||
578 | |||
570 | Windows::iterator win_it = m_windowlist.begin(); | 579 | Windows::iterator win_it = m_windowlist.begin(); |
571 | const Windows::iterator win_it_end = m_windowlist.end(); | 580 | const Windows::iterator win_it_end = m_windowlist.end(); |
572 | 581 | ||
@@ -582,7 +591,28 @@ void Workspace::placeWindow(FluxboxWindow &win) { | |||
582 | curr_x + curr_w > test_x && | 591 | curr_x + curr_w > test_x && |
583 | curr_y < test_y + win_h && | 592 | curr_y < test_y + win_h && |
584 | curr_y + curr_h > test_y) { | 593 | curr_y + curr_h > test_y) { |
594 | // this window is in the way | ||
585 | placed = false; | 595 | placed = false; |
596 | |||
597 | // we find the next x that we can go to (a window will be in the way | ||
598 | // all the way to its far side) | ||
599 | if (left_right) { | ||
600 | if (curr_x + curr_w > next_x) | ||
601 | next_x = curr_x + curr_w; | ||
602 | } else { | ||
603 | if (curr_x - win_w < next_x) | ||
604 | next_x = curr_x - win_w; | ||
605 | } | ||
606 | |||
607 | // but we can only go to the nearest y, since that is where the | ||
608 | // next time current windows in the way will change | ||
609 | if (top_bot) { | ||
610 | if (curr_y + curr_h < next_y) | ||
611 | next_y = curr_y + curr_h; | ||
612 | } else { | ||
613 | if (curr_y - win_h > next_y) | ||
614 | next_y = curr_y - win_h; | ||
615 | } | ||
586 | } | 616 | } |
587 | } | 617 | } |
588 | 618 | ||
@@ -594,34 +624,46 @@ void Workspace::placeWindow(FluxboxWindow &win) { | |||
594 | break; | 624 | break; |
595 | } | 625 | } |
596 | 626 | ||
597 | test_x += change_x; | 627 | test_x = next_x; |
598 | } // end while | 628 | } // end while |
599 | 629 | ||
600 | test_y += change_y; | 630 | test_y = next_y; |
601 | } // end while | 631 | } // end while |
602 | 632 | ||
603 | break; | 633 | break; |
604 | } // end case ROWSMARTPLACEMENT | 634 | } // end case ROWSMARTPLACEMENT |
605 | 635 | ||
606 | case BScreen::COLSMARTPLACEMENT: { | 636 | case BScreen::COLSMARTPLACEMENT: { |
607 | test_x = head_left; | 637 | int next_x, next_y; |
638 | bool top_bot = screen().getColPlacementDirection() == BScreen::TOPBOTTOM; | ||
639 | bool left_right = screen().getRowPlacementDirection() == BScreen::LEFTRIGHT; | ||
608 | 640 | ||
609 | if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) | 641 | if (left_right) |
642 | test_x = head_left; | ||
643 | else | ||
610 | test_x = head_right - win_w; | 644 | test_x = head_right - win_w; |
611 | 645 | ||
612 | while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 646 | while (!placed && |
613 | test_x > head_left : test_x + win_w < head_right) && | 647 | (left_right ? test_x + win_w < head_right |
614 | !placed) { | 648 | : test_x > head_left)) { |
615 | 649 | ||
616 | test_y = head_top; | 650 | if (left_right) |
617 | if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) | 651 | next_x = head_right; // it will get shrunk |
652 | else | ||
653 | next_x = head_left; | ||
654 | |||
655 | if (top_bot) | ||
656 | test_y = head_top; | ||
657 | else | ||
618 | test_y = head_bot - win_h; | 658 | test_y = head_bot - win_h; |
619 | 659 | ||
620 | while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ? | 660 | while (!placed && |
621 | test_y > head_top : test_y + win_h < head_bot) && | 661 | (top_bot ? test_y + win_h < head_bot |
622 | !placed) { | 662 | : test_y > head_top)) { |
623 | placed = True; | 663 | placed = True; |
624 | 664 | ||
665 | next_y = test_y + change_y; | ||
666 | |||
625 | Windows::iterator it = m_windowlist.begin(); | 667 | Windows::iterator it = m_windowlist.begin(); |
626 | Windows::iterator it_end = m_windowlist.end(); | 668 | Windows::iterator it_end = m_windowlist.end(); |
627 | for (; it != it_end && placed; ++it) { | 669 | for (; it != it_end && placed; ++it) { |
@@ -634,7 +676,28 @@ void Workspace::placeWindow(FluxboxWindow &win) { | |||
634 | curr_x + curr_w > test_x && | 676 | curr_x + curr_w > test_x && |
635 | curr_y < test_y + win_h && | 677 | curr_y < test_y + win_h && |
636 | curr_y + curr_h > test_y) { | 678 | curr_y + curr_h > test_y) { |
679 | // this window is in the way | ||
637 | placed = False; | 680 | placed = False; |
681 | |||
682 | // we find the next y that we can go to (a window will be in the way | ||
683 | // all the way to its bottom) | ||
684 | if (top_bot) { | ||
685 | if (curr_y + curr_h > next_y) | ||
686 | next_y = curr_y + curr_h; | ||
687 | } else { | ||
688 | if (curr_y - win_h < next_y) | ||
689 | next_y = curr_y - win_h; | ||
690 | } | ||
691 | |||
692 | // but we can only go to the nearest x, since that is where the | ||
693 | // next time current windows in the way will change | ||
694 | if (left_right) { | ||
695 | if (curr_x + curr_w < next_x) | ||
696 | next_x = curr_x + curr_w; | ||
697 | } else { | ||
698 | if (curr_x - win_w > next_x) | ||
699 | next_x = curr_x - win_w; | ||
700 | } | ||
638 | } | 701 | } |
639 | } | 702 | } |
640 | 703 | ||
@@ -643,10 +706,10 @@ void Workspace::placeWindow(FluxboxWindow &win) { | |||
643 | place_y = test_y; | 706 | place_y = test_y; |
644 | } | 707 | } |
645 | 708 | ||
646 | test_y += change_y; | 709 | test_y = next_y; |
647 | } // end while | 710 | } // end while |
648 | 711 | ||
649 | test_x += change_x; | 712 | test_x = next_x; |
650 | } // end while | 713 | } // end while |
651 | 714 | ||
652 | break; | 715 | break; |