JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Describe HUP
[spectrwm.git] / scrotwm.c
index 2757863..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;
@@ -2113,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 ||
@@ -2294,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);
@@ -3503,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
@@ -3558,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)
@@ -3650,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 },
 };
 
 
@@ -4908,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) {