aewl

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, 27 insertions(+), 46 deletions(-) [+]
line diff
     1.1 --- a/dwm.c	Fri May 30 00:34:38 2008 +0200
     1.2 +++ b/dwm.c	Fri May 30 21:57:51 2008 +0200
     1.3 @@ -58,11 +58,6 @@
     1.4  enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
     1.5  enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
     1.6  
     1.7 -typedef union {
     1.8 -	const char *cmd;
     1.9 -	int i;
    1.10 -} Arg; /* argument type */
    1.11 -
    1.12  typedef struct {
    1.13  	int ascent;
    1.14  	int descent;
    1.15 @@ -111,8 +106,8 @@
    1.16  typedef struct {
    1.17  	unsigned long mod;
    1.18  	KeySym keysym;
    1.19 -	void (*func)(Arg *arg);
    1.20 -	Arg arg;
    1.21 +	void (*func)(const char* cmd);
    1.22 +	const char* cmd;
    1.23  } Key;
    1.24  
    1.25  
    1.26 @@ -160,7 +155,6 @@
    1.27  void focus(Client *c);			/* focus c, c may be NULL */
    1.28  Client *getclient(Window w);		/* return client of w */
    1.29  Bool isprotodel(Client *c);		/* returns True if c->win supports wmatom[WMDelete] */
    1.30 -void killclient();		/* kill c nicely */
    1.31  void manage(Window w, XWindowAttributes *wa);	/* manage new client */
    1.32  void resize(Client *c, Bool sizehints);	/* resize c*/
    1.33  void updatesizehints(Client *c);		/* update the size hint variables of c */
    1.34 @@ -178,7 +172,6 @@
    1.35  void procevent(void);			/* process pending X events */
    1.36  
    1.37  /* main.c */
    1.38 -void quit();			/* quit dwm nicely */
    1.39  void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
    1.40  int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
    1.41  
    1.42 @@ -186,27 +179,31 @@
    1.43  void initrregs(void);			/* initialize regexps of rules defined in config.h */
    1.44  Client *getnext(Client *c);		/* returns next visible client */
    1.45  void settags(Client *c, Client *trans);	/* sets tags of c */
    1.46 -void toggletag();		/* toggles c tags with arg's index */
    1.47  
    1.48  /* util.c */
    1.49  void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
    1.50  void eprint(const char *errstr, ...);	/* prints errstr and exits with 1 */
    1.51 -void spawn(Arg *arg);			/* forks a new subprocess with to arg's cmd */
    1.52  
    1.53  /* view.c */
    1.54  void detach(Client *c);			/* detaches c from global client list */
    1.55  void dofloat(void);			/* arranges all windows floating */
    1.56  void dotile(void);			/* arranges all windows tiled */
    1.57  void domax(void);            /* arranges all windows fullscreen */
    1.58 -void focusnext();		/* focuses next visible client, arg is ignored  */
    1.59 +Bool isvisible(Client *c);		/* returns True if client is visible */
    1.60 +void restack(void);			/* restores z layers of all clients */
    1.61 +
    1.62 +
    1.63 +void toggleview();			/* toggle the viewed tag */
    1.64 +void focusnext();		/* focuses next visible client  */
    1.65 +void zoom();			/* zooms the focused client to master area */
    1.66 +void killclient();		/* kill c nicely */
    1.67 +void quit();			/* quit dwm nicely */
    1.68 +void togglemode();		/* toggles global arrange function (dotile/dofloat) */
    1.69 +void togglefloat();		/* toggles focusesd client between floating/non-floating state */
    1.70  void incnmaster();		/* increments nmaster */
    1.71  void decnmaster();		/* decrements nmaster */
    1.72 -Bool isvisible(Client *c);		/* returns True if client is visible */
    1.73 -void restack(void);			/* restores z layers of all clients */
    1.74 -void togglefloat();		/* toggles focusesd client between floating/non-floating state */
    1.75 -void togglemode();		/* toggles global arrange function (dotile/dofloat) */
    1.76 -void toggleview();			/* views the tag with arg's index */
    1.77 -void zoom();			/* zooms the focused client to master area, arg is ignored */
    1.78 +void toggletag();		/* toggles c tag */
    1.79 +void spawn(const char* cmd);			/* forks a new subprocess with cmd */
    1.80  
    1.81  
    1.82  
    1.83 @@ -538,12 +535,12 @@
    1.84  }
    1.85  
    1.86  void
    1.87 -spawn(Arg *arg) {
    1.88 +spawn(const char* cmd) {
    1.89  	static char *shell = NULL;
    1.90  
    1.91  	if(!shell && !(shell = getenv("SHELL")))
    1.92  		shell = "/bin/sh";
    1.93 -	if(!arg->cmd)
    1.94 +	if(!cmd)
    1.95  		return;
    1.96  	/* The double-fork construct avoids zombie processes and keeps the code
    1.97  	 * clean from stupid signal handlers. */
    1.98 @@ -552,8 +549,8 @@
    1.99  			if(dpy)
   1.100  				close(ConnectionNumber(dpy));
   1.101  			setsid();
   1.102 -			execl(shell, shell, "-c", arg->cmd, (char *)NULL);
   1.103 -			fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
   1.104 +			execl(shell, shell, "-c", cmd, (char *)NULL);
   1.105 +			fprintf(stderr, "dwm: execl '%s -c %s'", shell, cmd);
   1.106  			perror(" failed");
   1.107  		}
   1.108  		exit(0);
   1.109 @@ -756,38 +753,23 @@
   1.110  static void
   1.111  buttonpress(XEvent *e) {
   1.112  	int x;
   1.113 -	Arg a;
   1.114 +	int i;
   1.115  	Client *c;
   1.116  	XButtonPressedEvent *ev = &e->xbutton;
   1.117  
   1.118  	if(barwin == ev->window) {
   1.119 -		x = 0;
   1.120 -		for(a.i = 0; a.i < ntags; a.i++) {
   1.121 -			x += textw(tags[a.i]);
   1.122 -			if(ev->x < x) {
   1.123 -				if(ev->button == Button1) {
   1.124 -					toggleview();
   1.125 -				}
   1.126 -				return;
   1.127 -			}
   1.128 +		if(ev->button == Button1) {
   1.129 +			toggleview();
   1.130  		}
   1.131 -		if(ev->x < x + bmw)
   1.132 -			if (ev->button == Button1) {
   1.133 -				togglemode(NULL);
   1.134 -			}
   1.135 -	}
   1.136 -	else if((c = getclient(ev->window))) {
   1.137 +		return;
   1.138 +	} else if((c = getclient(ev->window))) {
   1.139  		focus(c);
   1.140  		if(CLEANMASK(ev->state) != MODKEY)
   1.141  			return;
   1.142  		if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
   1.143  			restack();
   1.144  			movemouse(c);
   1.145 -		}
   1.146 -		else if(ev->button == Button2)
   1.147 -			zoom(NULL);
   1.148 -		else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
   1.149 -				!c->isfixed) {
   1.150 +		} else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) && !c->isfixed) {
   1.151  			restack();
   1.152  			resizemouse(c);
   1.153  		}
   1.154 @@ -830,8 +812,7 @@
   1.155  		}
   1.156  		else
   1.157  			arrange();
   1.158 -	}
   1.159 -	else {
   1.160 +	} else {
   1.161  		wc.x = ev->x;
   1.162  		wc.y = ev->y;
   1.163  		wc.width = ev->width;
   1.164 @@ -890,7 +871,7 @@
   1.165  	for(i = 0; i < len; i++) {
   1.166  		if(keysym == key[i].keysym && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) {
   1.167  			if(key[i].func)
   1.168 -				key[i].func(&key[i].arg);
   1.169 +				key[i].func(key[i].cmd);
   1.170  		}
   1.171  	}
   1.172  }