aewl

diff event.c @ 123:61490330e90a

cleaned up code
author arg@10ksloc.org
date Thu, 20 Jul 2006 12:18:06 +0200
parents eb3165734f00
children 75576e44c1d8
line diff
     1.1 --- a/event.c	Thu Jul 20 10:48:22 2006 +0200
     1.2 +++ b/event.c	Thu Jul 20 12:18:06 2006 +0200
     1.3 @@ -20,50 +20,44 @@
     1.4  	Arg arg;
     1.5  } Key;
     1.6  
     1.7 -/*
     1.8  const char *browse[] = { "firefox", NULL };
     1.9  const char *gimp[] = { "gimp", NULL };
    1.10 -*/
    1.11 -const char *term[] = { "xterm", NULL };
    1.12 -/*
    1.13 +const char *term[] = { 
    1.14  	"urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
    1.15  	"-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL
    1.16  };
    1.17 -coonst char *xlock[] = { "xlock", NULL };
    1.18 -*/
    1.19 +const char *xlock[] = { "xlock", NULL };
    1.20  
    1.21  static Key key[] = {
    1.22 -	/* modifier				key			function	arguments */
    1.23 -	{ ControlMask,			XK_0,		appendtag,	{ .i = Tscratch } }, 
    1.24 -	{ ControlMask,			XK_1,		appendtag,	{ .i = Tdev } }, 
    1.25 -	{ ControlMask,			XK_2,		appendtag,	{ .i = Twww } }, 
    1.26 -	{ ControlMask,			XK_3,		appendtag,	{ .i = Twork } }, 
    1.27 -	{ MODKEY,				XK_0,		view,		{ .i = Tscratch } }, 
    1.28 -	{ MODKEY,				XK_1,		view,		{ .i = Tdev } }, 
    1.29 -	{ MODKEY,				XK_2,		view,		{ .i = Twww } }, 
    1.30 -	{ MODKEY,				XK_3,		view,		{ .i = Twork } }, 
    1.31 -	{ MODKEY,				XK_j,		focusnext,		{ 0 } }, 
    1.32 -	{ MODKEY,				XK_k,		focusprev,		{ 0 } },
    1.33 -	{ MODKEY,				XK_m,		maximize,		{ 0 } }, 
    1.34 -	{ MODKEY,				XK_space,	dotile,		{ 0 } }, 
    1.35 -	{ MODKEY,				XK_Return,	zoom,		{ 0 } },
    1.36 +	/* modifier		key		function	arguments */
    1.37 +	{ ControlMask,		XK_0,		appendtag,	{ .i = Tscratch } }, 
    1.38 +	{ ControlMask,		XK_1,		appendtag,	{ .i = Tdev } }, 
    1.39 +	{ ControlMask,		XK_2,		appendtag,	{ .i = Twww } }, 
    1.40 +	{ ControlMask,		XK_3,		appendtag,	{ .i = Twork } }, 
    1.41 +	{ MODKEY,		XK_0,		view,		{ .i = Tscratch } }, 
    1.42 +	{ MODKEY,		XK_1,		view,		{ .i = Tdev } }, 
    1.43 +	{ MODKEY,		XK_2,		view,		{ .i = Twww } }, 
    1.44 +	{ MODKEY,		XK_3,		view,		{ .i = Twork } }, 
    1.45 +	{ MODKEY,		XK_j,		focusnext,	{ 0 } }, 
    1.46 +	{ MODKEY,		XK_k,		focusprev,	{ 0 } },
    1.47 +	{ MODKEY,		XK_m,		maximize,	{ 0 } }, 
    1.48 +	{ MODKEY,		XK_space,	dotile,		{ 0 } }, 
    1.49 +	{ MODKEY,		XK_Return,	zoom,		{ 0 } },
    1.50  	{ ControlMask|ShiftMask,XK_0,		heretag,	{ .i = Tscratch } }, 
    1.51  	{ ControlMask|ShiftMask,XK_1,		heretag,	{ .i = Tdev } }, 
    1.52  	{ ControlMask|ShiftMask,XK_2,		heretag,	{ .i = Twww } }, 
    1.53  	{ ControlMask|ShiftMask,XK_3,		heretag,	{ .i = Twork } }, 
    1.54 -	{ MODKEY|ShiftMask,		XK_0,		replacetag,		{ .i = Tscratch } }, 
    1.55 -	{ MODKEY|ShiftMask,		XK_1,		replacetag,		{ .i = Tdev } }, 
    1.56 -	{ MODKEY|ShiftMask,		XK_2,		replacetag,		{ .i = Twww } }, 
    1.57 -	{ MODKEY|ShiftMask,		XK_3,		replacetag,		{ .i = Twork } }, 
    1.58 -	{ MODKEY|ShiftMask,		XK_c,		killclient,		{ 0 } }, 
    1.59 -	/*
    1.60 -	{ MODKEY|ShiftMask,		XK_g,		spawn,		{ .argv = gimp } },
    1.61 -	{ MODKEY|ShiftMask,		XK_l,		spawn,		{ .argv = xlock } },
    1.62 -	*/
    1.63 -	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } },
    1.64 -	{ MODKEY|ShiftMask,		XK_space,	dofloat,	{ 0 } }, 
    1.65 -	/*{ MODKEY|ShiftMask,		XK_w,		spawn,		{ .argv = browse } },*/
    1.66 -	{ MODKEY|ShiftMask,		XK_Return,	spawn,		{ .argv = term } },
    1.67 +	{ MODKEY|ShiftMask,	XK_0,		replacetag,	{ .i = Tscratch } }, 
    1.68 +	{ MODKEY|ShiftMask,	XK_1,		replacetag,	{ .i = Tdev } }, 
    1.69 +	{ MODKEY|ShiftMask,	XK_2,		replacetag,	{ .i = Twww } }, 
    1.70 +	{ MODKEY|ShiftMask,	XK_3,		replacetag,	{ .i = Twork } }, 
    1.71 +	{ MODKEY|ShiftMask,	XK_c,		killclient,	{ 0 } }, 
    1.72 +	{ MODKEY|ShiftMask,	XK_g,		spawn,		{ .argv = gimp } },
    1.73 +	{ MODKEY|ShiftMask,	XK_l,		spawn,		{ .argv = xlock } },
    1.74 +	{ MODKEY|ShiftMask,	XK_q,		quit,		{ 0 } },
    1.75 +	{ MODKEY|ShiftMask,	XK_space,	dofloat,	{ 0 } }, 
    1.76 +	{ MODKEY|ShiftMask,	XK_w,		spawn,		{ .argv = browse } },
    1.77 +	{ MODKEY|ShiftMask,	XK_Return,	spawn,		{ .argv = term } },
    1.78  };
    1.79  
    1.80  /* static */
    1.81 @@ -71,15 +65,15 @@
    1.82  static void
    1.83  movemouse(Client *c)
    1.84  {
    1.85 -	XEvent ev;
    1.86  	int x1, y1, ocx, ocy, di;
    1.87  	unsigned int dui;
    1.88  	Window dummy;
    1.89 +	XEvent ev;
    1.90  
    1.91  	ocx = c->x;
    1.92  	ocy = c->y;
    1.93  	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
    1.94 -				None, cursor[CurMove], CurrentTime) != GrabSuccess)
    1.95 +			None, cursor[CurMove], CurrentTime) != GrabSuccess)
    1.96  		return;
    1.97  	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
    1.98  	for(;;) {
    1.99 @@ -105,9 +99,9 @@
   1.100  static void
   1.101  resizemouse(Client *c)
   1.102  {
   1.103 -	XEvent ev;
   1.104  	int ocx, ocy;
   1.105  	Corner sticky;
   1.106 +	XEvent ev;
   1.107  
   1.108  	ocx = c->x;
   1.109  	ocy = c->y;
   1.110 @@ -146,8 +140,8 @@
   1.111  {
   1.112  	int x;
   1.113  	Arg a;
   1.114 +	Client *c;
   1.115  	XButtonPressedEvent *ev = &e->xbutton;
   1.116 -	Client *c;
   1.117  
   1.118  	if(barwin == ev->window) {
   1.119  		switch(ev->button) {
   1.120 @@ -201,9 +195,9 @@
   1.121  static void
   1.122  configurerequest(XEvent *e)
   1.123  {
   1.124 +	Client *c;
   1.125  	XConfigureRequestEvent *ev = &e->xconfigurerequest;
   1.126  	XWindowChanges wc;
   1.127 -	Client *c;
   1.128  
   1.129  	ev->value_mask &= ~CWSibling;
   1.130  	if((c = getclient(ev->window))) {
   1.131 @@ -248,8 +242,8 @@
   1.132  static void
   1.133  enternotify(XEvent *e)
   1.134  {
   1.135 +	Client *c;
   1.136  	XCrossingEvent *ev = &e->xcrossing;
   1.137 -	Client *c;
   1.138  
   1.139  	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
   1.140  		return;
   1.141 @@ -263,8 +257,8 @@
   1.142  static void
   1.143  expose(XEvent *e)
   1.144  {
   1.145 +	Client *c;
   1.146  	XExposeEvent *ev = &e->xexpose;
   1.147 -	Client *c;
   1.148  
   1.149  	if(ev->count == 0) {
   1.150  		if(barwin == ev->window)
   1.151 @@ -277,10 +271,10 @@
   1.152  static void
   1.153  keypress(XEvent *e)
   1.154  {
   1.155 -	XKeyEvent *ev = &e->xkey;
   1.156  	static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
   1.157  	unsigned int i;
   1.158  	KeySym keysym;
   1.159 +	XKeyEvent *ev = &e->xkey;
   1.160  
   1.161  	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
   1.162  	for(i = 0; i < len; i++)
   1.163 @@ -303,8 +297,8 @@
   1.164  static void
   1.165  maprequest(XEvent *e)
   1.166  {
   1.167 +	static XWindowAttributes wa;
   1.168  	XMapRequestEvent *ev = &e->xmaprequest;
   1.169 -	static XWindowAttributes wa;
   1.170  
   1.171  	if(!XGetWindowAttributes(dpy, ev->window, &wa))
   1.172  		return;
   1.173 @@ -322,9 +316,9 @@
   1.174  static void
   1.175  propertynotify(XEvent *e)
   1.176  {
   1.177 +	Client *c;
   1.178 +	Window trans;
   1.179  	XPropertyEvent *ev = &e->xproperty;
   1.180 -	Window trans;
   1.181 -	Client *c;
   1.182  
   1.183  	if(ev->state == PropertyDelete)
   1.184  		return; /* ignore */