JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
cleanup
[spectrwm.git] / spectrwm.c
index 5951b9e..b527e91 100644 (file)
@@ -6,8 +6,8 @@
  * Copyright (c) 2010 Tuukka Kataja <stuge@xor.fi>
  * Copyright (c) 2011 Jason L. Wright <jason@thought.net>
  * Copyright (c) 2011-2012 Reginald Kennedy <rk@rejii.com>
- * Copyright (c) 2012 Lawrence Teo <lteo@lteo.net>
- * Copyright (c) 2012 Tiago Cunha <tcunha@gmx.com>
+ * Copyright (c) 2011-2012 Lawrence Teo <lteo@lteo.net>
+ * Copyright (c) 2011-2012 Tiago Cunha <tcunha@gmx.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -83,7 +83,7 @@
 #elif defined(__FreeBSD__)
 #include <sys/tree.h>
 #else
-#include <sys/tree.h>
+#include "tree.h"
 #endif
 
 #include <X11/cursorfont.h>
@@ -1482,14 +1482,15 @@ bar_update(void)
                                if (r->ws->name)
                                        snprintf(ws, sizeof ws, "<%s>",
                                            r->ws->name);
+                               if (stack_enabled)
+                                       stack = r->ws->stacker;
+
+                               snprintf(loc, sizeof loc, 
+                                   "%d:%d %s %s   %s%s    %s    %s",
+                                   x++, r->ws->idx + 1, stack, ws, s, cn,
+                                   bar_ext, bar_vertext);
+                               bar_print(r, loc);
                        }
-                       if (stack_enabled)
-                               stack = r->ws->stacker;
-
-                       snprintf(loc, sizeof loc, "%d:%d %s %s   %s%s    %s    "
-                           "%s", x++, r->ws->idx + 1, stack, ws, s, cn,
-                           bar_ext, bar_vertext);
-                       bar_print(r, loc);
                }
        }
        alarm(bar_delay);
@@ -2534,8 +2535,6 @@ focus_prev(struct ws_win *win)
            (ws->cur_layout->flags & SWM_L_FOCUSPREV)) {
                if (cur_focus != ws->focus_prev)
                        winfocus = ws->focus_prev;
-               else if (cur_focus != ws->focus)
-                       winfocus = ws->focus;
                else
                        winfocus = TAILQ_PREV(win, ws_win_list, entry);
                if (winfocus)
@@ -2919,9 +2918,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
                if (w_inc > 1 && w_inc < v_slice) {
                        /* adjust for window's requested size increment */
                        remain = (win_g.w - w_base) % w_inc;
-                       missing = w_inc - remain;
                        win_g.w -= remain;
-                       extra += remain;
                }
 
                msize = win_g.w;
@@ -3298,7 +3295,7 @@ pressbutton(struct swm_region *r, union arg *args)
 void
 raise_toggle(struct swm_region *r, union arg *args)
 {
-       if (r && r->ws == NULL)
+       if (r == NULL || r->ws == NULL)
                return;
 
        r->ws->always_raise = !r->ws->always_raise;
@@ -3360,7 +3357,7 @@ uniconify(struct swm_region *r, union arg *args)
 
        DNPRINTF(SWM_D_MISC, "uniconify\n");
 
-       if (r && r->ws == NULL)
+       if (r == NULL || r->ws == NULL)
                return;
 
        /* make sure we have anything to uniconify */
@@ -5758,7 +5755,7 @@ manage_window(Window id)
        Atom                    *prot = NULL, *pp;
        unsigned char           ws_idx_str[SWM_PROPLEN], *prop = NULL;
        struct swm_region       *r;
-       long                    mask;
+       long                    mask = 0;
        const char              *errstr;
        XWindowChanges          wc;
        struct pid_e            *p;
@@ -5945,7 +5942,7 @@ manage_window(Window id)
        if (border_me) {
                bzero(&wc, sizeof wc);
                wc.border_width = border_width;
-               mask = CWBorderWidth;
+               mask |= CWBorderWidth;
                XConfigureWindow(display, win->id, mask, &wc);
        }
 
@@ -6972,44 +6969,39 @@ main(int argc, char *argv[])
 
        /* load config */
        for (i = 0; ; i++) {
+               conf[0] = '\0';
                switch (i) {
                case 0:
                        /* ~ */
                        snprintf(conf, sizeof conf, "%s/.%s",
                            pwd->pw_dir, SWM_CONF_FILE);
-                       if (stat(conf, &sb) != -1)
-                               if (S_ISREG(sb.st_mode))
-                                       cfile = conf;
                        break;
                case 1:
                        /* global */
                        snprintf(conf, sizeof conf, "/etc/%s",
                            SWM_CONF_FILE);
-                       if (stat(conf, &sb) != -1)
-                               if (S_ISREG(sb.st_mode))
-                                       cfile = conf;
                        break;
                case 2:
                        /* ~ compat */
                        snprintf(conf, sizeof conf, "%s/.%s",
                            pwd->pw_dir, SWM_CONF_FILE_OLD);
-                       if (stat(conf, &sb) != -1)
-                               if (S_ISREG(sb.st_mode))
-                                       cfile = conf;
                        break;
                case 3:
                        /* global compat */
                        snprintf(conf, sizeof conf, "/etc/%s",
                            SWM_CONF_FILE_OLD);
-                       if (stat(conf, &sb) != -1)
-                               if (S_ISREG(sb.st_mode))
-                                       cfile = conf;
                        break;
                default:
-                       cfile = NULL;
-                       break;
+                       goto noconfig;
                }
+
+               if (strlen(conf) && stat(conf, &sb) != -1)
+                       if (S_ISREG(sb.st_mode)) {
+                               cfile = conf;
+                               break;
+                       }
        }
+noconfig:
 
        /* load conf (if any) and refresh font color in bar graphics contexts */
        if (cfile && conf_load(cfile, SWM_CONF_DEFAULT) == 0)