]> Dogcows Code - chaz/openbox/commitdiff
added ClickMouse window placement policy
authorDana Jansens <danakj@orodu.net>
Sun, 28 Apr 2002 12:12:24 +0000 (12:12 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 28 Apr 2002 12:12:24 +0000 (12:12 +0000)
CHANGELOG
nls/C/Configmenu.m
src/Configmenu.cc
src/Screen.cc
src/Screen.h
src/Window.cc
src/Workspace.cc
src/openbox.cc

index 21c1f4c79cac0d9bcdee9ff74d41decec015ca09..b0fb39b6008fb297c0af1d10b84989e5812ffb30 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 Changelog for Openbox:
 
 1.1.0:
+ * added ClickMouse window placement algorithm/type.    (Ben Jansens)
  * added UnderMouse window placement algorithm/type.    (Ben Jansens)
 
 1.0.0:
index 1fcaba849bf100cf1afb6e4598bc3f2cfcdf741e..f6b422a230b33c6013ffff1ee7c1afe8609edaaa 100644 (file)
@@ -32,6 +32,8 @@ $ #BestFit
 # Best Fit Placement
 $ #UnderMouse
 # Under Mouse Placement
+$ #ClickMouse
+# Click Mouse Placement
 $ #LeftRight
 # Left to Right
 $ #RightLeft
index e11c7c386116b58d88fa7f60d61462369ca5233d..ffb5d6e3f8880cefb3bbd563b355c3bce00ec8fb 100644 (file)
@@ -240,6 +240,9 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
   insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse,
                           "Under Mouse Placement"),
          BScreen::UnderMousePlacement);
+  insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickMouse,
+                          "Click Mouse Placement"),
+         BScreen::ClickMousePlacement);
   insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
                          "Left to Right"), BScreen::LeftRight);
   insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
@@ -260,21 +263,26 @@ void Configmenu::Placementmenu::setValues() {
   setItemSelected(2, p == BScreen::CascadePlacement);
   setItemSelected(3, p == BScreen::BestFitPlacement);
   setItemSelected(4, p == BScreen::UnderMousePlacement);
+  setItemSelected(5, p == BScreen::ClickMousePlacement);
 
   bool rl = (configmenu->screen.rowPlacementDirection() ==
             BScreen::LeftRight),
        tb = (configmenu->screen.colPlacementDirection() ==
             BScreen::TopBottom);
 
-  setItemSelected(5, rl);
-  setItemEnabled(5, p != BScreen::UnderMousePlacement);
-  setItemSelected(6, !rl);
-  setItemEnabled(6, p != BScreen::UnderMousePlacement);
-
-  setItemSelected(7, tb);
-  setItemEnabled(7, p != BScreen::UnderMousePlacement);
-  setItemSelected(8, !tb);
-  setItemEnabled(8, p != BScreen::UnderMousePlacement);
+  setItemSelected(6, rl);
+  setItemEnabled(6, (p != BScreen::UnderMousePlacement &&
+                     p != BScreen::ClickMousePlacement));
+  setItemSelected(7, !rl);
+  setItemEnabled(7, (p != BScreen::UnderMousePlacement &&
+                     p != BScreen::ClickMousePlacement));
+
+  setItemSelected(8, tb);
+  setItemEnabled(8, (p != BScreen::UnderMousePlacement &&
+                     p != BScreen::ClickMousePlacement));
+  setItemSelected(9, !tb);
+  setItemEnabled(9, (p != BScreen::UnderMousePlacement &&
+                     p != BScreen::ClickMousePlacement));
 }
 
 void Configmenu::Placementmenu::reconfigure() {
@@ -312,6 +320,10 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) {
     configmenu->screen.setPlacementPolicy(item->function());
     break;
 
+  case BScreen::ClickMousePlacement:
+    configmenu->screen.setPlacementPolicy(item->function());
+    break;
+
   case BScreen::LeftRight:
     configmenu->screen.setRowPlacementDirection(BScreen::LeftRight);
     break;
index a5c6c793711e3337e2a236c7ae4f15722fec480f..2c46a836b6d2b587cd7ae5768f49b692348856ff 100644 (file)
@@ -1027,6 +1027,7 @@ void BScreen::setPlacementPolicy(int p) {
   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;
   }
@@ -1302,6 +1303,8 @@ void BScreen::load() {
       resource.placement_policy = BestFitPlacement;
     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
index 3b536d2738db262dab1b9c60a7b1c0dc75abdf00..124d4f98635501e60d89aca4f674638b285f1f27 100644 (file)
@@ -312,7 +312,7 @@ public:
   void updateNetizenWindowLower(Window);
 
   enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
-         BestFitPlacement, UnderMousePlacement,
+         BestFitPlacement, UnderMousePlacement, ClickMousePlacement,
          LeftRight, RightLeft, TopBottom, BottomTop };
   enum { LeftJustify = 1, RightJustify, CenterJustify };
   enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
index 51e2b41b2be51407796714480b4085af7b0654ab..3fc0f43d92b7457cd6b85b44155b413d221a743c 100644 (file)
@@ -2732,7 +2732,7 @@ void OpenboxWindow::buttonReleaseEvent(XButtonEvent *re) {
 void OpenboxWindow::startMove(int x, int y) {
   ASSERT(!flags.moving);
 
-  XGrabPointer(display, frame.window, False, Button1MotionMask |
+  XGrabPointer(display, frame.window, False, PointerMotionMask |
                ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
                None, openbox.getMoveCursor(), CurrentTime);
 
@@ -2853,14 +2853,13 @@ void OpenboxWindow::endMove() {
 
 
 void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) {
-  if (!flags.resizing && (me->state & Button1Mask) && functions.move &&
-      (frame.title == me->window || frame.label == me->window ||
-       frame.handle == me->window || frame.window == me->window)) {
-    if (!flags.moving)
-      startMove(me->x_root, me->y_root);
-    else
+  if (flags.moving)
       doMove(me->x_root, me->y_root);
-  } else if (functions.resize &&
+  else if (!flags.resizing && (me->state & Button1Mask) && functions.move &&
+      (frame.title == me->window || frame.label == me->window ||
+       frame.handle == me->window || frame.window == me->window))
+    startMove(me->x_root, me->y_root);
+  else if (functions.resize &&
             (((me->state & Button1Mask) && (me->window == frame.right_grip ||
                                             me->window == frame.left_grip)) ||
              (me->state & (Mod1Mask | Button3Mask) &&
index b39769e9e9f91c8abe8d05db9725b86db3211a31..ac655d15ec87fe03d2f2fdf6de2374d0df925c28 100644 (file)
@@ -606,6 +606,7 @@ void Workspace::placeWindow(OpenboxWindow &win) {
     place = colSmartPlacement(window_size, space);
     break;
   case BScreen::UnderMousePlacement:
+  case BScreen::ClickMousePlacement:
     place = underMousePlacement(window_size, space);
     break;
   } // switch
index cfdb6e9bc3db9fbd9aae5bfb498af8ed4198d573..99d623e5c99f4c3f4c556b0078a9a5540c87c356 100644 (file)
@@ -479,9 +479,19 @@ void Openbox::process_event(XEvent *e) {
     if (! win)
       win = new OpenboxWindow(*this, e->xmaprequest.window);
 
-    if ((win = searchWindow(e->xmaprequest.window)))
+    if ((win = searchWindow(e->xmaprequest.window))) {
       win->mapRequestEvent(&e->xmaprequest);
-
+      // if we're using the click to place placement type, then immediately
+      // after the window is mapped, we need to start interactively moving it
+      if (win->getScreen()->placementPolicy() == BScreen::ClickMousePlacement) {
+        int x, y, rx, ry;
+        Window c, r;
+        unsigned int m;
+        XQueryPointer(getXDisplay(), win->getScreen()->getRootWindow(),
+                      &r, &c, &rx, &ry, &x, &y, &m);
+        win->startMove(rx, ry);
+      }
+    }
     break;
   }
 
This page took 0.028921 seconds and 4 git commands to generate.