diff options
author | fluxgen <fluxgen> | 2003-06-18 13:42:21 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-06-18 13:42:21 (GMT) |
commit | b373962b76db06f59c04e504a8c93084607fe13d (patch) | |
tree | f5f3a3907329a0e9736ce9328be2bffe99a763c8 /src/Screen.cc | |
parent | 1314a15988c3d922cb8dd45807b0cea449ff9a5a (diff) | |
download | fluxbox-b373962b76db06f59c04e504a8c93084607fe13d.zip fluxbox-b373962b76db06f59c04e504a8c93084607fe13d.tar.bz2 |
Strut support
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 6db0e0d..df272f2 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.184 2003/06/15 20:09:13 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.185 2003/06/18 13:42:21 fluxgen Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -54,6 +54,7 @@ | |||
54 | #include "Subject.hh" | 54 | #include "Subject.hh" |
55 | #include "FbWinFrame.hh" | 55 | #include "FbWinFrame.hh" |
56 | #include "FbWindow.hh" | 56 | #include "FbWindow.hh" |
57 | #include "Strut.hh" | ||
57 | 58 | ||
58 | //use GNU extensions | 59 | //use GNU extensions |
59 | #ifndef _GNU_SOURCE | 60 | #ifndef _GNU_SOURCE |
@@ -521,7 +522,9 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
521 | *resource.rootcommand)), | 522 | *resource.rootcommand)), |
522 | m_root_window(scrn), | 523 | m_root_window(scrn), |
523 | resource(rm, screenname, altscreenname), | 524 | resource(rm, screenname, altscreenname), |
524 | m_toolbarhandler(0) { | 525 | m_toolbarhandler(0), |
526 | m_available_workspace_area(new Strut(0, 0, 0, 0)), | ||
527 | m_xinerama_headinfo(0) { | ||
525 | 528 | ||
526 | Display *disp = FbTk::App::instance()->display(); | 529 | Display *disp = FbTk::App::instance()->display(); |
527 | 530 | ||
@@ -783,29 +786,29 @@ Pixmap BScreen::rootPixmap() const { | |||
783 | unsigned int BScreen::maxLeft(int head) const { | 786 | unsigned int BScreen::maxLeft(int head) const { |
784 | if (hasXinerama()) | 787 | if (hasXinerama()) |
785 | return getHeadX(head); | 788 | return getHeadX(head); |
786 | else | 789 | else // we ignore strut if we're doing full maximization |
787 | return 0; | 790 | return doFullMax() ? 0 : m_available_workspace_area->left(); |
788 | } | 791 | } |
789 | 792 | ||
790 | unsigned int BScreen::maxRight(int head) const { | 793 | unsigned int BScreen::maxRight(int head) const { |
791 | if (hasXinerama()) | 794 | if (hasXinerama()) |
792 | return getHeadX(head) + getHeadWidth(head); | 795 | return getHeadX(head) + getHeadWidth(head); |
793 | else | 796 | else // we ignore strut if we're doing full maximization |
794 | return width(); | 797 | return doFullMax() ? width() : width() - m_available_workspace_area->right(); |
795 | } | 798 | } |
796 | 799 | ||
797 | unsigned int BScreen::maxTop(int head) const { | 800 | unsigned int BScreen::maxTop(int head) const { |
798 | if (hasXinerama()) | 801 | if (hasXinerama()) |
799 | return getHeadY(head); | 802 | return getHeadY(head); |
800 | else | 803 | else // we ignore strut if we're doing full maximization |
801 | return 0; | 804 | return doFullMax() ? 0 : m_available_workspace_area->top(); |
802 | } | 805 | } |
803 | 806 | ||
804 | unsigned int BScreen::maxBottom(int head) const { | 807 | unsigned int BScreen::maxBottom(int head) const { |
805 | if (hasXinerama()) | 808 | if (hasXinerama()) |
806 | return getHeadY(head) + getHeadHeight(head); | 809 | return getHeadY(head) + getHeadHeight(head); |
807 | else | 810 | else // we ignore strut if we're doing full maximization |
808 | return height(); | 811 | return doFullMax() ? height() : height() - m_available_workspace_area->bottom(); |
809 | } | 812 | } |
810 | 813 | ||
811 | void BScreen::reconfigure() { | 814 | void BScreen::reconfigure() { |
@@ -1443,6 +1446,55 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1443 | 1446 | ||
1444 | } | 1447 | } |
1445 | 1448 | ||
1449 | Strut *BScreen::requestStrut(int left, int right, int top, int bottom) { | ||
1450 | Strut *str = new Strut(left, right, top, bottom); | ||
1451 | m_strutlist.push_back(str); | ||
1452 | return str; | ||
1453 | } | ||
1454 | |||
1455 | void BScreen::clearStrut(Strut *str) { | ||
1456 | if (str == 0) | ||
1457 | return; | ||
1458 | // find strut and erase it | ||
1459 | std::list<Strut *>::iterator pos = find(m_strutlist.begin(), | ||
1460 | m_strutlist.end(), | ||
1461 | str); | ||
1462 | if (pos == m_strutlist.end()) | ||
1463 | return; | ||
1464 | m_strutlist.erase(pos); | ||
1465 | delete str; | ||
1466 | } | ||
1467 | |||
1468 | /// helper class for for_each in BScreen::updateAvailableWorkspaceArea() | ||
1469 | namespace { | ||
1470 | class MaxArea { | ||
1471 | public: | ||
1472 | MaxArea(Strut &max_area):m_max_area(max_area) { } | ||
1473 | void operator ()(const Strut *str) { | ||
1474 | static int left, right, bottom, top; | ||
1475 | left = std::max(m_max_area.left(), str->left()); | ||
1476 | right = std::max(m_max_area.right(), str->right()); | ||
1477 | bottom = std::max(m_max_area.bottom(), str->bottom()); | ||
1478 | top = std::max(m_max_area.top(), str->top()); | ||
1479 | m_max_area = Strut(left, right, top, bottom); | ||
1480 | } | ||
1481 | private: | ||
1482 | Strut &m_max_area; | ||
1483 | }; | ||
1484 | |||
1485 | }; // end anonymous namespace | ||
1486 | |||
1487 | void BScreen::updateAvailableWorkspaceArea() { | ||
1488 | // find max of left, right, top and bottom and set avaible workspace area | ||
1489 | |||
1490 | // clear old area | ||
1491 | m_available_workspace_area.reset(new Strut(0, 0, 0, 0)); | ||
1492 | |||
1493 | // calculate max area | ||
1494 | for_each(m_strutlist.begin(), | ||
1495 | m_strutlist.end(), | ||
1496 | MaxArea(*m_available_workspace_area.get())); | ||
1497 | } | ||
1446 | 1498 | ||
1447 | void BScreen::saveStrftimeFormat(const char *format) { | 1499 | void BScreen::saveStrftimeFormat(const char *format) { |
1448 | //make sure std::string don't get 0 string | 1500 | //make sure std::string don't get 0 string |