X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FWorkspace.cc;h=41a09324ab4ab687d7971ab1f5668306e63278fa;hb=f00ed578baacb73a36227fed1419e9d451ee7bb0;hp=256ad3da9845c18c6f1b8f3b7f7a7d53eb14a32b;hpb=a0dbb0e13f19ac4cc2dddf3d94723174971df6d2;p=chaz%2Fopenbox diff --git a/src/Workspace.cc b/src/Workspace.cc index 256ad3da..41a09324 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -63,16 +63,13 @@ typedef std::vector rectList; Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) { cascade_x = cascade_y = 0; - _focused = (OpenboxWindow *) 0; + _focused = _last = (OpenboxWindow *) 0; id = i; clientmenu = new Clientmenu(*this); - lastfocus = (OpenboxWindow *) 0; - name = (char *) 0; - char *tmp = screen.getNameOfWorkspace(id); - setName(tmp); + setName(screen.getNameOfWorkspace(id)); } @@ -112,23 +109,22 @@ const int Workspace::removeWindow(OpenboxWindow *w) { _zorder.remove(w); if (w->isFocused()) { + if (w == _last) + _last = (OpenboxWindow *) 0; + + OpenboxWindow *fw = (OpenboxWindow *) 0; if (w->isTransient() && w->getTransientFor() && - w->getTransientFor()->isVisible()) { - w->getTransientFor()->setInputFocus(); - } else { - 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(), - PointerRoot, None, CurrentTime); - } - } + w->getTransientFor()->isVisible()) + fw = w->getTransientFor(); + else if (screen.sloppyFocus()) // sloppy focus + fw = (OpenboxWindow *) 0; + else if (!_zorder.empty()) // click focus + fw = _zorder.front(); + + if (!(fw != (OpenboxWindow *) 0 && fw->setInputFocus())) + screen.getOpenbox().focusWindow(0); } - if (lastfocus == w) - lastfocus = (OpenboxWindow *) 0; - _windows.erase(_windows.begin() + w->getWindowNumber()); clientmenu->remove(w->getWindowNumber()); clientmenu->update(); @@ -149,6 +145,8 @@ void Workspace::focusWindow(OpenboxWindow *win) { if (_focused != (OpenboxWindow *) 0) clientmenu->setItemSelected(_focused->getWindowNumber(), false); _focused = win; + if (win != (OpenboxWindow *) 0) + _last = win; } @@ -297,7 +295,7 @@ void Workspace::setCurrent(void) { } -void Workspace::setName(char *new_name) { +void Workspace::setName(const char *new_name) { if (name) delete [] name; @@ -316,10 +314,8 @@ void Workspace::setName(char *new_name) { void Workspace::shutdown(void) { - while (!_windows.empty()) { + while (!_windows.empty()) _windows[0]->restore(); - delete _windows[0]; - } } static rectList calcSpace(const Rect &win, const rectList &spaces) { @@ -420,7 +416,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); @@ -474,7 +471,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 @@ -514,7 +512,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