]> Dogcows Code - chaz/openbox/commitdiff
added BScreen::availableArea() which returns a rect specifying where windows can...
authorDana Jansens <danakj@orodu.net>
Sat, 27 Apr 2002 19:25:20 +0000 (19:25 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 27 Apr 2002 19:25:20 +0000 (19:25 +0000)
src/Screen.cc
src/Screen.h
src/Window.cc
src/Workspace.cc

index 1de7c0bfb837958bee3a67ba6f73f5aa5842b9e2..43ab26b9d3b121ae5c9f8bec905d002f9b45d5d6 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)
index 99fbf40210dc0f924291d673350964affd4aa67a..fc285319eba08c653bf64e6e1070e3ed23fbf9e0 100644 (file)
@@ -187,6 +187,8 @@ public:
 
   inline Toolbar *getToolbar() { return toolbar; }
 
+  Rect availableArea() const;
+  
   inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
   inline Workspace *getCurrentWorkspace() { return current_workspace; }
 
index f768f6c15e90ad088401ce6071e1b7055c04535d..115b8c0f111939b20ef035ba689e352d2807360d 100644 (file)
@@ -1533,111 +1533,12 @@ void OpenboxWindow::maximize(unsigned int button) {
     return;
   }
 
-  // the following code is temporary and will be taken care of by Screen in the
-  // future (with the NETWM 'strut')
-  Rect space(0, 0, screen->size().w(), screen->size().h());
-  if (! screen->fullMax()) {
-#ifdef    SLIT
-    Slit *slit = screen->getSlit();
-    int slit_x = slit->autoHide() ? slit->hiddenOrigin().x() : slit->area().x(),
-        slit_y = slit->autoHide() ? slit->hiddenOrigin().y() : slit->area().y();
-    Toolbar *toolbar = screen->getToolbar();
-    int tbarh = screen->hideToolbar() ? 0 :
-      toolbar->getExposedHeight() + screen->getBorderWidth() * 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() +
-                                screen->getBorderWidth() * 2));
-        space.setH(space.h() - (slit_y + slit->area().h() +
-                                screen->getBorderWidth() * 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() - (screen->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 && (screen->size().h() - slit_y) < tbarh) {
-        space.setH(space.h() - tbarh);
-      } else {
-        space.setH(space.h() - (screen->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() +
-                 screen->getBorderWidth() * 2);
-      space.setW(space.w() - (slit_x + slit->area().w() +
-                              screen->getBorderWidth() * 2));
-      if (tbartop)
-        space.setY(space.y() + tbarh);
-      space.setH(space.h() - tbarh);
-    }
-#else // !SLIT
-    Toolbar *toolbar = screen->getToolbar();
-    int tbarh = screen->hideToolbar() ? 0 :
-      toolbar->getExposedHeight() + screen->getBorderWidth() * 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
-  }
-
   openbox_attrib.premax_x = frame.x;
   openbox_attrib.premax_y = frame.y;
   openbox_attrib.premax_w = frame.width;
   openbox_attrib.premax_h = frame.height;
 
+  Rect space = screen->availableArea();
   unsigned int dw = space.w(),
                dh = space.h();
   dw -= frame.border_w * 2;
index b0cafdfb5c6036c7f95bb5d772f4315eb8d81da0..1c290b754fa8368862d66dedfc11ccdfffda79f9 100644 (file)
@@ -581,105 +581,7 @@ Point *const Workspace::cascadePlacement(const OpenboxWindow *const win){
 void Workspace::placeWindow(OpenboxWindow *win) {
   ASSERT(win != NULL);
 
-  // the following code is temporary and will be taken care of by Screen in the
-  // future (with the NETWM 'strut')
-  Rect space(0, 0, screen.size().w(), screen.size().h());
-
-#ifdef    SLIT
-    Slit *slit = screen.getSlit();
-    int slit_x = slit->autoHide() ? slit->hiddenOrigin().x() : slit->area().x(),
-        slit_y = slit->autoHide() ? slit->hiddenOrigin().y() : slit->area().y();
-    Toolbar *toolbar = screen.getToolbar();
-    int tbarh = screen.hideToolbar() ? 0 :
-      toolbar->getExposedHeight() + screen.getBorderWidth() * 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() +
-                                screen.getBorderWidth() * 2));
-        space.setH(space.h() - (slit_y + slit->area().h() +
-                                screen.getBorderWidth() * 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() - (screen.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 && (screen.size().h() - slit_y) < tbarh) {
-        space.setH(space.h() - tbarh);
-      } else {
-        space.setH(space.h() - (screen.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() +
-                 screen.getBorderWidth() * 2);
-      space.setW(space.w() - (slit_x + slit->area().w() +
-                              screen.getBorderWidth() * 2));
-      if (tbartop)
-        space.setY(space.y() + tbarh);
-      space.setH(space.h() - tbarh);
-    }
-#else // !SLIT
-  Toolbar *toolbar = screen.getToolbar();
-  int tbarh = screen.hideToolbar() ? 0 :
-    toolbar->getExposedHeight() + screen.getBorderWidth() * 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
-
+  Rect space = screen.availableArea();
   const Size window_size(win->area().w()+screen.getBorderWidth() * 4,
                          win->area().h()+screen.getBorderWidth() * 4);
   Point *place = NULL;
This page took 0.038104 seconds and 4 git commands to generate.