changeset 758:bc512840e5a5

removed union arg (using const char* cmd now) whole bar toggles view if clicked now
author meillo@marmaro.de
date Fri, 30 May 2008 21:57:51 +0200
parents 427608ef0687
children 45f23169563e
files dwm.c
diffstat 1 files changed, 26 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/dwm.c	Fri May 30 00:34:38 2008 +0200
+++ b/dwm.c	Fri May 30 21:57:51 2008 +0200
@@ -58,11 +58,6 @@
 enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
 enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
 
-typedef union {
-	const char *cmd;
-	int i;
-} Arg; /* argument type */
-
 typedef struct {
 	int ascent;
 	int descent;
@@ -111,8 +106,8 @@
 typedef struct {
 	unsigned long mod;
 	KeySym keysym;
-	void (*func)(Arg *arg);
-	Arg arg;
+	void (*func)(const char* cmd);
+	const char* cmd;
 } Key;
 
 
@@ -160,7 +155,6 @@
 void focus(Client *c);			/* focus c, c may be NULL */
 Client *getclient(Window w);		/* return client of w */
 Bool isprotodel(Client *c);		/* returns True if c->win supports wmatom[WMDelete] */
-void killclient();		/* kill c nicely */
 void manage(Window w, XWindowAttributes *wa);	/* manage new client */
 void resize(Client *c, Bool sizehints);	/* resize c*/
 void updatesizehints(Client *c);		/* update the size hint variables of c */
@@ -178,7 +172,6 @@
 void procevent(void);			/* process pending X events */
 
 /* main.c */
-void quit();			/* quit dwm nicely */
 void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
 int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
 
@@ -186,27 +179,31 @@
 void initrregs(void);			/* initialize regexps of rules defined in config.h */
 Client *getnext(Client *c);		/* returns next visible client */
 void settags(Client *c, Client *trans);	/* sets tags of c */
-void toggletag();		/* toggles c tags with arg's index */
 
 /* util.c */
 void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
 void eprint(const char *errstr, ...);	/* prints errstr and exits with 1 */
-void spawn(Arg *arg);			/* forks a new subprocess with to arg's cmd */
 
 /* view.c */
 void detach(Client *c);			/* detaches c from global client list */
 void dofloat(void);			/* arranges all windows floating */
 void dotile(void);			/* arranges all windows tiled */
 void domax(void);            /* arranges all windows fullscreen */
-void focusnext();		/* focuses next visible client, arg is ignored  */
-void incnmaster();		/* increments nmaster */
-void decnmaster();		/* decrements nmaster */
 Bool isvisible(Client *c);		/* returns True if client is visible */
 void restack(void);			/* restores z layers of all clients */
-void togglefloat();		/* toggles focusesd client between floating/non-floating state */
+
+
+void toggleview();			/* toggle the viewed tag */
+void focusnext();		/* focuses next visible client  */
+void zoom();			/* zooms the focused client to master area */
+void killclient();		/* kill c nicely */
+void quit();			/* quit dwm nicely */
 void togglemode();		/* toggles global arrange function (dotile/dofloat) */
-void toggleview();			/* views the tag with arg's index */
-void zoom();			/* zooms the focused client to master area, arg is ignored */
+void togglefloat();		/* toggles focusesd client between floating/non-floating state */
+void incnmaster();		/* increments nmaster */
+void decnmaster();		/* decrements nmaster */
+void toggletag();		/* toggles c tag */
+void spawn(const char* cmd);			/* forks a new subprocess with cmd */
 
 
 
@@ -538,12 +535,12 @@
 }
 
 void
-spawn(Arg *arg) {
+spawn(const char* cmd) {
 	static char *shell = NULL;
 
 	if(!shell && !(shell = getenv("SHELL")))
 		shell = "/bin/sh";
-	if(!arg->cmd)
+	if(!cmd)
 		return;
 	/* The double-fork construct avoids zombie processes and keeps the code
 	 * clean from stupid signal handlers. */
@@ -552,8 +549,8 @@
 			if(dpy)
 				close(ConnectionNumber(dpy));
 			setsid();
-			execl(shell, shell, "-c", arg->cmd, (char *)NULL);
-			fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
+			execl(shell, shell, "-c", cmd, (char *)NULL);
+			fprintf(stderr, "dwm: execl '%s -c %s'", shell, cmd);
 			perror(" failed");
 		}
 		exit(0);
@@ -756,38 +753,23 @@
 static void
 buttonpress(XEvent *e) {
 	int x;
-	Arg a;
+	int i;
 	Client *c;
 	XButtonPressedEvent *ev = &e->xbutton;
 
 	if(barwin == ev->window) {
-		x = 0;
-		for(a.i = 0; a.i < ntags; a.i++) {
-			x += textw(tags[a.i]);
-			if(ev->x < x) {
-				if(ev->button == Button1) {
-					toggleview();
-				}
-				return;
-			}
+		if(ev->button == Button1) {
+			toggleview();
 		}
-		if(ev->x < x + bmw)
-			if (ev->button == Button1) {
-				togglemode(NULL);
-			}
-	}
-	else if((c = getclient(ev->window))) {
+		return;
+	} else if((c = getclient(ev->window))) {
 		focus(c);
 		if(CLEANMASK(ev->state) != MODKEY)
 			return;
 		if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
 			restack();
 			movemouse(c);
-		}
-		else if(ev->button == Button2)
-			zoom(NULL);
-		else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
-				!c->isfixed) {
+		} else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) && !c->isfixed) {
 			restack();
 			resizemouse(c);
 		}
@@ -830,8 +812,7 @@
 		}
 		else
 			arrange();
-	}
-	else {
+	} else {
 		wc.x = ev->x;
 		wc.y = ev->y;
 		wc.width = ev->width;
@@ -890,7 +871,7 @@
 	for(i = 0; i < len; i++) {
 		if(keysym == key[i].keysym && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) {
 			if(key[i].func)
-				key[i].func(&key[i].arg);
+				key[i].func(key[i].cmd);
 		}
 	}
 }