]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
don't click-to-place windows when they specify a position
[chaz/openbox] / src / Screen.cc
index 1de7c0bfb837958bee3a67ba6f73f5aa5842b9e2..2c46a836b6d2b587cd7ae5768f49b692348856ff 100644 (file)
@@ -49,6 +49,7 @@
 #include "Window.h"
 #include "Workspace.h"
 #include "Workspacemenu.h"
+#include "Util.h"
 
 #ifdef    HAVE_STDLIB_H
 #  include <stdlib.h>
@@ -589,6 +590,108 @@ BScreen::~BScreen(void) {
          resource.tstyle.b_pic_gc);
 }
 
+
+Rect BScreen::availableArea() const {
+  // the following code is temporary and will be taken care of by Screen in the
+  // future (with the NETWM 'strut')
+  Rect space(0, 0, size().w(), size().h());
+  if (!resource.full_max) {
+#ifdef    SLIT
+    int slit_x = slit->autoHide() ? slit->hiddenOrigin().x() : slit->area().x(),
+    slit_y = slit->autoHide() ? slit->hiddenOrigin().y() : slit->area().y();
+    int tbarh = resource.hide_toolbar ? 0 :
+      toolbar->getExposedHeight() + resource.border_width * 2;
+    bool tbartop;
+    switch (toolbar->placement()) {
+    case Toolbar::TopLeft:
+    case Toolbar::TopCenter:
+    case Toolbar::TopRight:
+      tbartop = true;
+      break;
+    case Toolbar::BottomLeft:
+    case Toolbar::BottomCenter:
+    case Toolbar::BottomRight:
+      tbartop = false;
+      break;
+    default:
+      ASSERT(false);      // unhandled placement
+    }
+    if ((slit->direction() == Slit::Horizontal &&
+         (slit->placement() == Slit::TopLeft ||
+          slit->placement() == Slit::TopRight)) ||
+        slit->placement() == Slit::TopCenter) {
+      // exclude top
+      if (tbartop && slit_y + slit->area().h() < tbarh) {
+        space.setY(space.y() + tbarh);
+        space.setH(space.h() - tbarh);
+      } else {
+        space.setY(space.y() + (slit_y + slit->area().h() +
+                                resource.border_width * 2));
+        space.setH(space.h() - (slit_y + slit->area().h() +
+                                resource.border_width * 2));
+        if (!tbartop)
+          space.setH(space.h() - tbarh);
+      }
+    } else if ((slit->direction() == Slit::Vertical &&
+                (slit->placement() == Slit::TopRight ||
+                 slit->placement() == Slit::BottomRight)) ||
+               slit->placement() == Slit::CenterRight) {
+      // exclude right
+      space.setW(space.w() - (size().w() - slit_x));
+      if (tbartop)
+        space.setY(space.y() + tbarh);
+      space.setH(space.h() - tbarh);
+    } else if ((slit->direction() == Slit::Horizontal &&
+                (slit->placement() == Slit::BottomLeft ||
+                 slit->placement() == Slit::BottomRight)) ||
+               slit->placement() == Slit::BottomCenter) {
+      // exclude bottom
+      if (!tbartop && (size().h() - slit_y) < tbarh) {
+        space.setH(space.h() - tbarh);
+      } else {
+        space.setH(space.h() - (size().h() - slit_y));
+        if (tbartop) {
+          space.setY(space.y() + tbarh);
+          space.setH(space.h() - tbarh);
+        }
+      }
+    } else {// if ((slit->direction() == Slit::Vertical &&
+      //      (slit->placement() == Slit::TopLeft ||
+      //       slit->placement() == Slit::BottomLeft)) ||
+      //     slit->placement() == Slit::CenterLeft)
+      // exclude left
+      space.setX(slit_x + slit->area().w() +
+                 resource.border_width * 2);
+      space.setW(space.w() - (slit_x + slit->area().w() +
+                              resource.border_width * 2));
+      if (tbartop)
+        space.setY(space.y() + tbarh);
+      space.setH(space.h() - tbarh);
+    }
+#else // !SLIT
+    int tbarh = resource.hide_toolbar() ? 0 :
+      toolbar->getExposedHeight() + resource.border_width * 2;
+    switch (toolbar->placement()) {
+    case Toolbar::TopLeft:
+    case Toolbar::TopCenter:
+    case Toolbar::TopRight:
+      space.setY(toolbar->getExposedHeight());
+      space.setH(space.h() - toolbar->getExposedHeight());
+      break;
+    case Toolbar::BottomLeft:
+    case Toolbar::BottomCenter:
+    case Toolbar::BottomRight:
+      space.setH(space.h() - tbarh);
+      break;
+    default:
+      ASSERT(false);      // unhandled placement
+    }
+#endif // SLIT
+  }
+  return space;
+}
+
+
 void BScreen::readDatabaseTexture(const char *rname, const char *rclass,
                                  BTexture *texture,
                                  unsigned long default_pixel)
@@ -923,6 +1026,8 @@ void BScreen::setPlacementPolicy(int p) {
   case CascadePlacement: placement = "CascadePlacement"; break;
   case BestFitPlacement: placement = "BestFitPlacement"; break;
   case ColSmartPlacement: placement = "ColSmartPlacement"; break;
+  case UnderMousePlacement: placement = "UnderMousePlacement"; break;
+  case ClickMousePlacement: placement = "ClickMousePlacement"; break;
   default:
   case RowSmartPlacement: placement = "RowSmartPlacement"; break;
   }
@@ -1117,7 +1222,7 @@ void BScreen::load() {
   if (config.getValue(rname.str(), rclass.str(), s)) {
     if (0 == strncasecmp(s.c_str(), "RightToLeft", s.length()))
       resource.row_direction = RightLeft;
-    else if (0 == strncasecmp(s.c_str(), "LeftToRight", s.length()))
+    else //if (0 == strncasecmp(s.c_str(), "LeftToRight", s.length()))
       resource.row_direction = LeftRight;
   } else
     resource.row_direction = LeftRight;
@@ -1128,7 +1233,7 @@ void BScreen::load() {
   if (config.getValue(rname.str(), rclass.str(), s)) {
     if (0 == strncasecmp(s.c_str(), "BottomToTop", s.length()))
       resource.col_direction = BottomTop;
-    else if (0 == strncasecmp(s.c_str(), "TopToBottom", s.length()))
+    else //if (0 == strncasecmp(s.c_str(), "TopToBottom", s.length()))
       resource.col_direction = TopBottom;
   } else
     resource.col_direction = TopBottom;
@@ -1169,7 +1274,7 @@ void BScreen::load() {
                                 s.length())) {
       resource.sloppy_focus = true;
       resource.auto_raise = true;
-    } else if (0 == strncasecmp(s.c_str(), "SloppyFocus", s.length())) {
+    } else { //if (0 == strncasecmp(s.c_str(), "SloppyFocus", s.length())) {
       resource.sloppy_focus = true;
       resource.auto_raise = false;
     }
@@ -1196,7 +1301,11 @@ void BScreen::load() {
       resource.placement_policy = ColSmartPlacement;
     else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length()))
       resource.placement_policy = BestFitPlacement;
-    else if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
+    else if (0 == strncasecmp(s.c_str(), "UnderMousePlacement", s.length()))
+      resource.placement_policy = UnderMousePlacement;
+    else if (0 == strncasecmp(s.c_str(), "ClickMousePlacement", s.length()))
+      resource.placement_policy = ClickMousePlacement;
+    else //if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
       resource.placement_policy = CascadePlacement;
   } else
     resource.placement_policy = CascadePlacement;
@@ -1220,7 +1329,7 @@ void BScreen::load() {
   if (config.getValue(rname.str(), rclass.str(), s)) {
     if (strncasecmp(s.c_str(), "European", s.length()))
       resource.date_format = B_EuropeanDate;
-    else if (strncasecmp(s.c_str(), "American", s.length()))
+    else //if (strncasecmp(s.c_str(), "American", s.length()))
       resource.date_format = B_AmericanDate;
   } else
     resource.date_format = B_AmericanDate;
This page took 0.027833 seconds and 4 git commands to generate.