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));
}
_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();
if (_focused != (OpenboxWindow *) 0)
clientmenu->setItemSelected(_focused->getWindowNumber(), false);
_focused = win;
+ if (win != (OpenboxWindow *) 0)
+ _last = win;
}
}
-void Workspace::setName(char *new_name) {
+void Workspace::setName(const char *new_name) {
if (name)
delete [] 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) {
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);
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
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