summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc50
-rw-r--r--src/Screen.hh11
-rw-r--r--src/Window.cc46
-rw-r--r--src/Workspace.cc68
4 files changed, 90 insertions, 85 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 0d1614d..f67b63a 100644
--- a/src/Screen.cc
+++ b/src/Screen.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: Screen.cc,v 1.174 2003/05/19 22:45:17 fluxgen Exp $ 25// $Id: Screen.cc,v 1.175 2003/05/20 11:03:10 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -808,47 +808,31 @@ Pixmap BScreen::rootPixmap() const {
808 808
809} 809}
810 810
811unsigned int BScreen::maxLeft(const FbTk::FbWindow &win) const { 811unsigned int BScreen::maxLeft(int head) const {
812 if (hasXinerama()) { 812 if (hasXinerama())
813 int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
814 // we MUST use a head, we use the center of the window, or if that
815 // isn't in a head, then the mouse's head
816 if (head == 0) head = getCurrHead();
817 return getHeadX(head); 813 return getHeadX(head);
818 } else 814 else
819 return 0; 815 return 0;
820} 816}
821 817
822unsigned int BScreen::maxRight(const FbTk::FbWindow &win) const { 818unsigned int BScreen::maxRight(int head) const {
823 if (hasXinerama()) { 819 if (hasXinerama())
824 int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
825 // we MUST use a head, we use the center of the window, or if that
826 // isn't in a head, then the mouse's head
827 if (head == 0) head = getCurrHead();
828 return getHeadX(head) + getHeadWidth(head); 820 return getHeadX(head) + getHeadWidth(head);
829 } else 821 else
830 return width(); 822 return width();
831} 823}
832 824
833unsigned int BScreen::maxTop(const FbTk::FbWindow &win) const { 825unsigned int BScreen::maxTop(int head) const {
834 if (hasXinerama()) { 826 if (hasXinerama())
835 int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
836 // we MUST use a head, we use the center of the window, or if that
837 // isn't in a head, then the mouse's head
838 if (head == 0) head = getCurrHead();
839 return getHeadY(head); 827 return getHeadY(head);
840 } else 828 else
841 return 0; 829 return 0;
842} 830}
843 831
844unsigned int BScreen::maxBottom(const FbTk::FbWindow &win) const { 832unsigned int BScreen::maxBottom(int head) const {
845 if (hasXinerama()) { 833 if (hasXinerama())
846 int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
847 // we MUST use a head, we use the center of the window, or if that
848 // isn't in a head, then the mouse's head
849 if (head == 0) head = getCurrHead();
850 return getHeadY(head) + getHeadHeight(head); 834 return getHeadY(head) + getHeadHeight(head);
851 } else 835 else
852 return height(); 836 return height();
853} 837}
854 838
@@ -2605,6 +2589,14 @@ int BScreen::getHead(int x, int y) const {
2605 return 0; 2589 return 0;
2606} 2590}
2607 2591
2592int BScreen::getHead(FbTk::FbWindow &win) const {
2593 if (hasXinerama())
2594 return getHead(win.x() + win.width()/2, win.y() + win.height()/2);
2595 else
2596 return 0;
2597}
2598
2599
2608int BScreen::getCurrHead() const { 2600int BScreen::getCurrHead() const {
2609 if (!hasXinerama()) return 0; 2601 if (!hasXinerama()) return 0;
2610 int root_x = 0, root_y = 0; 2602 int root_x = 0, root_y = 0;
diff --git a/src/Screen.hh b/src/Screen.hh
index d156013..7c96a4a 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -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: Screen.hh,v 1.102 2003/05/19 22:45:51 fluxgen Exp $ 25// $Id: Screen.hh,v 1.103 2003/05/20 11:03:10 rathnor Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -137,10 +137,10 @@ public:
137 /* 137 /*
138 maximum screen bounds for given window 138 maximum screen bounds for given window
139 */ 139 */
140 unsigned int maxLeft(const FbTk::FbWindow &win) const; 140 unsigned int maxLeft(int head) const;
141 unsigned int maxRight(const FbTk::FbWindow &win) const; 141 unsigned int maxRight(int head) const;
142 unsigned int maxTop(const FbTk::FbWindow &win) const; 142 unsigned int maxTop(int head) const;
143 unsigned int maxBottom(const FbTk::FbWindow &win) const; 143 unsigned int maxBottom(int head) const;
144 144
145 inline unsigned int width() const { return rootWindow().width(); } 145 inline unsigned int width() const { return rootWindow().width(); }
146 inline unsigned int height() const { return rootWindow().height(); } 146 inline unsigned int height() const { return rootWindow().height(); }
@@ -304,6 +304,7 @@ public:
304 void initXinerama(); 304 void initXinerama();
305 305
306 int getHead(int x, int y) const; 306 int getHead(int x, int y) const;
307 int getHead(FbTk::FbWindow &win) const;
307 int getCurrHead() const; 308 int getCurrHead() const;
308 int getHeadX(int head) const; 309 int getHeadX(int head) const;
309 int getHeadY(int head) const; 310 int getHeadY(int head) const;
diff --git a/src/Window.cc b/src/Window.cc
index 032c4cd..3254b50 100644
--- a/src/Window.cc
+++ b/src/Window.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: Window.cc,v 1.182 2003/05/19 22:43:48 fluxgen Exp $ 25// $Id: Window.cc,v 1.183 2003/05/20 11:03:10 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -1381,16 +1381,17 @@ void FluxboxWindow::maximize() {
1381 1381
1382 if (!maximized) { 1382 if (!maximized) {
1383 // save old values 1383 // save old values
1384 int head = screen().getHead(frame().window());
1384 m_old_width = frame().width(); 1385 m_old_width = frame().width();
1385 m_old_height = frame().height(); 1386 m_old_height = frame().height();
1386 m_old_pos_x = frame().x(); 1387 m_old_pos_x = frame().x();
1387 m_old_pos_y = frame().y(); 1388 m_old_pos_y = frame().y();
1388 unsigned int left_x = screen().maxLeft(frame().window()); 1389 unsigned int left_x = screen().maxLeft(head);
1389 unsigned int max_width = screen().maxRight(frame().window()); 1390 unsigned int max_width = screen().maxRight(head);
1390 unsigned int max_top = screen().maxTop(frame().window()); 1391 unsigned int max_top = screen().maxTop(head);
1391 moveResize(left_x, max_top, 1392 moveResize(left_x, max_top,
1392 max_width - left_x - 2*frame().window().borderWidth(), 1393 max_width - left_x - 2*frame().window().borderWidth(),
1393 screen().maxBottom(frame().window()) - max_top - 2*frame().window().borderWidth()); 1394 screen().maxBottom(head) - max_top - 2*frame().window().borderWidth());
1394 } else { // demaximize, restore to old values 1395 } else { // demaximize, restore to old values
1395 moveResize(m_old_pos_x, m_old_pos_y, 1396 moveResize(m_old_pos_x, m_old_pos_y,
1396 m_old_width, m_old_height); 1397 m_old_width, m_old_height);
@@ -1400,8 +1401,9 @@ void FluxboxWindow::maximize() {
1400} 1401}
1401 1402
1402void FluxboxWindow::maximizeHorizontal() { 1403void FluxboxWindow::maximizeHorizontal() {
1403 unsigned int left_x = screen().maxLeft(frame().window()); 1404 int head = screen().getHead(frame().window());
1404 unsigned int max_width = screen().maxRight(frame().window()); 1405 unsigned int left_x = screen().maxLeft(head);
1406 unsigned int max_width = screen().maxRight(head);
1405 moveResize(left_x, frame().y(), 1407 moveResize(left_x, frame().y(),
1406 max_width - left_x - 2*frame().window().borderWidth(), frame().height()); 1408 max_width - left_x - 2*frame().window().borderWidth(), frame().height());
1407 1409
@@ -1411,10 +1413,11 @@ void FluxboxWindow::maximizeHorizontal() {
1411 Maximize window horizontal 1413 Maximize window horizontal
1412 */ 1414 */
1413void FluxboxWindow::maximizeVertical() { 1415void FluxboxWindow::maximizeVertical() {
1414 unsigned int max_top = screen().maxTop(frame().window()); 1416 int head = screen().getHead(frame().window());
1417 unsigned int max_top = screen().maxTop(head);
1415 moveResize(frame().x(), max_top, 1418 moveResize(frame().x(), max_top,
1416 frame().width(), 1419 frame().width(),
1417 screen().maxBottom(frame().window()) - max_top - 2*frame().window().borderWidth()); 1420 screen().maxBottom(head) - max_top - 2*frame().window().borderWidth());
1418} 1421}
1419 1422
1420 1423
@@ -2899,17 +2902,15 @@ inline void snapToWindow(int &xlimit, int &ylimit,
2899} 2902}
2900 2903
2901/* 2904/*
2902 * Do Whatever snapping magic is necessary, and return using the left and top variables 2905 * Do Whatever snapping magic is necessary, and return using the orig_left
2903 * to indicate the new x,y position 2906 * and orig_top variables to indicate the new x,y position
2904 */ 2907 */
2905void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) { 2908void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
2906 /* 2909 /*
2907 * Snap to screen edge 2910 * Snap to screen/head edges
2908 * Snap to windows 2911 * Snap to windows
2909 * Snap to toolbar 2912 * Snap to toolbar
2910 * Snap to slit 2913 * Snap to slit
2911 * TODO:
2912 * Xinerama screen edge?
2913 */ 2914 */
2914 2915
2915 if (screen().getEdgeSnapThreshold() == 0) return; 2916 if (screen().getEdgeSnapThreshold() == 0) return;
@@ -2928,9 +2929,20 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
2928 int bottom = orig_top + height() + 2*borderW; 2929 int bottom = orig_top + height() + 2*borderW;
2929 2930
2930 ///////////////////////////////////// 2931 /////////////////////////////////////
2931 // begin by checking the screen edges 2932 // begin by checking the screen (or Xinerama head) edges
2932 2933
2933 snapToWindow(dx, dy, left, right, top, bottom, 0, screen().width(), 0, screen().height()); 2934 if (screen().hasXinerama()) {
2935 // head "0" == whole screen width + height, which we skip since the
2936 // sum of all the heads covers those edges
2937 for (int h = 1; h <= screen().numHeads(); h++) {
2938 snapToWindow(dx, dy, left, right, top, bottom,
2939 screen().maxLeft(h),
2940 screen().maxRight(h),
2941 screen().maxTop(h),
2942 screen().maxBottom(h));
2943 }
2944 } else
2945 snapToWindow(dx, dy, left, right, top, bottom, 0, screen().width(), 0, screen().height());
2934 2946
2935 ///////////////////////////////////// 2947 /////////////////////////////////////
2936 // now check window edges 2948 // now check window edges
diff --git a/src/Workspace.cc b/src/Workspace.cc
index db0cac2..2bf2450 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.67 2003/05/19 15:32:47 rathnor Exp $ 25// $Id: Workspace.cc,v 1.68 2003/05/20 11:03:11 rathnor Exp $
26 26
27#include "Workspace.hh" 27#include "Workspace.hh"
28 28
@@ -479,7 +479,14 @@ void Workspace::placeWindow(FluxboxWindow &win) {
479 479
480 bool placed = false; 480 bool placed = false;
481 481
482 int place_x = 0, place_y = 0, change_x = 1, change_y = 1; 482 // restrictions
483 int head = (signed) screen().getCurrHead();
484 int head_left = (signed) screen().maxLeft(head);
485 int head_right = (signed) screen().maxRight(head);
486 int head_top = (signed) screen().maxTop(head);
487 int head_bot = (signed) screen().maxBottom(head);
488
489 int place_x = head_left, place_y = head_top, change_x = 1, change_y = 1;
483 490
484 if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) 491 if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP)
485 change_y = -1; 492 change_y = -1;
@@ -494,7 +501,7 @@ void Workspace::placeWindow(FluxboxWindow &win) {
494 501
495 switch (screen().getPlacementPolicy()) { 502 switch (screen().getPlacementPolicy()) {
496 case BScreen::UNDERMOUSEPLACEMENT: { 503 case BScreen::UNDERMOUSEPLACEMENT: {
497 int root_x, root_y, min_y, min_x, max_y, max_x, ignore_i; 504 int root_x, root_y, ignore_i;
498 505
499 unsigned int ignore_ui; 506 unsigned int ignore_ui;
500 507
@@ -508,24 +515,19 @@ void Workspace::placeWindow(FluxboxWindow &win) {
508 test_x = root_x - (win_w / 2); 515 test_x = root_x - (win_w / 2);
509 test_y = root_y - (win_h / 2); 516 test_y = root_y - (win_h / 2);
510 517
511 min_x = (int) screen().maxLeft(win.frame().window());
512 min_y = (int) screen().maxTop(win.frame().window());
513 max_x = (int) screen().maxRight(win.frame().window()) - win_w;
514 max_y = (int) screen().maxBottom(win.frame().window()) - win_h;
515
516 // keep the window inside the screen 518 // keep the window inside the screen
517 519
518 if (test_x < min_x) 520 if (test_x < head_left)
519 test_x = min_x; 521 test_x = head_left;
520 522
521 if (test_x > max_x) 523 if (test_x > head_right)
522 test_x = max_x; 524 test_x = head_right;
523 525
524 if (test_y < min_y) 526 if (test_y < head_top)
525 test_y = min_y; 527 test_y = head_top;
526 528
527 if (test_y > max_y) 529 if (test_y > head_bot)
528 test_y = max_y; 530 test_y = head_bot;
529 531
530 place_x = test_x; 532 place_x = test_x;
531 place_y = test_y; 533 place_y = test_y;
@@ -540,21 +542,21 @@ void Workspace::placeWindow(FluxboxWindow &win) {
540 test_y = 0; 542 test_y = 0;
541 543
542 if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) 544 if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP)
543 test_y = screen().height() - win_h - test_y; 545 test_y = head_bot - win_h - test_y;
544 546
545 547
546 while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ? 548 while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ?
547 test_y > 0 : test_y + win_h < (signed) screen().height()) && 549 test_y > 0 : test_y + win_h < head_bot) &&
548 ! placed) { 550 ! placed) {
549 551
550 test_x = 0; 552 test_x = 0;
551 553
552 if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) 554 if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT)
553 test_x = screen().width() - win_w - test_x; 555 test_x = head_right - win_w - test_x;
554 556
555 557
556 while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ? 558 while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ?
557 test_x > 0 : test_x + win_w < (signed) screen().width()) && ! placed) { 559 test_x > 0 : test_x + win_w < head_right) && ! placed) {
558 560
559 placed = true; 561 placed = true;
560 562
@@ -596,23 +598,21 @@ void Workspace::placeWindow(FluxboxWindow &win) {
596 } // end case ROWSMARTPLACEMENT 598 } // end case ROWSMARTPLACEMENT
597 599
598 case BScreen::COLSMARTPLACEMENT: { 600 case BScreen::COLSMARTPLACEMENT: {
599 test_x = 0; 601 test_x = head_left;
600 602
601 if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) 603 if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT)
602 604 test_x = head_right - win_w;
603 test_x = screen().width() - win_w - test_x;
604
605 605
606 while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ? 606 while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ?
607 test_x > 0 : test_x + win_w < (signed) screen().width()) && 607 test_x > head_left : test_x + win_w < head_right) &&
608 !placed) { 608 !placed) {
609 609
610 test_y = 0; 610 test_y = head_top;
611 if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) 611 if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP)
612 test_y = screen().height() - win_h - test_y; 612 test_y = head_bot - win_h;
613 613
614 while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ? 614 while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ?
615 test_y > 0 : test_y + win_h < (signed) screen().height()) && 615 test_y > head_top : test_y + win_h < head_bot) &&
616 !placed) { 616 !placed) {
617 placed = True; 617 placed = True;
618 618
@@ -657,8 +657,8 @@ void Workspace::placeWindow(FluxboxWindow &win) {
657 // cascade placement or smart placement failed 657 // cascade placement or smart placement failed
658 if (! placed) { 658 if (! placed) {
659 659
660 if (((unsigned) m_cascade_x > (screen().width() / 2)) || 660 if ((m_cascade_x > ((head_left + head_right) / 2)) ||
661 ((unsigned) m_cascade_y > (screen().height() / 2))) 661 (m_cascade_y > ((head_top + head_bot) / 2)))
662 m_cascade_x = m_cascade_y = 32; 662 m_cascade_x = m_cascade_y = 32;
663 663
664 place_x = m_cascade_x; 664 place_x = m_cascade_x;
@@ -668,10 +668,10 @@ void Workspace::placeWindow(FluxboxWindow &win) {
668 m_cascade_y += win.titleHeight(); 668 m_cascade_y += win.titleHeight();
669 } 669 }
670 670
671 if (place_x + win_w > (signed) screen().width()) 671 if (place_x + win_w > head_right)
672 place_x = (((signed) screen().width()) - win_w) / 2; 672 place_x = (head_right - win_w) / 2;
673 if (place_y + win_h > (signed) screen().height()) 673 if (place_y + win_h > head_bot)
674 place_y = (((signed) screen().height()) - win_h) / 2; 674 place_y = (head_bot - win_h) / 2;
675 675
676 676
677 win.moveResize(place_x, place_y, win.width(), win.height()); 677 win.moveResize(place_x, place_y, win.width(), win.height());