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)
# Cascade Placement
$ #BestFit
# Best Fit Placement
+$ #UnderMouse
+# Under Mouse Placement
$ #LeftRight
# Left to Right
$ #RightLeft
"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,
}
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() {
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();
}
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;
}
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;
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;
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;
}
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;
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;
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,
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;
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);
case BScreen::ColSmartPlacement:
place = colSmartPlacement(window_size, space);
break;
+ case BScreen::UnderMousePlacement:
+ place = underMousePlacement(window_size, space);
+ break;
} // switch
if (place == NULL)
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);