sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 5d3fb382442552f3eaafc0446b226958845ea322
parent 389dd8c8c68bcc6672f34708bcbae6e1fd1b2fdb
Author: William Light <wrl@illest.net>
Date:   Sat, 25 Sep 2010 15:00:49 -0700

fixed segfault with pertag when creating new monitors while dwm is running (i.e. with xrandr)

test case:
1) start dwm
2) plug in a second monitor and bring it up with xrandr, setting it RightOf the current screen
3) select the new monitor (modkey-,)
4) switch to a different tag
Diffstat:
Mdwm.suckless.org/patches/dwm-5.8.2-pertag.diff | 76++++++++++++++++++++++++++++++++++++----------------------------------------
Mdwm.suckless.org/patches/dwm-5.8.2-pertag_without_bar.diff | 94++++++++++++++++++++++++++++---------------------------------------------------
Mdwm.suckless.org/patches/pertag.md | 1+
3 files changed, 70 insertions(+), 101 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-5.8.2-pertag.diff b/dwm.suckless.org/patches/dwm-5.8.2-pertag.diff @@ -1,7 +1,7 @@ -diff -r cb309a6cea4b dwm.c ---- a/dwm.c Wed Jun 02 18:24:24 2010 +0200 -+++ b/dwm.c Thu Jun 03 18:47:50 2010 +0200 -@@ -121,26 +121,6 @@ +diff --git a/dwm.c b/dwm.c +--- a/dwm.c ++++ b/dwm.c +@@ -122,26 +122,6 @@ typedef struct { void (*arrange)(Monitor *); } Layout; @@ -28,7 +28,7 @@ diff -r cb309a6cea4b dwm.c typedef struct { const char *class; const char *instance; -@@ -275,6 +255,31 @@ +@@ -278,6 +258,31 @@ static Window root; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -60,7 +60,31 @@ diff -r cb309a6cea4b dwm.c /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; -@@ -1467,7 +1472,7 @@ +@@ -609,6 +614,7 @@ configurerequest(XEvent *e) { + Monitor * + createmon(void) { + Monitor *m; ++ unsigned int i; + + if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) + die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); +@@ -619,6 +625,15 @@ createmon(void) { + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); ++ ++ /* pertag init */ ++ m->curtag = m->prevtag = 1; ++ for(i=0; i < LENGTH(tags) + 1 ; i++) { ++ m->mfacts[i] = mfact; ++ m->lts[i] = &layouts[0]; ++ m->showbars[i] = m->showbar; ++ } ++ + return m; + } + +@@ -1486,7 +1501,7 @@ setlayout(const Arg *arg) { if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) selmon->sellt ^= 1; if(arg && arg->v) @@ -69,7 +93,7 @@ diff -r cb309a6cea4b dwm.c strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if(selmon->sel) arrange(selmon); -@@ -1485,13 +1490,15 @@ +@@ -1504,7 +1519,7 @@ setmfact(const Arg *arg) { f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; if(f < 0.1 || f > 0.9) return; @@ -78,43 +102,15 @@ diff -r cb309a6cea4b dwm.c arrange(selmon); } - void - setup(void) { - XSetWindowAttributes wa; -+ Monitor *m; -+ unsigned int i; - - /* clean up any zombies immediately */ - sigchld(0); -@@ -1527,7 +1534,27 @@ +@@ -1547,7 +1562,6 @@ setup(void) { XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) XSetFont(dpy, dc.gc, dc.font.xfont->fid); -+ /* init tags */ -+ for(m = mons; m; m = m->next) -+ m->curtag = m->prevtag = 1; -+ /* init mfacts */ -+ for(m = mons; m; m = m->next) { -+ for(i=0; i < LENGTH(tags) + 1 ; i++) { -+ m->mfacts[i] = m->mfact; -+ } -+ } -+ /* init layouts */ -+ for(m = mons; m; m = m->next) { -+ for(i=0; i < LENGTH(tags) + 1; i++) { -+ m->lts[i] = &layouts[0]; -+ } -+ } - /* init bars */ -+ for(m = mons; m; m = m->next) { -+ for(i=0; i < LENGTH(tags) + 1; i++) { -+ m->showbars[i] = m->showbar; -+ } -+ } +- /* init bars */ updatebars(); updatestatus(); /* EWMH support per view */ -@@ -1638,7 +1665,7 @@ +@@ -1658,7 +1672,7 @@ tile(Monitor *m) { void togglebar(const Arg *arg) { @@ -123,7 +119,7 @@ diff -r cb309a6cea4b dwm.c updatebarpos(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); arrange(selmon); -@@ -1658,12 +1685,27 @@ +@@ -1678,12 +1692,27 @@ togglefloating(const Arg *arg) { void toggletag(const Arg *arg) { unsigned int newtags; @@ -151,7 +147,7 @@ diff -r cb309a6cea4b dwm.c arrange(selmon); } } -@@ -1930,11 +1972,29 @@ +@@ -1950,11 +1979,29 @@ updatewmhints(Client *c) { void view(const Arg *arg) { diff --git a/dwm.suckless.org/patches/dwm-5.8.2-pertag_without_bar.diff b/dwm.suckless.org/patches/dwm-5.8.2-pertag_without_bar.diff @@ -1,9 +1,7 @@ -diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c ---- dwm-5.8.2/dwm.c 2010-06-04 12:39:15.000000000 +0200 -+++ dwm-5.8.2-pertag/dwm.c 2010-06-15 17:59:56.000000000 +0200 -@@ -120,30 +120,10 @@ - typedef struct { - const char *symbol; +diff --git a/dwm.c b/dwm.c +--- a/dwm.c ++++ b/dwm.c +@@ -122,26 +122,6 @@ typedef struct { void (*arrange)(Monitor *); } Layout; @@ -30,11 +28,7 @@ diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c typedef struct { const char *class; const char *instance; - const char *title; - unsigned int tags; -@@ -276,10 +256,34 @@ - static Window root; - +@@ -278,6 +258,30 @@ static Window root; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -65,11 +59,30 @@ diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; - /* function implementations */ - void -@@ -1492,11 +1496,11 @@ - void - setlayout(const Arg *arg) { +@@ -609,6 +613,7 @@ configurerequest(XEvent *e) { + Monitor * + createmon(void) { + Monitor *m; ++ unsigned int i; + + if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) + die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); +@@ -619,6 +624,14 @@ createmon(void) { + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); ++ ++ /* pertag init */ ++ m->curtag = m->prevtag = 1; ++ for(i=0; i < LENGTH(tags) + 1 ; i++) { ++ m->mfacts[i] = mfact; ++ m->lts[i] = &layouts[0]; ++ } ++ + return m; + } + +@@ -1486,7 +1499,7 @@ setlayout(const Arg *arg) { if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) selmon->sellt ^= 1; if(arg && arg->v) @@ -78,11 +91,7 @@ diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if(selmon->sel) arrange(selmon); - else - drawbar(selmon); -@@ -1510,17 +1514,19 @@ - if(!arg || !selmon->lt[selmon->sellt]->arrange) - return; +@@ -1504,7 +1517,7 @@ setmfact(const Arg *arg) { f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; if(f < 0.1 || f > 0.9) return; @@ -91,46 +100,15 @@ diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c arrange(selmon); } - void - setup(void) { - XSetWindowAttributes wa; -+ Monitor *m; -+ unsigned int i; - - /* clean up any zombies immediately */ - sigchld(0); - - /* init screen */ -@@ -1553,11 +1559,25 @@ - dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); - dc.gc = XCreateGC(dpy, root, 0, NULL); +@@ -1547,7 +1560,6 @@ setup(void) { XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) XSetFont(dpy, dc.gc, dc.font.xfont->fid); - /* init bars */ -+ /* init tags */ -+ for(m = mons; m; m = m->next) -+ m->curtag = m->prevtag = 1; -+ /* init mfacts */ -+ for(m = mons; m; m = m->next) { -+ for(i=0; i < LENGTH(tags) + 1 ; i++) { -+ m->mfacts[i] = m->mfact; -+ } -+ } -+ /* init layouts */ -+ for(m = mons; m; m = m->next) { -+ for(i=0; i < LENGTH(tags) + 1; i++) { -+ m->lts[i] = &layouts[0]; -+ } -+ } updatebars(); updatestatus(); /* EWMH support per view */ - XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, - PropModeReplace, (unsigned char *) netatom, NetLast); -@@ -1684,16 +1704,29 @@ - } - +@@ -1678,12 +1690,25 @@ togglefloating(const Arg *arg) { void toggletag(const Arg *arg) { unsigned int newtags; @@ -156,11 +134,7 @@ diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c arrange(selmon); } } - - void -@@ -1957,15 +1990,31 @@ - } - } +@@ -1950,11 +1975,27 @@ updatewmhints(Client *c) { void view(const Arg *arg) { @@ -189,5 +163,3 @@ diff -NU5 -r dwm-5.8.2/dwm.c dwm-5.8.2-pertag/dwm.c arrange(selmon); } - Client * - wintoclient(Window w) { diff --git a/dwm.suckless.org/patches/pertag.md b/dwm.suckless.org/patches/pertag.md @@ -25,6 +25,7 @@ Authors * Updated by V4hn - `v4hn.de` * Updated by Jerome Andrieux - `<jerome at gcu dot info>` * Updated by Sidney Amani - `<seed at uffs dot org>` +* Updated by William Light - `<wrl at illest dot net>` [1]: http://www.e-jc.de/dwm/4.6/current/dwm-4.6-pertag.diff [2]: http://www.e-jc.de/dwm/4.6/current/dwm-4.6-pertag_nmaster.diff