]> Dogcows Code - chaz/openbox/commitdiff
better logic to not place windows over the slit and toolbar
authorDana Jansens <danakj@orodu.net>
Sat, 20 Apr 2002 19:53:19 +0000 (19:53 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 20 Apr 2002 19:53:19 +0000 (19:53 +0000)
maximize uses this same logic to not maximize over the toolbar *and the slit*

src/Window.cc
src/Workspace.cc

index 56487e0bd99c2674394bdae38f26993810b4d86a..d733afc3be8605b1db387941ded36fe318bce061 100644 (file)
@@ -54,6 +54,7 @@
 #ifdef    SLIT
 #  include "Slit.h"
 #endif // SLIT
+#include "Util.h"
 
 /*
  * Initializes the class with default values/the window's set initial values.
@@ -1532,29 +1533,107 @@ void OpenboxWindow::maximize(unsigned int button) {
     return;
   }
 
-  int dx = 0, dy = 0;
-  unsigned int dw, dh;
+  // 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();
+    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) {
+        space.setY(slit->area().y());
+        space.setH(space.h() - space.y());
+      } else
+        space.setH(space.h() - tbarh);
+      space.setY(space.y() + slit->area().h() + screen->getBorderWidth() * 2);
+      space.setH(space.h() - (slit->area().h() + screen->getBorderWidth() * 2));
+    } else if ((slit->direction() == Slit::Vertical &&
+              (slit->placement() == Slit::TopRight ||
+               slit->placement() == Slit::BottomRight)) ||
+             slit->placement() == Slit::CenterRight) {
+      // exclude right
+      space.setW(space.w() - (slit->area().w() + screen->getBorderWidth() * 2));
+      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
+      space.setH(space.h() - (screen->size().h() - slit->area().y()));
+    } else {// if ((slit->direction() == Slit::Vertical &&
+      //      (slit->placement() == Slit::TopLeft ||
+      //       slit->placement() == Slit::BottomLeft)) ||
+      //     slit->placement() == Slit::CenterLeft)
+      // exclude left
+      space.setX(slit->area().w() + screen->getBorderWidth() * 2);
+      space.setW(space.w() - (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;
 
-  dw = screen->size().w();
+  unsigned int dw = space.w(),
+               dh = space.h();
   dw -= frame.border_w * 2;
   dw -= frame.mwm_border_w * 2;
   dw -= client.base_width;
 
-  dh = screen->size().h();
   dh -= frame.border_w * 2;
   dh -= frame.mwm_border_w * 2;
   dh -= ((frame.handle_h + frame.border_w) * decorations.handle);
   dh -= client.base_height;
   dh -= frame.y_border;
 
-  if (! screen->fullMax())
-    dh -= screen->getToolbar()->getExposedHeight() + frame.border_w;
-
   if (dw < client.min_width) dw = client.min_width;
   if (dh < client.min_height) dh = client.min_height;
   if (dw > client.max_width) dw = client.max_width;
@@ -1570,23 +1649,8 @@ void OpenboxWindow::maximize(unsigned int button) {
   dh += ((frame.handle_h + frame.border_w) * decorations.handle);
   dh += frame.mwm_border_w * 2;
 
-  dx += ((screen->size().w() - dw) / 2) - frame.border_w;
-
-  if (screen->fullMax()) {
-    dy += ((screen->size().h() - dh) / 2) - frame.border_w;
-  } else {
-    dy += (((screen->size().h() - screen->getToolbar()->getExposedHeight())
-           - dh) / 2) - frame.border_w;
-
-    switch (screen->getToolbar()->placement()) {
-    case Toolbar::TopLeft:
-    case Toolbar::TopCenter:
-    case Toolbar::TopRight:
-      dy += screen->getToolbar()->getExposedHeight() +
-        frame.border_w;
-      break;
-    }
-  }
+  int dx = space.x() + ((space.w() - dw) / 2) - frame.border_w,
+      dy = space.y() + ((space.h() - dh) / 2) - frame.border_w;
 
   switch(button) {
   case 1:
index 894d49a29f7a71c2154e9de88b1c0dd8cb0f8e6f..5f8817cb4023e8d92ef2616f4538286b2317d782 100644 (file)
@@ -545,35 +545,63 @@ void Workspace::placeWindow(OpenboxWindow *win) {
 
 #ifdef    SLIT
   Slit *slit = screen.getSlit();
-  int remove;   // 0 - top/2 - right/2 - bottom/3 - left
+  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)
+      slit->placement() == Slit::TopCenter) {
     // exclude top
-    space.setY(slit->area().h() + screen.getBorderWidth() * 2);
-  else if ((slit->direction() == Slit::Vertical &&
-            (slit->placement() == Slit::TopRight ||
-             slit->placement() == Slit::BottomRight)) ||
-           slit->placement() == Slit::CenterRight)
+    if (tbartop) {
+      space.setY(slit->area().y());
+      space.setH(space.h() - space.y());
+    } else
+      space.setH(space.h() - tbarh);
+    space.setY(space.y() + slit->area().h() + screen.getBorderWidth() * 2);
+    space.setH(space.h() - (slit->area().h() + screen.getBorderWidth() * 2));
+  } else if ((slit->direction() == Slit::Vertical &&
+              (slit->placement() == Slit::TopRight ||
+               slit->placement() == Slit::BottomRight)) ||
+             slit->placement() == Slit::CenterRight) {
     // exclude right
-    space.setW(screen.size().w() -
-               (slit->area().w() + screen.getBorderWidth() * 2));
-  else if ((slit->direction() == Slit::Horizontal &&
-            (slit->placement() == Slit::BottomLeft ||
-             slit->placement() == Slit::BottomRight)) ||
-           slit->placement() == Slit::TopCenter)
+    space.setW(space.w() - (slit->area().w() + screen.getBorderWidth() * 2));
+    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
-    space.setH(screen.size().h() -
-               (slit->area().h() + screen.getBorderWidth() * 2));
-  else// if ((slit->direction() == Slit::Vertical &&
-      //      (slit->placement() == Slit::TopLeft ||
-      //       slit->placement() == Slit::BottomLeft)) ||
-      //     slit->placement() == Slit::CenterLeft)
+    space.setH(space.h() - (screen.size().h() - slit->area().y()));
+  } else {// if ((slit->direction() == Slit::Vertical &&
+    //      (slit->placement() == Slit::TopLeft ||
+    //       slit->placement() == Slit::BottomLeft)) ||
+    //     slit->placement() == Slit::CenterLeft)
     // exclude left
     space.setX(slit->area().w() + screen.getBorderWidth() * 2);
-#endif
-
+    space.setW(space.w() - (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;
@@ -581,26 +609,26 @@ void Workspace::placeWindow(OpenboxWindow *win) {
   case Toolbar::TopLeft:
   case Toolbar::TopCenter:
   case Toolbar::TopRight:
-    if (tbarh > space.y())
-      space.setY(toolbar->getExposedHeight());
+    space.setY(toolbar->getExposedHeight());
+    space.setH(space.h() - toolbar->getExposedHeight());
     break;
   case Toolbar::BottomLeft:
   case Toolbar::BottomCenter:
   case Toolbar::BottomRight:
-    if (screen.size().h() - tbarh < space.h())
-      space.setH(screen.size().h() - tbarh);
+    space.setH(space.h() - tbarh);
     break;
   default:
     ASSERT(false);      // unhandled placement
   }
+#endif // SLIT
 
   const int win_w = win->size().w() + (screen.getBorderWidth() * 4),
-    win_h = win->size().h() + (screen.getBorderWidth() * 4),
-    start_pos = 0,
-    change_y =
-      ((screen.colPlacementDirection() == BScreen::TopBottom) ? 1 : -1),
-    change_x =
-      ((screen.rowPlacementDirection() == BScreen::LeftRight) ? 1 : -1),
+  win_h = win->size().h() + (screen.getBorderWidth() * 4),
+  start_pos = 0,
+  change_y =
+    ((screen.colPlacementDirection() == BScreen::TopBottom) ? 1 : -1),
+  change_x =
+    ((screen.rowPlacementDirection() == BScreen::LeftRight) ? 1 : -1),
     delta_x = 8, delta_y = 8;
 
   LinkedListIterator<OpenboxWindow> it(windowList);
This page took 0.036313 seconds and 4 git commands to generate.