aewl
diff event.c @ 75:f08271b7cb20
rearranged several stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Sat, 15 Jul 2006 16:30:50 +0200 |
parents | 5370ef170cc9 |
children | 4bd49f404f10 |
line diff
1.1 --- a/event.c Fri Jul 14 22:54:09 2006 +0200 1.2 +++ b/event.c Sat Jul 15 16:30:50 2006 +0200 1.3 @@ -16,6 +16,44 @@ 1.4 #define ButtonMask (ButtonPressMask | ButtonReleaseMask) 1.5 #define MouseMask (ButtonMask | PointerMotionMask) 1.6 1.7 +/********** CUSTOMIZE **********/ 1.8 + 1.9 +const char *term[] = { 1.10 + "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", 1.11 + "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL 1.12 +}; 1.13 +const char *browse[] = { "firefox", NULL }; 1.14 +const char *xlock[] = { "xlock", NULL }; 1.15 + 1.16 +Key key[] = { 1.17 + /* modifier key function arguments */ 1.18 + { Mod1Mask, XK_Return, zoom, { 0 } }, 1.19 + { Mod1Mask, XK_k, focusprev, { 0 } }, 1.20 + { Mod1Mask, XK_j, focusnext, { 0 } }, 1.21 + { Mod1Mask, XK_m, maximize, { 0 } }, 1.22 + { Mod1Mask, XK_0, view, { .i = Tscratch } }, 1.23 + { Mod1Mask, XK_1, view, { .i = Tdev } }, 1.24 + { Mod1Mask, XK_2, view, { .i = Twww } }, 1.25 + { Mod1Mask, XK_3, view, { .i = Twork } }, 1.26 + { Mod1Mask, XK_space, dotile, { 0 } }, 1.27 + { Mod1Mask|ShiftMask, XK_space, dofloat, { 0 } }, 1.28 + { Mod1Mask|ShiftMask, XK_0, replacetag, { .i = Tscratch } }, 1.29 + { Mod1Mask|ShiftMask, XK_1, replacetag, { .i = Tdev } }, 1.30 + { Mod1Mask|ShiftMask, XK_2, replacetag, { .i = Twww } }, 1.31 + { Mod1Mask|ShiftMask, XK_3, replacetag, { .i = Twork } }, 1.32 + { Mod1Mask|ShiftMask, XK_c, killclient, { 0 } }, 1.33 + { Mod1Mask|ShiftMask, XK_q, quit, { 0 } }, 1.34 + { Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } }, 1.35 + { Mod1Mask|ShiftMask, XK_w, spawn, { .argv = browse } }, 1.36 + { Mod1Mask|ShiftMask, XK_l, spawn, { .argv = xlock } }, 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 +}; 1.42 + 1.43 +/********** CUSTOMIZE **********/ 1.44 + 1.45 /* local functions */ 1.46 static void buttonpress(XEvent *e); 1.47 static void configurerequest(XEvent *e); 1.48 @@ -23,6 +61,7 @@ 1.49 static void enternotify(XEvent *e); 1.50 static void leavenotify(XEvent *e); 1.51 static void expose(XEvent *e); 1.52 +static void keypress(XEvent *e); 1.53 static void maprequest(XEvent *e); 1.54 static void propertynotify(XEvent *e); 1.55 static void unmapnotify(XEvent *e); 1.56 @@ -40,8 +79,40 @@ 1.57 [UnmapNotify] = unmapnotify 1.58 }; 1.59 1.60 +void 1.61 +grabkeys() 1.62 +{ 1.63 + static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0; 1.64 + unsigned int i; 1.65 + KeyCode code; 1.66 + 1.67 + for(i = 0; i < len; i++) { 1.68 + code = XKeysymToKeycode(dpy, key[i].keysym); 1.69 + XUngrabKey(dpy, code, key[i].mod, root); 1.70 + XGrabKey(dpy, code, key[i].mod, root, True, 1.71 + GrabModeAsync, GrabModeAsync); 1.72 + } 1.73 +} 1.74 + 1.75 static void 1.76 -mresize(Client *c) 1.77 +keypress(XEvent *e) 1.78 +{ 1.79 + XKeyEvent *ev = &e->xkey; 1.80 + static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0; 1.81 + unsigned int i; 1.82 + KeySym keysym; 1.83 + 1.84 + keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 1.85 + for(i = 0; i < len; i++) 1.86 + if((keysym == key[i].keysym) && (key[i].mod == ev->state)) { 1.87 + if(key[i].func) 1.88 + key[i].func(&key[i].arg); 1.89 + return; 1.90 + } 1.91 +} 1.92 + 1.93 +static void 1.94 +resizemouse(Client *c) 1.95 { 1.96 XEvent ev; 1.97 int ocx, ocy; 1.98 @@ -75,7 +146,7 @@ 1.99 } 1.100 1.101 static void 1.102 -mmove(Client *c) 1.103 +movemouse(Client *c) 1.104 { 1.105 XEvent ev; 1.106 int x1, y1, ocx, ocy, di; 1.107 @@ -117,7 +188,7 @@ 1.108 Client *c; 1.109 1.110 if(barwin == ev->window) { 1.111 - x = (arrange == floating) ? textw("~") : 0; 1.112 + x = (arrange == dofloat) ? textw("~") : 0; 1.113 for(a.i = 0; a.i < TLast; a.i++) { 1.114 x += textw(tags[a.i]); 1.115 if(ev->x < x) { 1.116 @@ -127,20 +198,20 @@ 1.117 } 1.118 } 1.119 else if((c = getclient(ev->window))) { 1.120 - if(arrange == tiling && !c->floating) 1.121 + if(arrange == dotile && !c->dofloat) 1.122 return; 1.123 higher(c); 1.124 switch(ev->button) { 1.125 default: 1.126 break; 1.127 case Button1: 1.128 - mmove(c); 1.129 + movemouse(c); 1.130 break; 1.131 case Button2: 1.132 lower(c); 1.133 break; 1.134 case Button3: 1.135 - mresize(c); 1.136 + resizemouse(c); 1.137 break; 1.138 } 1.139 } 1.140 @@ -226,7 +297,7 @@ 1.141 if(ev->count == 0) { 1.142 if(barwin == ev->window) 1.143 drawstatus(); 1.144 - else if((c = gettitle(ev->window))) 1.145 + else if((c = getctitle(ev->window))) 1.146 drawtitle(c); 1.147 } 1.148 } 1.149 @@ -262,14 +333,14 @@ 1.150 1.151 if((c = getclient(ev->window))) { 1.152 if(ev->atom == wm_atom[WMProtocols]) { 1.153 - c->proto = proto(c->win); 1.154 + c->proto = getproto(c->win); 1.155 return; 1.156 } 1.157 switch (ev->atom) { 1.158 default: break; 1.159 case XA_WM_TRANSIENT_FOR: 1.160 XGetTransientForHint(dpy, c->win, &trans); 1.161 - if(!c->floating && (c->floating = (trans != 0))) 1.162 + if(!c->dofloat && (c->dofloat = (trans != 0))) 1.163 arrange(NULL); 1.164 break; 1.165 case XA_WM_NORMAL_HINTS: