]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
add next/prev window on all workspaces
[chaz/openbox] / src / Screen.cc
index c1f8532f193a129530872a878f18bfaf31e6d58f..ab7003ad2e6f556d928fdebf4102849ad75bc273 100644 (file)
@@ -21,7 +21,9 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
+#ifdef    HAVE_CONFIG_H
 #include "../config.h"
+#endif // HAVE_CONFIG_H
 
 extern "C" {
 #include <X11/Xatom.h>
@@ -231,7 +233,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
   xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
                   XAtom::cardinal, 0); //first workspace
 
-  //workspacemenu->setItemSelected(2, True);
+  workspacemenu->setItemSelected(2, True);
 
   toolbar = new Toolbar(this);
 
@@ -613,8 +615,9 @@ void BScreen::load_rc(void) {
   else
     resource.col_direction = TopBottom;
 
-  XAtom::StringVect workspaceNames;
   if (config->getValue(screenstr + "workspaceNames", s)) {
+    XAtom::StringVect workspaceNames;
+
     string::const_iterator it = s.begin(), end = s.end();
     while(1) {
       string::const_iterator tmp = it;     // current string.begin()
@@ -624,9 +627,10 @@ void BScreen::load_rc(void) {
         break;
       ++it;
     }
+
+    xatom->setValue(getRootWindow(), XAtom::net_desktop_names, XAtom::utf8,
+                    workspaceNames);
   }
-  xatom->setValue(getRootWindow(), XAtom::net_desktop_names, XAtom::utf8,
-                  workspaceNames);
 
   resource.sloppy_focus = true;
   resource.auto_raise = false;
@@ -684,12 +688,37 @@ void BScreen::load_rc(void) {
 }
 
 
+void BScreen::changeWorkspaceCount(unsigned int new_count) {
+  assert(new_count > 0);
+
+  if (new_count < workspacesList.size()) {
+    // shrink
+    for (unsigned int i = workspacesList.size(); i > new_count; --i)
+      removeLastWorkspace();
+    // removeLast already sets the current workspace to the 
+    // last available one.
+  } else if (new_count > workspacesList.size()) {
+    // grow
+    for(unsigned int i = workspacesList.size(); i < new_count; ++i)
+      addWorkspace();
+  }
+}
+
+
 void BScreen::reconfigure(void) {
+  // don't reconfigure while saving the initial rc file, it's a waste and it
+  // breaks somethings (workspace names)
+  if (blackbox->isStartup()) return;
+
   load_rc();
   toolbar->load_rc();
   slit->load_rc();
   LoadStyle();
 
+  // we need to do this explicitly, because just loading this value from the rc
+  // does nothing
+  changeWorkspaceCount(resource.workspaces);
+
   XGCValues gcv;
   gcv.foreground = WhitePixel(blackbox->getXDisplay(),
                               getScreenNumber());
@@ -1063,14 +1092,14 @@ void BScreen::changeWorkspaceID(unsigned int id) {
   blackbox->setFocusedWindow((BlackboxWindow *) 0);
     
   current_workspace->hideAll();
-  //workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
+  workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
 
   current_workspace = getWorkspace(id);
 
   xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
                   XAtom::cardinal, id);
 
-  //workspacemenu->setItemSelected(current_workspace->getID() + 2, True);
+  workspacemenu->setItemSelected(current_workspace->getID() + 2, True);
   toolbar->redrawWorkspaceLabel(True);
 
   current_workspace->showAll();
This page took 0.027885 seconds and 4 git commands to generate.