if (openbox.focusedWindow() &&
openbox.focusedWindow()->getScreen() == this &&
(! openbox.focusedWindow()->isStuck())) {
- current_workspace->setLastFocusedWindow(openbox.focusedWindow());
- openbox.focusWindow((OpenboxWindow *) 0);
+ openbox.focusWindow(0);
}
current_workspace = getWorkspace(id);
current_workspace->showAll();
- if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
+ if (resource.focus_last && current_workspace->lastFocusedWindow()) {
XSync(openbox.getXDisplay(), False);
- current_workspace->getLastFocusedWindow()->setInputFocus();
+ current_workspace->lastFocusedWindow()->setInputFocus();
}
}
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;
setName(screen.getNameOfWorkspace(id));
}
const int Workspace::addWindow(OpenboxWindow *w, Bool place) {
if (! w) return -1;
+ if (place) placeWindow(*w);
+
w->setWorkspace(id);
w->setWindowNumber(_windows.size());
raiseWindow(w);
- if (place) placeWindow(*w);
-
return w->getWindowNumber();
}
_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);
- }
- }
+ 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;
}
class Workspace {
private:
BScreen &screen;
- OpenboxWindow *lastfocus;
Clientmenu *clientmenu;
typedef std::vector<OpenboxWindow *> winVect;
char *name;
int id, cascade_x, cascade_y;
- OpenboxWindow *_focused;
+ OpenboxWindow *_focused, *_last; // last is the same as focused except
+ // that when focus is removed from all
+ // windows on the workspace, last doesnt
+ // change to NULL
protected:
void placeWindow(OpenboxWindow &);
~Workspace(void);
inline BScreen &getScreen(void) { return screen; }
- inline OpenboxWindow *getLastFocusedWindow(void) { return lastfocus; }
inline Clientmenu *getMenu(void) { return clientmenu; }
inline const char *getName(void) const { return name; }
inline const int &getWorkspaceID(void) const { return id; }
- inline void setLastFocusedWindow(OpenboxWindow *w) { lastfocus = w; }
inline OpenboxWindow *focusedWindow() { return _focused; }
+ inline OpenboxWindow *lastFocusedWindow() { return _last; }
void focusWindow(OpenboxWindow *win);
OpenboxWindow *getWindow(int);
Bool isCurrent(void);
resource.titlebar_layout = NULL;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
- focused_screen = (BScreen *) 0;
- masked_window = NULL;
+ current_screen = (BScreen *) 0;
+ masked_window = (OpenboxWindow *) 0;
masked = None;
load();
"Openbox::Openbox: no managable screens found, aborting.\n"));
::exit(3);
}
- focused_screen = screenList.front();
+ current_screen = screenList.front();
// save current settings and default values
save();
ungrab();
- focusWindow((OpenboxWindow *) 0);
+ focusWindow(0);
}
void Openbox::shutdown() {
BaseDisplay::shutdown();
- focusWindow((OpenboxWindow *) 0);
-
std::for_each(screenList.begin(), screenList.end(),
std::mem_fun(&BScreen::shutdown));
+ focusWindow(0);
+
XSync(getXDisplay(), False);
}
OpenboxWindow *Openbox::focusedWindow() {
- if (focused_screen == (BScreen *) 0)
- return (OpenboxWindow *) 0;
- Workspace *w = focused_screen->getCurrentWorkspace();
- if (w == (Workspace *) 0)
- return (OpenboxWindow *) 0;
- return w->focusedWindow();
+ Workspace *w;
+ if (current_screen)
+ if ((w = current_screen->getCurrentWorkspace()))
+ return w->focusedWindow();
+ return (OpenboxWindow *) 0;
}
old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
old_tbar = old_screen->getToolbar();
- old_win->setFocusFlag(False);
+ old_win->setFocusFlag(false);
old_wkspc->focusWindow((OpenboxWindow *) 0);
}
if (win && !win->isIconic()) {
- focused_screen = win->getScreen();
- tbar = focused_screen->getToolbar();
- wkspc = focused_screen->getWorkspace(win->getWorkspaceNumber());
+ current_screen = win->getScreen();
+ tbar = current_screen->getToolbar();
+ wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
win->setFocusFlag(true);
wkspc->focusWindow(win);
if (tbar)
tbar->redrawWindowLabel(true);
- focused_screen->updateNetizenWindowFocus();
+ current_screen->updateNetizenWindowFocus();
} else {
- ASSERT(focused_screen != (BScreen *) 0);
- XSetInputFocus(getXDisplay(), focused_screen->getRootWindow(),
- None, CurrentTime);
+ XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
}
if (old_tbar && old_tbar != tbar)
old_tbar->redrawWindowLabel(true);
- if (old_screen && old_screen != focused_screen)
+ if (old_screen && old_screen != current_screen)
old_screen->updateNetizenWindowFocus();
}
typedef std::list<BScreen*> ScreenList;
ScreenList screenList;
- BScreen *focused_screen;
+ BScreen *current_screen;
OpenboxWindow *masked_window;
BTimer *timer;