summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Screen.cc72
-rw-r--r--src/Screen.hh14
2 files changed, 74 insertions, 12 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 {
783unsigned int BScreen::maxLeft(int head) const { 786unsigned 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
790unsigned int BScreen::maxRight(int head) const { 793unsigned 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
797unsigned int BScreen::maxTop(int head) const { 800unsigned 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
804unsigned int BScreen::maxBottom(int head) const { 807unsigned 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
811void BScreen::reconfigure() { 814void BScreen::reconfigure() {
@@ -1443,6 +1446,55 @@ void BScreen::setupWindowActions(FluxboxWindow &win) {
1443 1446
1444} 1447}
1445 1448
1449Strut *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
1455void 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()
1469namespace {
1470class MaxArea {
1471public:
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 }
1481private:
1482 Strut &m_max_area;
1483};
1484
1485}; // end anonymous namespace
1486
1487void 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
1447void BScreen::saveStrftimeFormat(const char *format) { 1499void 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
diff --git a/src/Screen.hh b/src/Screen.hh
index a90ca29..9a16597 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.105 2003/06/15 11:37:53 rathnor Exp $ 25// $Id: Screen.hh,v 1.106 2003/06/18 13:42:21 fluxgen Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -52,6 +52,7 @@ class RootTheme;
52class WinButtonTheme; 52class WinButtonTheme;
53class WinClient; 53class WinClient;
54class Workspace; 54class Workspace;
55class Strut;
55 56
56namespace FbTk { 57namespace FbTk {
57class MenuTheme; 58class MenuTheme;
@@ -69,7 +70,7 @@ class BScreen : private FbTk::NotCopyable {
69public: 70public:
70 typedef std::vector<Workspace *> Workspaces; 71 typedef std::vector<Workspace *> Workspaces;
71 typedef std::vector<std::string> WorkspaceNames; 72 typedef std::vector<std::string> WorkspaceNames;
72 73
73 BScreen(FbTk::ResourceManager &rm, 74 BScreen(FbTk::ResourceManager &rm,
74 const std::string &screenname, const std::string &altscreenname, 75 const std::string &screenname, const std::string &altscreenname,
75 int scrn, int number_of_layers); 76 int scrn, int number_of_layers);
@@ -334,6 +335,12 @@ public:
334 FluxboxWindow *createWindow(Window clientwin); 335 FluxboxWindow *createWindow(Window clientwin);
335 FluxboxWindow *createWindow(WinClient &client); 336 FluxboxWindow *createWindow(WinClient &client);
336 void setupWindowActions(FluxboxWindow &win); 337 void setupWindowActions(FluxboxWindow &win);
338 /// request workspace space, i.e "don't maximize over this area"
339 Strut *requestStrut(int left, int right, int top, int bottom);
340 /// remove requested space and destroy strut
341 void clearStrut(Strut *strut);
342 /// updates max avaible area for the workspace
343 void updateAvailableWorkspaceArea();
337 344
338 enum { ROWSMARTPLACEMENT = 1, COLSMARTPLACEMENT, CASCADEPLACEMENT, 345 enum { ROWSMARTPLACEMENT = 1, COLSMARTPLACEMENT, CASCADEPLACEMENT,
339 UNDERMOUSEPLACEMENT, LEFTRIGHT, RIGHTLEFT, TOPBOTTOM, BOTTOMTOP }; 346 UNDERMOUSEPLACEMENT, LEFTRIGHT, RIGHTLEFT, TOPBOTTOM, BOTTOMTOP };
@@ -456,10 +463,13 @@ private:
456 463
457 int m_xinerama_center_x, m_xinerama_center_y; 464 int m_xinerama_center_x, m_xinerama_center_y;
458 465
466 std::auto_ptr<Strut> m_available_workspace_area;
467
459 struct XineramaHeadInfo { 468 struct XineramaHeadInfo {
460 int x, y, width, height; 469 int x, y, width, height;
461 } *m_xinerama_headinfo; 470 } *m_xinerama_headinfo;
462 471
472 std::list<Strut *> m_strutlist;
463}; 473};
464 474
465 475