added ClickMouse window placement policy
This commit is contained in:
parent
830e53f25c
commit
8ef0610e90
8 changed files with 48 additions and 19 deletions
|
@ -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:
|
||||
|
|
|
@ -32,6 +32,8 @@ $ #BestFit
|
|||
# Best Fit Placement
|
||||
$ #UnderMouse
|
||||
# Under Mouse Placement
|
||||
$ #ClickMouse
|
||||
# Click Mouse Placement
|
||||
$ #LeftRight
|
||||
# Left to Right
|
||||
$ #RightLeft
|
||||
|
|
|
@ -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(6, rl);
|
||||
setItemEnabled(6, (p != BScreen::UnderMousePlacement &&
|
||||
p != BScreen::ClickMousePlacement));
|
||||
setItemSelected(7, !rl);
|
||||
setItemEnabled(7, (p != BScreen::UnderMousePlacement &&
|
||||
p != BScreen::ClickMousePlacement));
|
||||
|
||||
setItemSelected(7, tb);
|
||||
setItemEnabled(7, p != BScreen::UnderMousePlacement);
|
||||
setItemSelected(8, !tb);
|
||||
setItemEnabled(8, p != BScreen::UnderMousePlacement);
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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) &&
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue