]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
making warping work.. hopefully.
[chaz/openbox] / src / Screen.cc
index d49e418afbfa6c5bc57f3a7d22eea4c046baae8a..31811fe63d740996b8745d9846e53006d57509cb 100644 (file)
@@ -1186,20 +1186,38 @@ unsigned int BScreen::removeLastWorkspace(void) {
 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();
 }
 
This page took 0.025579 seconds and 4 git commands to generate.