added ClickMouse window placement policy

This commit is contained in:
Dana Jansens 2002-04-28 12:12:24 +00:00
parent 830e53f25c
commit 8ef0610e90
8 changed files with 48 additions and 19 deletions

View file

@ -1,6 +1,8 @@
Changelog for Openbox: Changelog for Openbox:
1.1.0: 1.1.0:
* added ClickMouse window placement algorithm/type. (Ben Jansens)
* added UnderMouse window placement algorithm/type. (Ben Jansens) * added UnderMouse window placement algorithm/type. (Ben Jansens)
1.0.0: 1.0.0:

View file

@ -32,6 +32,8 @@ $ #BestFit
# Best Fit Placement # Best Fit Placement
$ #UnderMouse $ #UnderMouse
# Under Mouse Placement # Under Mouse Placement
$ #ClickMouse
# Click Mouse Placement
$ #LeftRight $ #LeftRight
# Left to Right # Left to Right
$ #RightLeft $ #RightLeft

View file

@ -240,6 +240,9 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse, insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse,
"Under Mouse Placement"), "Under Mouse Placement"),
BScreen::UnderMousePlacement); BScreen::UnderMousePlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickMouse,
"Click Mouse Placement"),
BScreen::ClickMousePlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight, insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
"Left to Right"), BScreen::LeftRight); "Left to Right"), BScreen::LeftRight);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft, insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
@ -260,21 +263,26 @@ void Configmenu::Placementmenu::setValues() {
setItemSelected(2, p == BScreen::CascadePlacement); setItemSelected(2, p == BScreen::CascadePlacement);
setItemSelected(3, p == BScreen::BestFitPlacement); setItemSelected(3, p == BScreen::BestFitPlacement);
setItemSelected(4, p == BScreen::UnderMousePlacement); setItemSelected(4, p == BScreen::UnderMousePlacement);
setItemSelected(5, p == BScreen::ClickMousePlacement);
bool rl = (configmenu->screen.rowPlacementDirection() == bool rl = (configmenu->screen.rowPlacementDirection() ==
BScreen::LeftRight), BScreen::LeftRight),
tb = (configmenu->screen.colPlacementDirection() == tb = (configmenu->screen.colPlacementDirection() ==
BScreen::TopBottom); BScreen::TopBottom);
setItemSelected(5, rl); setItemSelected(6, rl);
setItemEnabled(5, p != BScreen::UnderMousePlacement); setItemEnabled(6, (p != BScreen::UnderMousePlacement &&
setItemSelected(6, !rl); p != BScreen::ClickMousePlacement));
setItemEnabled(6, p != BScreen::UnderMousePlacement); setItemSelected(7, !rl);
setItemEnabled(7, (p != BScreen::UnderMousePlacement &&
p != BScreen::ClickMousePlacement));
setItemSelected(7, tb); setItemSelected(8, tb);
setItemEnabled(7, p != BScreen::UnderMousePlacement); setItemEnabled(8, (p != BScreen::UnderMousePlacement &&
setItemSelected(8, !tb); p != BScreen::ClickMousePlacement));
setItemEnabled(8, p != BScreen::UnderMousePlacement); setItemSelected(9, !tb);
setItemEnabled(9, (p != BScreen::UnderMousePlacement &&
p != BScreen::ClickMousePlacement));
} }
void Configmenu::Placementmenu::reconfigure() { void Configmenu::Placementmenu::reconfigure() {
@ -312,6 +320,10 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) {
configmenu->screen.setPlacementPolicy(item->function()); configmenu->screen.setPlacementPolicy(item->function());
break; break;
case BScreen::ClickMousePlacement:
configmenu->screen.setPlacementPolicy(item->function());
break;
case BScreen::LeftRight: case BScreen::LeftRight:
configmenu->screen.setRowPlacementDirection(BScreen::LeftRight); configmenu->screen.setRowPlacementDirection(BScreen::LeftRight);
break; break;

View file

@ -1027,6 +1027,7 @@ void BScreen::setPlacementPolicy(int p) {
case BestFitPlacement: placement = "BestFitPlacement"; break; case BestFitPlacement: placement = "BestFitPlacement"; break;
case ColSmartPlacement: placement = "ColSmartPlacement"; break; case ColSmartPlacement: placement = "ColSmartPlacement"; break;
case UnderMousePlacement: placement = "UnderMousePlacement"; break; case UnderMousePlacement: placement = "UnderMousePlacement"; break;
case ClickMousePlacement: placement = "ClickMousePlacement"; break;
default: default:
case RowSmartPlacement: placement = "RowSmartPlacement"; break; case RowSmartPlacement: placement = "RowSmartPlacement"; break;
} }
@ -1302,6 +1303,8 @@ void BScreen::load() {
resource.placement_policy = BestFitPlacement; resource.placement_policy = BestFitPlacement;
else if (0 == strncasecmp(s.c_str(), "UnderMousePlacement", s.length())) else if (0 == strncasecmp(s.c_str(), "UnderMousePlacement", s.length()))
resource.placement_policy = UnderMousePlacement; 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())) else //if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
resource.placement_policy = CascadePlacement; resource.placement_policy = CascadePlacement;
} else } else

View file

@ -312,7 +312,7 @@ public:
void updateNetizenWindowLower(Window); void updateNetizenWindowLower(Window);
enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement, enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
BestFitPlacement, UnderMousePlacement, BestFitPlacement, UnderMousePlacement, ClickMousePlacement,
LeftRight, RightLeft, TopBottom, BottomTop }; LeftRight, RightLeft, TopBottom, BottomTop };
enum { LeftJustify = 1, RightJustify, CenterJustify }; enum { LeftJustify = 1, RightJustify, CenterJustify };
enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet }; enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };

View file

@ -2732,7 +2732,7 @@ void OpenboxWindow::buttonReleaseEvent(XButtonEvent *re) {
void OpenboxWindow::startMove(int x, int y) { void OpenboxWindow::startMove(int x, int y) {
ASSERT(!flags.moving); ASSERT(!flags.moving);
XGrabPointer(display, frame.window, False, Button1MotionMask | XGrabPointer(display, frame.window, False, PointerMotionMask |
ButtonReleaseMask, GrabModeAsync, GrabModeAsync, ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
None, openbox.getMoveCursor(), CurrentTime); None, openbox.getMoveCursor(), CurrentTime);
@ -2853,14 +2853,13 @@ void OpenboxWindow::endMove() {
void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) { void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) {
if (!flags.resizing && (me->state & Button1Mask) && functions.move && if (flags.moving)
(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
doMove(me->x_root, me->y_root); 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->state & Button1Mask) && (me->window == frame.right_grip ||
me->window == frame.left_grip)) || me->window == frame.left_grip)) ||
(me->state & (Mod1Mask | Button3Mask) && (me->state & (Mod1Mask | Button3Mask) &&

View file

@ -606,6 +606,7 @@ void Workspace::placeWindow(OpenboxWindow &win) {
place = colSmartPlacement(window_size, space); place = colSmartPlacement(window_size, space);
break; break;
case BScreen::UnderMousePlacement: case BScreen::UnderMousePlacement:
case BScreen::ClickMousePlacement:
place = underMousePlacement(window_size, space); place = underMousePlacement(window_size, space);
break; break;
} // switch } // switch

View file

@ -479,9 +479,19 @@ void Openbox::process_event(XEvent *e) {
if (! win) if (! win)
win = new OpenboxWindow(*this, e->xmaprequest.window); win = new OpenboxWindow(*this, e->xmaprequest.window);
if ((win = searchWindow(e->xmaprequest.window))) if ((win = searchWindow(e->xmaprequest.window))) {
win->mapRequestEvent(&e->xmaprequest); 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; break;
} }