JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Fix all kinds of chicken and egg problems with the bar as reported by
[spectrwm.git] / scrotwm.c
index 4775e91..0863b62 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -650,7 +650,6 @@ bar_update(void)
 
        if (bar_enabled == 0)
                return;
-
        if (bar_extra && bar_extra_running) {
                /* ignore short reads; it'll correct itself */
                while ((b = fgetln(stdin, &len)) != NULL)
@@ -705,16 +704,13 @@ bar_toggle(struct swm_region *r, union arg *args)
                                XMapRaised(display, tmpr->bar_window);
        }
        bar_enabled = !bar_enabled;
-       XSync(display, False);
        for (i = 0; i < sc; i++)
                for (j = 0; j < SWM_WS_MAX; j++)
                        screens[i].ws[j].restack = 1;
 
        stack();
        /* must be after stack */
-       for (i = 0; i < sc; i++)
-               TAILQ_FOREACH(tmpr, &screens[i].rl, entry)
-                       bar_update();
+       bar_update();
 }
 
 void
@@ -1412,7 +1408,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
        struct ws_win           *win, *winfocus;
        int                     i, j, s, stacks; 
        int                     w_inc = 1, h_inc, w_base = 1, h_base;
-       int                     hrh, extra, h_slice, last_h = 0;
+       int                     hrh, extra = 0, h_slice, last_h = 0;
        int                     split, colno, winno, mwin, msize, mscale;
        int                     remain, missing, v_slice;;
        unsigned int            mask;
@@ -1467,14 +1463,8 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
                        /* adjust for window's requested size increment */
                        remain = (win_g.w - w_base) % w_inc;
                        missing = w_inc - remain;
-
-                       if (missing <= extra) {
-                               extra -= missing;
-                               win_g.w += missing;
-                       } else {
-                               win_g.w -= remain;
-                               extra += remain;
-                       }
+                       win_g.w -= remain;
+                       extra += remain;
                }
 
                msize = win_g.w;
@@ -2659,7 +2649,6 @@ new_region(struct swm_screen *s, int x, int y, int w, int h)
        r->ws = ws;
        ws->r = r;
        TAILQ_INSERT_TAIL(&s->rl, r, entry);
-       bar_setup(r);
 }
 
 void
@@ -2849,10 +2838,11 @@ int
 main(int argc, char *argv[])
 {
        struct passwd           *pwd;
+       struct swm_region       *r;
        char                    conf[PATH_MAX], *cfile = NULL;
        struct stat             sb;
        XEvent                  e;
-       int                     xfd;
+       int                     xfd, i;
        fd_set                  rd;
 
        start_argv = argv;
@@ -2889,7 +2879,11 @@ main(int argc, char *argv[])
        }
        if (cfile)
                conf_load(cfile);
-       bar_refresh();
+
+       /* setup all bars */
+       for (i = 0; i < ScreenCount(display); i++)
+               TAILQ_FOREACH(r, &screens[i].rl, entry)
+                       bar_setup(r);
 
        /* ws[0].focus = TAILQ_FIRST(&ws[0].winlist); */