From a88511a4a772ec021029649905b7ce645ff9a597 Mon Sep 17 00:00:00 2001 From: rathnor Date: Tue, 20 May 2003 11:03:11 +0000 Subject: xinerama for placement + snapping, + tidy --- ChangeLog | 3 +++ RoadMap | 2 +- src/Screen.cc | 50 +++++++++++++++++------------------------ src/Screen.hh | 11 ++++----- src/Window.cc | 46 ++++++++++++++++++++++++-------------- src/Workspace.cc | 68 ++++++++++++++++++++++++++++---------------------------- 6 files changed, 94 insertions(+), 86 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3390ad7..dd57890 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.3: +*03/05/20: + * Add xinerama for placement and snapping, plus tidy (Simon) + Screen.hh/cc Window.cc Workspace.cc *03/05/19: * Clean + change xinerama, plus add maximize smarts (Simon) Screen.hh/cc Window.cc Workspace.cc Toolbar.cc Slit.cc diff --git a/RoadMap b/RoadMap index cf1457b..14a717b 100644 --- a/RoadMap +++ b/RoadMap @@ -117,7 +117,7 @@ Bugfixes/lower priority: Release: 0.9.3 Approx Date: 26 May, 2003 Major Features: - = Xinerama (Simon) + * Xinerama (Simon) * XRandr (Henrik) Minor Features: - Add some sort of program launch function (Simon) 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.174 2003/05/19 22:45:17 fluxgen Exp $ +// $Id: Screen.cc,v 1.175 2003/05/20 11:03:10 rathnor Exp $ #include "Screen.hh" @@ -808,47 +808,31 @@ Pixmap BScreen::rootPixmap() const { } -unsigned int BScreen::maxLeft(const FbTk::FbWindow &win) const { - if (hasXinerama()) { - int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); - // we MUST use a head, we use the center of the window, or if that - // isn't in a head, then the mouse's head - if (head == 0) head = getCurrHead(); +unsigned int BScreen::maxLeft(int head) const { + if (hasXinerama()) return getHeadX(head); - } else + else return 0; } -unsigned int BScreen::maxRight(const FbTk::FbWindow &win) const { - if (hasXinerama()) { - int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); - // we MUST use a head, we use the center of the window, or if that - // isn't in a head, then the mouse's head - if (head == 0) head = getCurrHead(); +unsigned int BScreen::maxRight(int head) const { + if (hasXinerama()) return getHeadX(head) + getHeadWidth(head); - } else + else return width(); } -unsigned int BScreen::maxTop(const FbTk::FbWindow &win) const { - if (hasXinerama()) { - int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); - // we MUST use a head, we use the center of the window, or if that - // isn't in a head, then the mouse's head - if (head == 0) head = getCurrHead(); +unsigned int BScreen::maxTop(int head) const { + if (hasXinerama()) return getHeadY(head); - } else + else return 0; } -unsigned int BScreen::maxBottom(const FbTk::FbWindow &win) const { - if (hasXinerama()) { - int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); - // we MUST use a head, we use the center of the window, or if that - // isn't in a head, then the mouse's head - if (head == 0) head = getCurrHead(); +unsigned int BScreen::maxBottom(int head) const { + if (hasXinerama()) return getHeadY(head) + getHeadHeight(head); - } else + else return height(); } @@ -2605,6 +2589,14 @@ int BScreen::getHead(int x, int y) const { return 0; } +int BScreen::getHead(FbTk::FbWindow &win) const { + if (hasXinerama()) + return getHead(win.x() + win.width()/2, win.y() + win.height()/2); + else + return 0; +} + + int BScreen::getCurrHead() const { if (!hasXinerama()) return 0; 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.102 2003/05/19 22:45:51 fluxgen Exp $ +// $Id: Screen.hh,v 1.103 2003/05/20 11:03:10 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -137,10 +137,10 @@ public: /* maximum screen bounds for given window */ - unsigned int maxLeft(const FbTk::FbWindow &win) const; - unsigned int maxRight(const FbTk::FbWindow &win) const; - unsigned int maxTop(const FbTk::FbWindow &win) const; - unsigned int maxBottom(const FbTk::FbWindow &win) const; + unsigned int maxLeft(int head) const; + unsigned int maxRight(int head) const; + unsigned int maxTop(int head) const; + unsigned int maxBottom(int head) const; inline unsigned int width() const { return rootWindow().width(); } inline unsigned int height() const { return rootWindow().height(); } @@ -304,6 +304,7 @@ public: void initXinerama(); int getHead(int x, int y) const; + int getHead(FbTk::FbWindow &win) const; int getCurrHead() const; int getHeadX(int head) const; 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.182 2003/05/19 22:43:48 fluxgen Exp $ +// $Id: Window.cc,v 1.183 2003/05/20 11:03:10 rathnor Exp $ #include "Window.hh" @@ -1381,16 +1381,17 @@ void FluxboxWindow::maximize() { if (!maximized) { // save old values + int head = screen().getHead(frame().window()); m_old_width = frame().width(); m_old_height = frame().height(); m_old_pos_x = frame().x(); m_old_pos_y = frame().y(); - unsigned int left_x = screen().maxLeft(frame().window()); - unsigned int max_width = screen().maxRight(frame().window()); - unsigned int max_top = screen().maxTop(frame().window()); + unsigned int left_x = screen().maxLeft(head); + unsigned int max_width = screen().maxRight(head); + unsigned int max_top = screen().maxTop(head); moveResize(left_x, max_top, max_width - left_x - 2*frame().window().borderWidth(), - screen().maxBottom(frame().window()) - max_top - 2*frame().window().borderWidth()); + screen().maxBottom(head) - max_top - 2*frame().window().borderWidth()); } else { // demaximize, restore to old values moveResize(m_old_pos_x, m_old_pos_y, m_old_width, m_old_height); @@ -1400,8 +1401,9 @@ void FluxboxWindow::maximize() { } void FluxboxWindow::maximizeHorizontal() { - unsigned int left_x = screen().maxLeft(frame().window()); - unsigned int max_width = screen().maxRight(frame().window()); + int head = screen().getHead(frame().window()); + unsigned int left_x = screen().maxLeft(head); + unsigned int max_width = screen().maxRight(head); moveResize(left_x, frame().y(), max_width - left_x - 2*frame().window().borderWidth(), frame().height()); @@ -1411,10 +1413,11 @@ void FluxboxWindow::maximizeHorizontal() { Maximize window horizontal */ void FluxboxWindow::maximizeVertical() { - unsigned int max_top = screen().maxTop(frame().window()); + int head = screen().getHead(frame().window()); + unsigned int max_top = screen().maxTop(head); moveResize(frame().x(), max_top, frame().width(), - screen().maxBottom(frame().window()) - max_top - 2*frame().window().borderWidth()); + screen().maxBottom(head) - max_top - 2*frame().window().borderWidth()); } @@ -2899,17 +2902,15 @@ inline void snapToWindow(int &xlimit, int &ylimit, } /* - * Do Whatever snapping magic is necessary, and return using the left and top variables - * to indicate the new x,y position + * Do Whatever snapping magic is necessary, and return using the orig_left + * and orig_top variables to indicate the new x,y position */ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) { /* - * Snap to screen edge + * Snap to screen/head edges * Snap to windows * Snap to toolbar * Snap to slit - * TODO: - * Xinerama screen edge? */ if (screen().getEdgeSnapThreshold() == 0) return; @@ -2928,9 +2929,20 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) { int bottom = orig_top + height() + 2*borderW; ///////////////////////////////////// - // begin by checking the screen edges - - snapToWindow(dx, dy, left, right, top, bottom, 0, screen().width(), 0, screen().height()); + // begin by checking the screen (or Xinerama head) edges + + if (screen().hasXinerama()) { + // head "0" == whole screen width + height, which we skip since the + // sum of all the heads covers those edges + for (int h = 1; h <= screen().numHeads(); h++) { + snapToWindow(dx, dy, left, right, top, bottom, + screen().maxLeft(h), + screen().maxRight(h), + screen().maxTop(h), + screen().maxBottom(h)); + } + } else + snapToWindow(dx, dy, left, right, top, bottom, 0, screen().width(), 0, screen().height()); ///////////////////////////////////// // 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.67 2003/05/19 15:32:47 rathnor Exp $ +// $Id: Workspace.cc,v 1.68 2003/05/20 11:03:11 rathnor Exp $ #include "Workspace.hh" @@ -479,7 +479,14 @@ void Workspace::placeWindow(FluxboxWindow &win) { bool placed = false; - int place_x = 0, place_y = 0, change_x = 1, change_y = 1; + // restrictions + int head = (signed) screen().getCurrHead(); + int head_left = (signed) screen().maxLeft(head); + int head_right = (signed) screen().maxRight(head); + int head_top = (signed) screen().maxTop(head); + int head_bot = (signed) screen().maxBottom(head); + + int place_x = head_left, place_y = head_top, change_x = 1, change_y = 1; if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) change_y = -1; @@ -494,7 +501,7 @@ void Workspace::placeWindow(FluxboxWindow &win) { switch (screen().getPlacementPolicy()) { case BScreen::UNDERMOUSEPLACEMENT: { - int root_x, root_y, min_y, min_x, max_y, max_x, ignore_i; + int root_x, root_y, ignore_i; unsigned int ignore_ui; @@ -508,24 +515,19 @@ void Workspace::placeWindow(FluxboxWindow &win) { test_x = root_x - (win_w / 2); test_y = root_y - (win_h / 2); - min_x = (int) screen().maxLeft(win.frame().window()); - min_y = (int) screen().maxTop(win.frame().window()); - max_x = (int) screen().maxRight(win.frame().window()) - win_w; - max_y = (int) screen().maxBottom(win.frame().window()) - win_h; - // keep the window inside the screen - if (test_x < min_x) - test_x = min_x; + if (test_x < head_left) + test_x = head_left; - if (test_x > max_x) - test_x = max_x; + if (test_x > head_right) + test_x = head_right; - if (test_y < min_y) - test_y = min_y; + if (test_y < head_top) + test_y = head_top; - if (test_y > max_y) - test_y = max_y; + if (test_y > head_bot) + test_y = head_bot; place_x = test_x; place_y = test_y; @@ -540,21 +542,21 @@ void Workspace::placeWindow(FluxboxWindow &win) { test_y = 0; if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) - test_y = screen().height() - win_h - test_y; + test_y = head_bot - win_h - test_y; while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ? - test_y > 0 : test_y + win_h < (signed) screen().height()) && + test_y > 0 : test_y + win_h < head_bot) && ! placed) { test_x = 0; if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) - test_x = screen().width() - win_w - test_x; + test_x = head_right - win_w - test_x; while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ? - test_x > 0 : test_x + win_w < (signed) screen().width()) && ! placed) { + test_x > 0 : test_x + win_w < head_right) && ! placed) { placed = true; @@ -596,23 +598,21 @@ void Workspace::placeWindow(FluxboxWindow &win) { } // end case ROWSMARTPLACEMENT case BScreen::COLSMARTPLACEMENT: { - test_x = 0; + test_x = head_left; if (screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) - - test_x = screen().width() - win_w - test_x; - + test_x = head_right - win_w; while (((screen().getRowPlacementDirection() == BScreen::RIGHTLEFT) ? - test_x > 0 : test_x + win_w < (signed) screen().width()) && + test_x > head_left : test_x + win_w < head_right) && !placed) { - test_y = 0; + test_y = head_top; if (screen().getColPlacementDirection() == BScreen::BOTTOMTOP) - test_y = screen().height() - win_h - test_y; + test_y = head_bot - win_h; while (((screen().getColPlacementDirection() == BScreen::BOTTOMTOP) ? - test_y > 0 : test_y + win_h < (signed) screen().height()) && + test_y > head_top : test_y + win_h < head_bot) && !placed) { placed = True; @@ -657,8 +657,8 @@ void Workspace::placeWindow(FluxboxWindow &win) { // cascade placement or smart placement failed if (! placed) { - if (((unsigned) m_cascade_x > (screen().width() / 2)) || - ((unsigned) m_cascade_y > (screen().height() / 2))) + if ((m_cascade_x > ((head_left + head_right) / 2)) || + (m_cascade_y > ((head_top + head_bot) / 2))) m_cascade_x = m_cascade_y = 32; place_x = m_cascade_x; @@ -668,10 +668,10 @@ void Workspace::placeWindow(FluxboxWindow &win) { m_cascade_y += win.titleHeight(); } - if (place_x + win_w > (signed) screen().width()) - place_x = (((signed) screen().width()) - win_w) / 2; - if (place_y + win_h > (signed) screen().height()) - place_y = (((signed) screen().height()) - win_h) / 2; + if (place_x + win_w > head_right) + place_x = (head_right - win_w) / 2; + if (place_y + win_h > head_bot) + place_y = (head_bot - win_h) / 2; win.moveResize(place_x, place_y, win.width(), win.height()); -- cgit v0.11.2