using std::string;
#include "blackbox.hh"
-#include "font.hh"
-#include "screen.hh"
-#include "util.hh"
-#include "window.hh"
+#include "otk/font.hh"
+#include "otk/display.hh"
+#include "bbscreen.hh"
+#include "otk/util.hh"
+#include "bbwindow.hh"
#include "workspace.hh"
-#include "xatom.hh"
+namespace ob {
Workspace::Workspace(BScreen *scrn, unsigned int i) {
screen = scrn;
// pass focus to the next appropriate window
if ((w->isFocused() || w == lastfocus) &&
- ! screen->getBlackbox()->doShutdown()) {
+ screen->getBlackbox()->state() != Openbox::State_Exiting) {
focusFallback(w);
}
// sticky windows arent unmapped on a workspace change so we don't have ot
// map them, but sometimes on a restart, another app can unmap our sticky
// windows, so we map on startup always
- if (! bw->isStuck() || screen->getBlackbox()->isStartup())
+ if (! bw->isStuck() ||
+ screen->getBlackbox()->state() == Openbox::State_Starting)
bw->show();
}
}
}
-bool Workspace::isLastWindow(const BlackboxWindow* const w) const {
+bool Workspace::isLastWindow(const BlackboxWindow *w) const {
return (w == windowList.back());
}
void Workspace::readName(void) {
- XAtom::StringVect namesList;
+ otk::OBProperty::StringVect namesList;
unsigned long numnames = id + 1;
// attempt to get from the _NET_WM_DESKTOP_NAMES property
- if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names,
- XAtom::utf8, numnames, namesList) &&
+ if (xatom->get(screen->getRootWindow(), otk::OBProperty::net_desktop_names,
+ otk::OBProperty::utf8, &numnames, &namesList) &&
namesList.size() > id) {
name = namesList[id];
void Workspace::setName(const string& new_name) {
// set the _NET_WM_DESKTOP_NAMES property with the new name
- XAtom::StringVect namesList;
+ otk::OBProperty::StringVect namesList;
unsigned long numnames = (unsigned) -1;
- if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names,
- XAtom::utf8, numnames, namesList) &&
+ if (xatom->get(screen->getRootWindow(),
+ otk::OBProperty::net_desktop_names,
+ otk::OBProperty::utf8, &numnames, &namesList) &&
namesList.size() > id)
namesList[id] = new_name;
else
namesList.push_back(new_name);
- xatom->setValue(screen->getRootWindow(), XAtom::net_desktop_names,
- XAtom::utf8, namesList);
+ xatom->set(screen->getRootWindow(), otk::OBProperty::net_desktop_names,
+ otk::OBProperty::utf8, namesList);
}
/*
* Calculate free space available for window placement.
*/
-Workspace::rectList Workspace::calcSpace(const Rect &win,
+Workspace::rectList Workspace::calcSpace(const otk::Rect &win,
const rectList &spaces) const {
- Rect isect, extra;
+ otk::Rect isect, extra;
rectList result;
rectList::const_iterator siter, end = spaces.end();
for (siter = spaces.begin(); siter != end; ++siter) {
- const Rect &curr = *siter;
+ const otk::Rect &curr = *siter;
if(! win.intersects(curr)) {
result.push_back(curr);
}
-static bool rowRLBT(const Rect &first, const Rect &second) {
+static bool rowRLBT(const otk::Rect &first, const otk::Rect &second) {
if (first.bottom() == second.bottom())
return first.right() > second.right();
return first.bottom() > second.bottom();
}
-static bool rowRLTB(const Rect &first, const Rect &second) {
+static bool rowRLTB(const otk::Rect &first, const otk::Rect &second) {
if (first.y() == second.y())
return first.right() > second.right();
return first.y() < second.y();
}
-static bool rowLRBT(const Rect &first, const Rect &second) {
+static bool rowLRBT(const otk::Rect &first, const otk::Rect &second) {
if (first.bottom() == second.bottom())
return first.x() < second.x();
return first.bottom() > second.bottom();
}
-static bool rowLRTB(const Rect &first, const Rect &second) {
+static bool rowLRTB(const otk::Rect &first, const otk::Rect &second) {
if (first.y() == second.y())
return first.x() < second.x();
return first.y() < second.y();
}
-static bool colLRTB(const Rect &first, const Rect &second) {
+static bool colLRTB(const otk::Rect &first, const otk::Rect &second) {
if (first.x() == second.x())
return first.y() < second.y();
return first.x() < second.x();
}
-static bool colLRBT(const Rect &first, const Rect &second) {
+static bool colLRBT(const otk::Rect &first, const otk::Rect &second) {
if (first.x() == second.x())
return first.bottom() > second.bottom();
return first.x() < second.x();
}
-static bool colRLTB(const Rect &first, const Rect &second) {
+static bool colRLTB(const otk::Rect &first, const otk::Rect &second) {
if (first.right() == second.right())
return first.y() < second.y();
return first.right() > second.right();
}
-static bool colRLBT(const Rect &first, const Rect &second) {
+static bool colRLBT(const otk::Rect &first, const otk::Rect &second) {
if (first.right() == second.right())
return first.bottom() > second.bottom();
return first.right() > second.right();
}
-bool Workspace::smartPlacement(Rect& win) {
+bool Workspace::smartPlacement(otk::Rect& win) {
rectList spaces;
//initially the entire screen is free
} else
#endif // XINERAMA
{
- Rect r = screen->availableArea();
+ otk::Rect r = screen->availableArea();
r.setRect(r.x() + screen->getSnapOffset(),
r.y() + screen->getSnapOffset(),
r.width() - screen->getSnapOffset(),
//Find Free Spaces
BlackboxWindowList::const_iterator wit = windowList.begin(),
end = windowList.end();
- Rect tmp;
+ otk::Rect tmp;
for (; wit != end; ++wit) {
const BlackboxWindow* const curr = *wit;
}
tmp.setRect(curr->frameRect().x(), curr->frameRect().y(),
- curr->frameRect().width() + screen->getBorderWidth(),
- curr->frameRect().height() + screen->getBorderWidth());
+ curr->frameRect().width() + screen->getWindowStyle()->getBorderWidth(),
+ curr->frameRect().height() + screen->getWindowStyle()->getBorderWidth());
spaces = calcSpace(tmp, spaces);
}
return False;
//set new position based on the empty space found
- const Rect& where = *sit;
+ const otk::Rect& where = *sit;
win.setX(where.x());
win.setY(where.y());
}
-bool Workspace::underMousePlacement(Rect &win) {
+bool Workspace::underMousePlacement(otk::Rect &win) {
int x, y, rx, ry;
Window c, r;
unsigned int m;
- XQueryPointer(screen->getBlackbox()->getXDisplay(), screen->getRootWindow(),
+ XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(),
&r, &c, &rx, &ry, &x, &y, &m);
- Rect area;
+ otk::Rect area;
#ifdef XINERAMA
if (screen->isXineramaActive() &&
screen->getBlackbox()->doXineramaPlacement()) {
}
-bool Workspace::cascadePlacement(Rect &win, const int offset) {
- Rect area;
+bool Workspace::cascadePlacement(otk::Rect &win, const int offset) {
+ otk::Rect area;
#ifdef XINERAMA
if (screen->isXineramaActive() &&
void Workspace::placeWindow(BlackboxWindow *win) {
- Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height());
+ otk::Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height());
bool placed = False;
switch (screen->getPlacementPolicy()) {
if (placed == False)
cascadePlacement(new_win, (win->getTitleHeight() +
- screen->getBorderWidth() * 2));
+ screen->getWindowStyle()->getBorderWidth() * 2));
if (new_win.right() > screen->availableArea().right())
new_win.setX(screen->availableArea().left());
win->configure(new_win.x(), new_win.y(), new_win.width(), new_win.height());
}
+
+}