void BScreen::changeWorkspaceID(unsigned int id) {
if (! current_workspace || id == current_workspace->getID()) return;
- current_workspace->hide();
+ BlackboxWindow *focused = blackbox->getFocusedWindow();
+ if (focused && focused->getScreen() == this) {
+ assert(focused->isStuck() ||
+ focused->getWorkspaceNumber() == current_workspace->getID());
+
+ current_workspace->setLastFocusedWindow(focused);
+ } else {
+ // if no window had focus, no need to store a last focus
+ current_workspace->setLastFocusedWindow((BlackboxWindow *) 0);
+ }
+ // when we switch workspaces, unfocus whatever was focused
+ blackbox->setFocusedWindow((BlackboxWindow *) 0);
+
+ current_workspace->hideAll();
workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
current_workspace = getWorkspace(id);
- current_workspace->show();
-
xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
XAtom::cardinal, id);
workspacemenu->setItemSelected(current_workspace->getID() + 2, True);
toolbar->redrawWorkspaceLabel(True);
+ current_workspace->showAll();
+
+ if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
+ XSync(blackbox->getXDisplay(), False);
+ current_workspace->getLastFocusedWindow()->setInputFocus();
+ }
+
updateNetizenCurrentWorkspace();
}
// don't list non-normal windows as managed windows
windowList.push_back(win);
updateClientList();
+
+ if (win->isTopmost())
+ specialWindowList.push_back(win->getFrameWindow());
} else if (win->isDesktop()) {
desktopWindowList.push_back(win->getFrameWindow());
}
// we don't list non-normal windows as managed windows
windowList.remove(w);
updateClientList();
+
+ if (w->isTopmost()) {
+ WindowList::iterator it = specialWindowList.begin();
+ const WindowList::iterator end = specialWindowList.end();
+ for (; it != end; ++it)
+ if (*it == w->getFrameWindow()) {
+ specialWindowList.erase(it);
+ break;
+ }
+ assert(it != end); // the window wasnt a special window?
+ }
} else if (w->isDesktop()) {
WindowList::iterator it = desktopWindowList.begin();
const WindowList::iterator end = desktopWindowList.end();
#endif // XINERAMA
Window *session_stack = new
- Window[(num + workspacesList.size() + rootmenuList.size() + bbwins)];
+ Window[(num + workspacesList.size() + rootmenuList.size() +
+ specialWindowList.size() + bbwins)];
unsigned int i = 0, k = num;
XRaiseWindow(blackbox->getXDisplay(), iconmenu->getWindowID());
if (slit->isOnTop())
*(session_stack + i++) = slit->getWindowID();
+ WindowList::iterator sit, send = specialWindowList.end();
+ for (sit = specialWindowList.begin(); sit != send; ++sit)
+ *(session_stack + i++) = *sit;
+
while (k--)
*(session_stack + i++) = *(workspace_stack + k);