dwm-meillo

annotate kb.c @ 34:cd30cce52b78

added logo+description
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 09:32:22 +0200
parents e90449e03167
children
rev   line source
garbeam@8 1 /*
garbeam@8 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
garbeam@8 3 * See LICENSE file for license details.
garbeam@8 4 */
garbeam@8 5
garbeam@8 6 #include "wm.h"
garbeam@8 7
garbeam@8 8 #include <X11/keysym.h>
garbeam@8 9
garbeam@31 10 /********** CUSTOMIZE **********/
garbeam@31 11
garbeam@33 12 const char *term[] = {
garbeam@29 13 "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
garbeam@31 14 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
garbeam@14 15 };
garbeam@34 16 const char *browse[] = { "firefox", NULL };
garbeam@14 17
garbeam@8 18 static Key key[] = {
garbeam@33 19 { Mod1Mask, XK_Return, (void (*)(void *))spawn, term },
garbeam@34 20 { Mod1Mask, XK_w, (void (*)(void *))spawn, browse },
garbeam@27 21 { Mod1Mask, XK_k, sel, "prev" },
garbeam@27 22 { Mod1Mask, XK_j, sel, "next" },
garbeam@34 23 { Mod1Mask, XK_space, toggle, NULL },
garbeam@28 24 { Mod1Mask, XK_m, max, NULL },
garbeam@32 25 { Mod1Mask | ShiftMask, XK_c, ckill, NULL },
garbeam@27 26 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
garbeam@8 27 };
garbeam@8 28
garbeam@31 29 /********** CUSTOMIZE **********/
garbeam@31 30
garbeam@8 31 void
garbeam@33 32 update_keys(void)
garbeam@8 33 {
garbeam@8 34 unsigned int i, len;
garbeam@8 35 KeyCode code;
garbeam@8 36
garbeam@8 37 len = sizeof(key) / sizeof(key[0]);
garbeam@8 38 for(i = 0; i < len; i++) {
garbeam@8 39 code = XKeysymToKeycode(dpy, key[i].keysym);
garbeam@8 40 XUngrabKey(dpy, code, key[i].mod, root);
garbeam@8 41 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
garbeam@8 42 }
garbeam@8 43 }
garbeam@9 44
garbeam@9 45 void
garbeam@9 46 keypress(XEvent *e)
garbeam@9 47 {
garbeam@9 48 XKeyEvent *ev = &e->xkey;
garbeam@9 49 unsigned int i, len;
garbeam@9 50 KeySym keysym;
garbeam@9 51
garbeam@9 52 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
garbeam@9 53 len = sizeof(key) / sizeof(key[0]);
garbeam@9 54 for(i = 0; i < len; i++)
garbeam@9 55 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
garbeam@9 56 if(key[i].func)
garbeam@14 57 key[i].func(key[i].aux);
garbeam@9 58 return;
garbeam@9 59 }
garbeam@9 60 }