]> Dogcows Code - chaz/openbox/commitdiff
added UnderMouse windwo placement.
authorDana Jansens <danakj@orodu.net>
Sun, 28 Apr 2002 00:11:19 +0000 (00:11 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 28 Apr 2002 00:11:19 +0000 (00:11 +0000)
CHANGELOG
nls/C/Configmenu.m
src/Configmenu.cc
src/Screen.cc
src/Screen.h
src/Workspace.cc
src/Workspace.h

index 0a1e90fe95e095721596980a2a44b41ba21bf207..21c1f4c79cac0d9bcdee9ff74d41decec015ca09 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,8 @@
 Changelog for Openbox:
 
+1.1.0:
+ * added UnderMouse window placement algorithm/type.    (Ben Jansens)
+
 1.0.0:
  * maximizing windows takes the slit into account as
    well as the toolbar when 'Full Maximization' is off  (Ben Jansens)
index 741e468d2159f69d854d59423d197363337745ff..1fcaba849bf100cf1afb6e4598bc3f2cfcdf741e 100644 (file)
@@ -30,6 +30,8 @@ $ #Cascade
 # Cascade Placement
 $ #BestFit
 # Best Fit Placement
+$ #UnderMouse
+# Under Mouse Placement
 $ #LeftRight
 # Left to Right
 $ #RightLeft
index 0bef3d2e6f7d2f0f35a2360c88232793fee663c3..e11c7c386116b58d88fa7f60d61462369ca5233d 100644 (file)
@@ -237,6 +237,9 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
                          "Cascade Placement"), BScreen::CascadePlacement);
   insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBestFit,
                           "Best Fit Placement"), BScreen::BestFitPlacement);
+  insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse,
+                          "Under Mouse Placement"),
+         BScreen::UnderMousePlacement);
   insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
                          "Left to Right"), BScreen::LeftRight);
   insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
@@ -251,34 +254,27 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
 }
 
 void Configmenu::Placementmenu::setValues() {
-  switch (configmenu->screen.placementPolicy()) {
-  case BScreen::RowSmartPlacement:
-    setItemSelected(0, True);
-    break;
-
-  case BScreen::ColSmartPlacement:
-    setItemSelected(1, True);
-    break;
-
-  case BScreen::CascadePlacement:
-    setItemSelected(2, True);
-    break;
-
-  case BScreen::BestFitPlacement:
-    setItemSelected(3, True);
-    break;
-  }
-
-  Bool rl = (configmenu->screen.rowPlacementDirection() ==
+  const int p = configmenu->screen.placementPolicy();
+  setItemSelected(0, p == BScreen::RowSmartPlacement);
+  setItemSelected(1, p == BScreen::ColSmartPlacement);
+  setItemSelected(2, p == BScreen::CascadePlacement);
+  setItemSelected(3, p == BScreen::BestFitPlacement);
+  setItemSelected(4, p == BScreen::UnderMousePlacement);
+
+  bool rl = (configmenu->screen.rowPlacementDirection() ==
             BScreen::LeftRight),
        tb = (configmenu->screen.colPlacementDirection() ==
             BScreen::TopBottom);
 
-  setItemSelected(4, rl);
-  setItemSelected(5, !rl);
+  setItemSelected(5, rl);
+  setItemEnabled(5, p != BScreen::UnderMousePlacement);
+  setItemSelected(6, !rl);
+  setItemEnabled(6, p != BScreen::UnderMousePlacement);
 
-  setItemSelected(6, tb);
-  setItemSelected(7, !tb);
+  setItemSelected(7, tb);
+  setItemEnabled(7, p != BScreen::UnderMousePlacement);
+  setItemSelected(8, !tb);
+  setItemEnabled(8, p != BScreen::UnderMousePlacement);
 }
 
 void Configmenu::Placementmenu::reconfigure() {
@@ -298,74 +294,39 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) {
   switch (item->function()) {
   case BScreen::RowSmartPlacement:
     configmenu->screen.setPlacementPolicy(item->function());
-
-    setItemSelected(0, True);
-    setItemSelected(1, False);
-    setItemSelected(2, False);
-    setItemSelected(3, False);
-
     break;
 
   case BScreen::ColSmartPlacement:
     configmenu->screen.setPlacementPolicy(item->function());
-
-    setItemSelected(0, False);
-    setItemSelected(1, True);
-    setItemSelected(2, False);
-    setItemSelected(3, False);
-
     break;
 
   case BScreen::CascadePlacement:
     configmenu->screen.setPlacementPolicy(item->function());
-
-    setItemSelected(0, False);
-    setItemSelected(1, False);
-    setItemSelected(2, True);
-    setItemSelected(3, False);
-
     break;
 
   case BScreen::BestFitPlacement:
     configmenu->screen.setPlacementPolicy(item->function());
+    break;
 
-    setItemSelected(0, False);
-    setItemSelected(1, False);
-    setItemSelected(2, False);
-    setItemSelected(3, True);
-
+  case BScreen::UnderMousePlacement:
+    configmenu->screen.setPlacementPolicy(item->function());
     break;
 
   case BScreen::LeftRight:
     configmenu->screen.setRowPlacementDirection(BScreen::LeftRight);
-
-    setItemSelected(4, True);
-    setItemSelected(5, False);
-
     break;
 
   case BScreen::RightLeft:
     configmenu->screen.setRowPlacementDirection(BScreen::RightLeft);
-
-    setItemSelected(4, False);
-    setItemSelected(5, True);
-
     break;
 
   case BScreen::TopBottom:
     configmenu->screen.setColPlacementDirection(BScreen::TopBottom);
-
-    setItemSelected(6, True);
-    setItemSelected(7, False);
-
     break;
 
   case BScreen::BottomTop:
     configmenu->screen.setColPlacementDirection(BScreen::BottomTop);
-
-    setItemSelected(6, False);
-    setItemSelected(7, True);
-
     break;
   }
+  setValues();
 }
index 43ab26b9d3b121ae5c9f8bec905d002f9b45d5d6..a5c6c793711e3337e2a236c7ae4f15722fec480f 100644 (file)
@@ -1026,6 +1026,7 @@ 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;
   default:
   case RowSmartPlacement: placement = "RowSmartPlacement"; break;
   }
@@ -1220,7 +1221,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;
@@ -1231,7 +1232,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;
@@ -1272,7 +1273,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;
     }
@@ -1299,7 +1300,9 @@ 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(), "CascadePlacement", s.length()))
       resource.placement_policy = CascadePlacement;
   } else
     resource.placement_policy = CascadePlacement;
@@ -1323,7 +1326,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;
index fc285319eba08c653bf64e6e1070e3ed23fbf9e0..3b536d2738db262dab1b9c60a7b1c0dc75abdf00 100644 (file)
@@ -312,7 +312,8 @@ public:
   void updateNetizenWindowLower(Window);
 
   enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
-         BestFitPlacement, LeftRight, RightLeft, TopBottom, BottomTop };
+         BestFitPlacement, UnderMousePlacement,
+         LeftRight, RightLeft, TopBottom, BottomTop };
   enum { LeftJustify = 1, RightJustify, CenterJustify };
   enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
   enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
index 392107437f8c2df0862c3584ef2d43aac2368d56..c1a0d602d41f0ce726fe9279e7d31892bb38c361 100644 (file)
@@ -444,6 +444,26 @@ Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space) {
     return NULL; //fall back to cascade
 }
 
+Point *Workspace::underMousePlacement(const Size &win_size, const Rect &space) {
+  Point *pt;
+
+  int x, y, rx, ry;
+  Window c, r;
+  unsigned int m;
+  XQueryPointer(screen.getOpenbox().getXDisplay(), screen.getRootWindow(),
+                &r, &c, &rx, &ry, &x, &y, &m);
+  pt = new Point(rx - win_size.w() / 2, ry - win_size.h() / 2);
+
+  if (pt->x() < space.x())
+    pt->setX(space.x());
+  if (pt->y() < space.y())
+    pt->setY(space.y());
+  if (pt->x() + win_size.w() > space.x() + space.w())
+    pt->setX(space.x() + space.w() - win_size.w());
+  if (pt->y() + win_size.h() > space.y() + space.h())
+    pt->setY(space.y() + space.h() - win_size.h());
+  return pt;
+}
 
 Point *Workspace::rowSmartPlacement(const Size &win_size, const Rect &space) {
   bool placed=false;
@@ -587,8 +607,8 @@ Point *const Workspace::cascadePlacement(const OpenboxWindow &win,
 
 void Workspace::placeWindow(OpenboxWindow &win) {
   Rect space = screen.availableArea();
-  const Size window_size(win.area().w()+screen.getBorderWidth() * 4,
-                         win.area().h()+screen.getBorderWidth() * 4);
+  const Size window_size(win.area().w()+screen.getBorderWidth() * 2,
+                         win.area().h()+screen.getBorderWidth() * 2);
   Point *place = NULL;
   LinkedListIterator<OpenboxWindow> it(windowList);
 
@@ -602,6 +622,9 @@ void Workspace::placeWindow(OpenboxWindow &win) {
   case BScreen::ColSmartPlacement:
     place = colSmartPlacement(window_size, space);
     break;
+  case BScreen::UnderMousePlacement:
+    place = underMousePlacement(window_size, space);
+    break;
   } // switch
 
   if (place == NULL)
index 12d4dfc2c3ee9cd2d06d88dc9905b078d8127378..ab8dad3ffef7f559f57a55588985eb60e1075715 100644 (file)
@@ -48,6 +48,7 @@ private:
 protected:
   void placeWindow(OpenboxWindow &);
   Point *bestFitPlacement(const Size &win_size, const Rect &space);
+  Point *underMousePlacement(const Size &win_size, const Rect &space);
   Point *rowSmartPlacement(const Size &win_size, const Rect &space);
   Point *colSmartPlacement(const Size &win_size, const Rect &space);
   Point *const cascadePlacement(const OpenboxWindow &window, const Rect &space);
This page took 0.034544 seconds and 4 git commands to generate.