aewl
diff kb.c @ 18:1efa34c6e1b6
added mouse-based resizals
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 21:24:10 +0200 |
parents | key.c@5c078b66347b |
children | 4560e0882c1d |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/kb.c Tue Jul 11 21:24:10 2006 +0200 1.3 @@ -0,0 +1,55 @@ 1.4 +/* 1.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 1.6 + * See LICENSE file for license details. 1.7 + */ 1.8 + 1.9 +#include "wm.h" 1.10 + 1.11 +#include <X11/keysym.h> 1.12 + 1.13 +static const char *term[] = { 1.14 + "xterm", "-u8", "-bg", "black", "-fg", "white", "-fn", 1.15 + "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0 1.16 +}; 1.17 + 1.18 +static const char *proglist[] = { 1.19 + "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0 1.20 +}; 1.21 + 1.22 +static Key key[] = { 1.23 + { Mod1Mask, XK_Return, run, term }, 1.24 + { Mod1Mask, XK_p, run, proglist }, 1.25 + { Mod1Mask | ShiftMask, XK_c, kill, NULL}, 1.26 + { Mod1Mask | ShiftMask, XK_q, quit, NULL}, 1.27 +}; 1.28 + 1.29 +void 1.30 +update_keys() 1.31 +{ 1.32 + unsigned int i, len; 1.33 + KeyCode code; 1.34 + 1.35 + len = sizeof(key) / sizeof(key[0]); 1.36 + for(i = 0; i < len; i++) { 1.37 + code = XKeysymToKeycode(dpy, key[i].keysym); 1.38 + XUngrabKey(dpy, code, key[i].mod, root); 1.39 + XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync); 1.40 + } 1.41 +} 1.42 + 1.43 +void 1.44 +keypress(XEvent *e) 1.45 +{ 1.46 + XKeyEvent *ev = &e->xkey; 1.47 + unsigned int i, len; 1.48 + KeySym keysym; 1.49 + 1.50 + keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 1.51 + len = sizeof(key) / sizeof(key[0]); 1.52 + for(i = 0; i < len; i++) 1.53 + if((keysym == key[i].keysym) && (key[i].mod == ev->state)) { 1.54 + if(key[i].func) 1.55 + key[i].func(key[i].aux); 1.56 + return; 1.57 + } 1.58 +}