X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWorkspace.cc;h=5982f878a8bf2631394a043b73fd613ddeaa551d;hb=e81b9d6a722b45f8895e70aa108ba4f879b48572;hp=4b9bb33b93ae6045d5237470beab0c6e3f7bed81;hpb=b424a72384ba3527044b8a4a203c53b683128913;p=chaz%2Fopenbox diff --git a/src/Workspace.cc b/src/Workspace.cc index 4b9bb33b..5982f878 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -71,8 +71,7 @@ Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) { lastfocus = (OpenboxWindow *) 0; name = (char *) 0; - char *tmp = screen.getNameOfWorkspace(id); - setName(tmp); + setName(screen.getNameOfWorkspace(id)); } @@ -87,8 +86,6 @@ Workspace::~Workspace(void) { const int Workspace::addWindow(OpenboxWindow *w, Bool place) { if (! w) return -1; - if (place) placeWindow(*w); - w->setWorkspace(id); w->setWindowNumber(_windows.size()); @@ -102,6 +99,8 @@ const int Workspace::addWindow(OpenboxWindow *w, Bool place) { raiseWindow(w); + if (place) placeWindow(*w); + return w->getWindowNumber(); } @@ -115,14 +114,11 @@ const int Workspace::removeWindow(OpenboxWindow *w) { if (w->isTransient() && w->getTransientFor() && w->getTransientFor()->isVisible()) { w->getTransientFor()->setInputFocus(); - } else if (screen.sloppyFocus()) { - screen.getOpenbox().focusWindow((OpenboxWindow *) 0); } else { - if (_zorder.empty() || !_zorder.front()->setInputFocus()) { + if (screen.sloppyFocus() || // sloppy focus + _zorder.empty() || // click focus but no windows + !_zorder.front()->setInputFocus()) { // tried window, but wont focus screen.getOpenbox().focusWindow((OpenboxWindow *) 0); - XSetInputFocus(screen.getOpenbox().getXDisplay(), - screen.getToolbar()->getWindowID(), - RevertToParent, CurrentTime); } } } @@ -298,7 +294,7 @@ void Workspace::setCurrent(void) { } -void Workspace::setName(char *new_name) { +void Workspace::setName(const char *new_name) { if (name) delete [] name; @@ -317,10 +313,8 @@ void Workspace::setName(char *new_name) { void Workspace::shutdown(void) { - while (!_windows.empty()) { + while (!_windows.empty()) _windows[0]->restore(); - _windows.erase(_windows.begin()); - } } static rectList calcSpace(const Rect &win, const rectList &spaces) { @@ -421,7 +415,8 @@ Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space) { spaces.push_back(space); //initially the entire screen is free //Find Free Spaces - for (winVect::iterator it = _windows.begin(); it != _windows.end(); ++it) + winVect::iterator it; + for (it = _windows.begin(); it != _windows.end(); ++it) spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4), spaces); @@ -475,7 +470,8 @@ Point *Workspace::rowSmartPlacement(const Size &win_size, const Rect &space) { spaces.push_back(space); //initially the entire screen is free //Find Free Spaces - for (winVect::iterator it = _windows.begin(); it != _windows.end(); ++it) + winVect::iterator it; + for (it = _windows.begin(); it != _windows.end(); ++it) spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4), spaces); //Sort spaces by preference @@ -515,7 +511,8 @@ Point *Workspace::colSmartPlacement(const Size &win_size, const Rect &space) { spaces.push_back(space); //initially the entire screen is free //Find Free Spaces - for (winVect::iterator it = _windows.begin(); it != _windows.end(); ++it) + winVect::iterator it; + for (it = _windows.begin(); it != _windows.end(); ++it) spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4), spaces); //Sort spaces by user preference