]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
making warping work.. hopefully.
[chaz/openbox] / src / Screen.cc
index 3d51a2d20164d9775021448beedc7e0bdb55ef6f..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();
 }
 
@@ -1313,6 +1331,9 @@ void BScreen::manageWindow(Window w) {
     // 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());
   }
@@ -1345,6 +1366,17 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {
     // 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();
@@ -1495,7 +1527,8 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
 #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());
@@ -1536,6 +1569,10 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
   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);
 
This page took 0.022802 seconds and 4 git commands to generate.