JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Describe HUP
[spectrwm.git] / scrotwm.c
index ce3cd62..67ad17a 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -168,6 +168,7 @@ Atom                        aprot;
 Atom                   adelete;
 Atom                   takefocus;
 volatile sig_atomic_t   running = 1;
+volatile sig_atomic_t   restart_wm = 0;
 int                    outputs = 0;
 int                    last_focus_event = FocusOut;
 int                    (*xerrorxlib)(Display *, XErrorEvent *);
@@ -206,6 +207,7 @@ char                        *clock_format = NULL;
 int                    title_name_enabled = 0;
 int                    title_class_enabled = 0;
 int                    focus_mode = SWM_FOCUS_DEFAULT;
+int                    disable_border = 0;
 pid_t                  bar_pid;
 GC                     bar_gc;
 XGCValues              bar_gcv;
@@ -607,9 +609,11 @@ sighdlr(int sig)
                                break;
                }
                break;
+       case SIGHUP:
+               restart_wm = 1;
+               break;
        case SIGINT:
        case SIGTERM:
-       case SIGHUP:
        case SIGQUIT:
                running = 0;
                break;
@@ -774,6 +778,7 @@ bar_update(void)
        int                     i, x;
        size_t                  len;
        char                    s[SWM_BAR_MAX];
+       char                    cn[SWM_BAR_MAX];
        char                    loc[SWM_BAR_MAX];
        char                    *b;
        char                    *stack = "";
@@ -807,14 +812,15 @@ bar_update(void)
        for (i = 0; i < ScreenCount(display); i++) {
                x = 1;
                TAILQ_FOREACH(r, &screens[i].rl, entry) {
+                       strlcpy(cn, "", sizeof cn);
                        if (r && r->ws)
-                               bar_class_name(s, sizeof s, r->ws->focus);
+                               bar_class_name(cn, sizeof cn, r->ws->focus);
 
                        if (stack_enabled)
                                stack = r->ws->cur_layout->name;
 
-                       snprintf(loc, sizeof loc, "%d:%d %s   %s    %s    %s",
-                           x++, r->ws->idx + 1, stack, s, bar_ext,
+                       snprintf(loc, sizeof loc, "%d:%d %s   %s%s    %s    %s",
+                           x++, r->ws->idx + 1, stack, s, cn, bar_ext,
                            bar_vertext);
                        bar_print(r, loc);
                }
@@ -2111,7 +2117,12 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
                        win_g.y += last_h + 2;
 
                bzero(&wc, sizeof wc);
-               wc.border_width = 1;
+               if (disable_border && bar_enabled == 0 && winno == 1){
+                       wc.border_width = 0;
+                       win_g.w += 2;
+                       win_g.h += 2;
+               } else
+                       wc.border_width = 1;
                reconfigure = 0;
                if (rot) {
                        if (win->g.x != win_g.y || win->g.y != win_g.x ||
@@ -2292,11 +2303,17 @@ max_stack(struct workspace *ws, struct swm_geometry *g)
                if (win->g.x != gg.x || win->g.y != gg.y || win->g.w != gg.w ||
                    win->g.h != gg.h) {
                        bzero(&wc, sizeof wc);
-                       wc.border_width = 1;
                        win->g.x = wc.x = gg.x;
                        win->g.y = wc.y = gg.y;
-                       win->g.w = wc.width = gg.w;
-                       win->g.h = wc.height = gg.h;
+                       if (bar_enabled){
+                               wc.border_width = 1;
+                               win->g.w = wc.width = gg.w;
+                               win->g.h = wc.height = gg.h;
+                       } else {
+                               wc.border_width = 0;
+                               win->g.w = wc.width = gg.w + 2;
+                               win->g.h = wc.height = gg.h + 2;
+                       }
                        mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
                        XConfigureWindow(display, win->id, mask, &wc);
                        configreq_win(win);
@@ -3501,8 +3518,8 @@ enum      { SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, SWM_S_STACK_ENABLED,
          SWM_S_CLOCK_ENABLED, SWM_S_CLOCK_FORMAT, SWM_S_CYCLE_EMPTY,
          SWM_S_CYCLE_VISIBLE, SWM_S_SS_ENABLED, SWM_S_TERM_WIDTH,
          SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_NAME_ENABLED,
-         SWM_S_FOCUS_MODE, SWM_S_BAR_FONT, SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM,
-         SWM_S_SS_APP, SWM_S_DIALOG_RATIO
+         SWM_S_FOCUS_MODE, SWM_S_DISABLE_BORDER, SWM_S_BAR_FONT,
+         SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM, SWM_S_SS_APP, SWM_S_DIALOG_RATIO
        };
 
 int
@@ -3556,6 +3573,9 @@ setconfvalue(char *selector, char *value, int flags)
                else
                        err(1, "focus_mode");
                break;
+       case SWM_S_DISABLE_BORDER:
+               disable_border = atoi(value);
+               break;
        case SWM_S_BAR_FONT:
                free(bar_fonts[0]);
                if ((bar_fonts[0] = strdup(value)) == NULL)
@@ -3648,6 +3668,7 @@ struct config_option configopt[] = {
        { "title_class_enabled",        setconfvalue,   SWM_S_TITLE_CLASS_ENABLED },
        { "title_name_enabled",         setconfvalue,   SWM_S_TITLE_NAME_ENABLED },
        { "focus_mode",                 setconfvalue,   SWM_S_FOCUS_MODE },
+       { "disable_border",             setconfvalue,   SWM_S_DISABLE_BORDER },
 };
 
 
@@ -4278,9 +4299,6 @@ enternotify(XEvent *e)
 void
 focusevent(XEvent *e)
 {
-       DNPRINTF(SWM_D_EVENT, "focusevent: %s window: %lu mode %d detail %d\n",
-           ev->type == FocusIn ? "entering" : "leaving",
-           ev->window, ev->mode, ev->detail);
 #if 0
        struct ws_win           *win;
        u_int32_t               mode_detail;
@@ -4492,6 +4510,9 @@ new_region(struct swm_screen *s, int x, int y, int w, int h)
                    (X(r) + WIDTH(r)) > x &&
                    Y(r) < (y + h) &&
                    (Y(r) + HEIGHT(r)) > y) {
+                       if (r->ws->r != NULL)
+                               r->ws->old_r = r->ws->r;
+                       r->ws->r = NULL;
                        XDestroyWindow(display, r->bar_window);
                        TAILQ_REMOVE(&s->rl, r, entry);
                        TAILQ_INSERT_TAIL(&s->orl, r, entry);
@@ -4906,6 +4927,8 @@ main(int argc, char *argv[])
                if (select(xfd + 1, &rd, NULL, NULL, &tv) == -1)
                        if (errno != EINTR)
                                DNPRINTF(SWM_D_MISC, "select failed");
+               if (restart_wm == 1)
+                       restart(NULL, NULL);
                if (running == 0)
                        goto done;
                if (bar_alarm) {