X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=29af1bd29499d67dbf7b212b822fef51a54ddc70;hp=5b8747c631e6daa585684ea25b7a8dbab7157a0c;hb=016dca4f694cb51c7db77aeeefcb55b8869f3842;hpb=a8e0772c4d977fafb35c5ab9e29e322a9505b71a diff --git a/dwm.c b/dwm.c index 5b8747c..29af1bd 100644 --- a/dwm.c +++ b/dwm.c @@ -93,11 +93,10 @@ typedef struct { } DC; /* draw context */ typedef union { - const char *c; int i; uint ui; float f; - void *aux; + void *v; } Arg; typedef struct { @@ -225,13 +224,11 @@ static Client *stack = NULL; static Cursor cursor[CurLast]; static Display *dpy; static DC dc = {0}; +static Layout *lt = NULL; static Window root, barwin; - /* configuration, allows nested code to access above variables */ #include "config.h" -static Layout *lt = layouts; - /* compile-time check if all tags fit into an uint bit array. */ struct NumTags { char limitexceeded[sizeof(uint) * 8 < LENGTH(tags) ? -1 : 1]; }; @@ -327,9 +324,9 @@ buttonpress(XEvent *e) { } } if(ev->x < x + blw) { - if(ev->button == Button1) + if(ev->button == Button1) togglelayout(NULL); - else if(ev->button == Button3) + else if(ev->button == Button3) togglemax(NULL); } } @@ -364,8 +361,11 @@ checkotherwm(void) { void cleanup(void) { Arg a = {.i = ~0}; + Layout foo = { "", NULL }; + close(STDIN_FILENO); view(&a); + lt = &foo; while(stack) unmanage(stack); if(dc.font.set) @@ -662,7 +662,7 @@ focusstack(const Arg *arg) { for(i = clients; i != sel; i = i->next) if (!i->isbanned) c = i; - if(!c) + if(!c) for(; i; i = i->next) if (!i->isbanned) c = i; @@ -1323,6 +1323,7 @@ setup(void) { sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); bh = dc.font.height + 2; + lt = layouts; updategeom(); /* init atoms */ @@ -1388,10 +1389,6 @@ setup(void) { void spawn(const Arg *arg) { - static char *shell = NULL; - - if(!shell && !(shell = getenv("SHELL"))) - shell = "/bin/sh"; /* The double-fork construct avoids zombie processes and keeps the code * clean from stupid signal handlers. */ if(fork() == 0) { @@ -1399,8 +1396,8 @@ spawn(const Arg *arg) { if(dpy) close(ConnectionNumber(dpy)); setsid(); - execl(shell, shell, "-c", arg->c, (char *)NULL); - fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->c); + execvp(((char **)arg->v)[0], (char **)arg->v); + fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); perror(" failed"); } exit(0); @@ -1481,20 +1478,10 @@ togglefloating(const Arg *arg) { void togglelayout(const Arg *arg) { - uint i; - - if(!arg->c) { - if(++lt == &layouts[LENGTH(layouts)]) - lt = &layouts[0]; - } - else { - for(i = 0; i < LENGTH(layouts); i++) - if(!strcmp(arg->c, layouts[i].symbol)) - break; - if(i == LENGTH(layouts)) - return; - lt = &layouts[i]; - } + if(arg && arg->v) + lt = (Layout *)arg->v; + else if(++lt == &layouts[LENGTH(layouts)]) + lt = &layouts[0]; if(sel) arrange(); else