aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/dwm.c b/dwm.c
index eec383a..9a25210 100644
--- a/dwm.c
+++ b/dwm.c
@@ -258,6 +258,8 @@ static void setmfact(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
+static void sighup(int unused);
+static void sigterm(int unused);
static void spawn(const Arg *arg);
static Monitor *systraytomon(Monitor *m);
static void switchtag(const Arg *arg);
@@ -333,6 +335,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
+static int restart = 0;
static int running = 1;
static Cur *cursor[CurLast];
static Clr **scheme;
@@ -654,24 +657,24 @@ bstack(Monitor *m) {
if (n == 0)
return;
if (n > m->nmaster) {
- mh = m->nmaster ? m->mfact * m->wh : 0;
- tw = m->ww / (n - m->nmaster);
+ mh = m->nmaster ? m->mfact * m->wh - m->gappx : 0;
+ tw = m->ww / (n - m->nmaster) - m->gappx;
ty = m->wy + mh;
} else {
mh = m->wh;
tw = m->ww;
ty = m->wy;
}
- for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ for (i = mx = m->gappx, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
if (i < m->nmaster) {
- w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
- mx += WIDTH(c);
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i) - m->gappx;
+ resize(c, m->wx + mx + m->gappx, m->wy, w - (2 * c->bw) - m->gappx, mh - (2 * c->bw), 0);
+ mx += WIDTH(c) + m->gappx;
} else {
- h = m->wh - mh;
- resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
- if (tw != m->ww)
- tx += WIDTH(c);
+ h = m->wh - mh - m->gappx;
+ resize(c, tx + m->gappx, ty, tw - (2 * c->bw) - 2 * m->gappx, h - (2 * c->bw), 0);
+ if (tw + m->gappx != m->ww)
+ tx += WIDTH(c) + m->gappx;
}
}
}
@@ -2011,6 +2014,8 @@ propertynotify(XEvent *e)
void
quit(const Arg *arg)
{
+ if (arg->i)
+ restart = 1;
running = 0;
}
@@ -2361,6 +2366,9 @@ setup(void)
/* clean up any zombies (inherited from .xinitrc etc) immediately */
while (waitpid(-1, NULL, WNOHANG) > 0);
+ signal(SIGHUP, sighup);
+ signal(SIGTERM, sigterm);
+
/* init screen */
screen = DefaultScreen(dpy);
sw = DisplayWidth(dpy, screen);
@@ -2467,6 +2475,20 @@ showhide(Client *c)
}
void
+sighup(int unused)
+{
+ Arg a = {.i = 1};
+ quit(&a);
+}
+
+void
+sigterm(int unused)
+{
+ Arg a = {.i = 0};
+ quit(&a);
+}
+
+void
spawn(const Arg *arg)
{
struct sigaction sa;
@@ -3578,6 +3600,8 @@ main(int argc, char *argv[])
#endif /* __OpenBSD__ */
scan();
run();
+ if (restart)
+ execvp(argv[0], argv);
cleanup();
XCloseDisplay(dpy);
return EXIT_SUCCESS;