From 8ef0610e9056613eeb1988dde95d252bc0988883 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 28 Apr 2002 12:12:24 +0000 Subject: [PATCH] added ClickMouse window placement policy --- CHANGELOG | 2 ++ nls/C/Configmenu.m | 2 ++ src/Configmenu.cc | 30 +++++++++++++++++++++--------- src/Screen.cc | 3 +++ src/Screen.h | 2 +- src/Window.cc | 15 +++++++-------- src/Workspace.cc | 1 + src/openbox.cc | 14 ++++++++++++-- 8 files changed, 49 insertions(+), 20 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 21c1f4c7..b0fb39b6 100644 --- 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: diff --git a/nls/C/Configmenu.m b/nls/C/Configmenu.m index 1fcaba84..f6b422a2 100644 --- a/nls/C/Configmenu.m +++ b/nls/C/Configmenu.m @@ -32,6 +32,8 @@ $ #BestFit # Best Fit Placement $ #UnderMouse # Under Mouse Placement +$ #ClickMouse +# Click Mouse Placement $ #LeftRight # Left to Right $ #RightLeft diff --git a/src/Configmenu.cc b/src/Configmenu.cc index e11c7c38..ffb5d6e3 100644 --- a/src/Configmenu.cc +++ b/src/Configmenu.cc @@ -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; diff --git a/src/Screen.cc b/src/Screen.cc index a5c6c793..2c46a836 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -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 diff --git a/src/Screen.h b/src/Screen.h index 3b536d27..124d4f98 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -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 }; diff --git a/src/Window.cc b/src/Window.cc index 51e2b41b..3fc0f43d 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -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) && diff --git a/src/Workspace.cc b/src/Workspace.cc index b39769e9..ac655d15 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -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 diff --git a/src/openbox.cc b/src/openbox.cc index cfdb6e9b..99d623e5 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -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; } -- 2.45.2