aewl
changeset 42:040a7074d23c
added dev.c instead of kb.c
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Thu, 13 Jul 2006 10:34:55 +0200 |
parents | fc9ccd34b8ab |
children | 989178822938 |
files | Makefile README dev.c wm.h |
diffstat | 6 files changed, 137 insertions(+), 146 deletions(-) [+] |
line diff
1.1 --- a/Makefile Thu Jul 13 10:25:57 2006 +0200 1.2 +++ b/Makefile Thu Jul 13 10:34:55 2006 +0200 1.3 @@ -3,7 +3,7 @@ 1.4 1.5 include config.mk 1.6 1.7 -SRC = client.c draw.c event.c kb.c mouse.c util.c wm.c 1.8 +SRC = client.c dev.c draw.c event.c util.c wm.c 1.9 OBJ = ${SRC:.c=.o} 1.10 MAN1 = dwm.1 1.11 BIN = dwm
2.1 --- a/README Thu Jul 13 10:25:57 2006 +0200 2.2 +++ b/README Thu Jul 13 10:34:55 2006 +0200 2.3 @@ -37,4 +37,4 @@ 2.4 Configuration 2.5 ------------- 2.6 The configuration of dwm is done by customizing the wm.h source file. To 2.7 -customize the key bindings edit kb.c. 2.8 +customize the key bindings edit dev.c.
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/dev.c Thu Jul 13 10:34:55 2006 +0200 3.3 @@ -0,0 +1,134 @@ 3.4 +/* 3.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 3.6 + * See LICENSE file for license details. 3.7 + */ 3.8 + 3.9 +#include "wm.h" 3.10 + 3.11 +#include <stdlib.h> 3.12 +#include <string.h> 3.13 +#include <unistd.h> 3.14 +#include <X11/keysym.h> 3.15 + 3.16 +/********** CUSTOMIZE **********/ 3.17 + 3.18 +const char *term[] = { 3.19 + "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", 3.20 + "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL 3.21 +}; 3.22 +const char *browse[] = { "firefox", NULL }; 3.23 + 3.24 +static Key key[] = { 3.25 + { Mod1Mask, XK_Return, (void (*)(void *))spawn, term }, 3.26 + { Mod1Mask, XK_w, (void (*)(void *))spawn, browse }, 3.27 + { Mod1Mask, XK_k, sel, "prev" }, 3.28 + { Mod1Mask, XK_j, sel, "next" }, 3.29 + { Mod1Mask, XK_space, toggle, NULL }, 3.30 + { Mod1Mask, XK_m, max, NULL }, 3.31 + { Mod1Mask | ShiftMask, XK_c, ckill, NULL }, 3.32 + { Mod1Mask | ShiftMask, XK_q, quit, NULL }, 3.33 +}; 3.34 + 3.35 +/********** CUSTOMIZE **********/ 3.36 + 3.37 +void 3.38 +update_keys(void) 3.39 +{ 3.40 + unsigned int i, len; 3.41 + KeyCode code; 3.42 + 3.43 + len = sizeof(key) / sizeof(key[0]); 3.44 + for(i = 0; i < len; i++) { 3.45 + code = XKeysymToKeycode(dpy, key[i].keysym); 3.46 + XUngrabKey(dpy, code, key[i].mod, root); 3.47 + XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync); 3.48 + } 3.49 +} 3.50 + 3.51 +void 3.52 +keypress(XEvent *e) 3.53 +{ 3.54 + XKeyEvent *ev = &e->xkey; 3.55 + unsigned int i, len; 3.56 + KeySym keysym; 3.57 + 3.58 + keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 3.59 + len = sizeof(key) / sizeof(key[0]); 3.60 + for(i = 0; i < len; i++) 3.61 + if((keysym == key[i].keysym) && (key[i].mod == ev->state)) { 3.62 + if(key[i].func) 3.63 + key[i].func(key[i].aux); 3.64 + return; 3.65 + } 3.66 +} 3.67 + 3.68 +#define ButtonMask (ButtonPressMask | ButtonReleaseMask) 3.69 +#define MouseMask (ButtonMask | PointerMotionMask) 3.70 + 3.71 +void 3.72 +mresize(Client *c) 3.73 +{ 3.74 + XEvent ev; 3.75 + int ocx, ocy; 3.76 + 3.77 + ocx = c->x; 3.78 + ocy = c->y; 3.79 + if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, 3.80 + None, cursor[CurResize], CurrentTime) != GrabSuccess) 3.81 + return; 3.82 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); 3.83 + for(;;) { 3.84 + XMaskEvent(dpy, MouseMask | ExposureMask, &ev); 3.85 + switch(ev.type) { 3.86 + default: break; 3.87 + case Expose: 3.88 + handler[Expose](&ev); 3.89 + break; 3.90 + case MotionNotify: 3.91 + XFlush(dpy); 3.92 + c->w = abs(ocx - ev.xmotion.x); 3.93 + c->h = abs(ocy - ev.xmotion.y); 3.94 + c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; 3.95 + c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; 3.96 + resize(c); 3.97 + break; 3.98 + case ButtonRelease: 3.99 + XUngrabPointer(dpy, CurrentTime); 3.100 + return; 3.101 + } 3.102 + } 3.103 +} 3.104 + 3.105 +void 3.106 +mmove(Client *c) 3.107 +{ 3.108 + XEvent ev; 3.109 + int x1, y1, ocx, ocy, di; 3.110 + unsigned int dui; 3.111 + Window dummy; 3.112 + 3.113 + ocx = c->x; 3.114 + ocy = c->y; 3.115 + if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, 3.116 + None, cursor[CurMove], CurrentTime) != GrabSuccess) 3.117 + return; 3.118 + XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); 3.119 + for(;;) { 3.120 + XMaskEvent(dpy, MouseMask | ExposureMask, &ev); 3.121 + switch (ev.type) { 3.122 + default: break; 3.123 + case Expose: 3.124 + handler[Expose](&ev); 3.125 + break; 3.126 + case MotionNotify: 3.127 + XFlush(dpy); 3.128 + c->x = ocx + (ev.xmotion.x - x1); 3.129 + c->y = ocy + (ev.xmotion.y - y1); 3.130 + resize(c); 3.131 + break; 3.132 + case ButtonRelease: 3.133 + XUngrabPointer(dpy, CurrentTime); 3.134 + return; 3.135 + } 3.136 + } 3.137 +}
4.1 --- a/kb.c Thu Jul 13 10:25:57 2006 +0200 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,60 +0,0 @@ 4.4 -/* 4.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 4.6 - * See LICENSE file for license details. 4.7 - */ 4.8 - 4.9 -#include "wm.h" 4.10 - 4.11 -#include <X11/keysym.h> 4.12 - 4.13 -/********** CUSTOMIZE **********/ 4.14 - 4.15 -const char *term[] = { 4.16 - "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", 4.17 - "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL 4.18 -}; 4.19 -const char *browse[] = { "firefox", NULL }; 4.20 - 4.21 -static Key key[] = { 4.22 - { Mod1Mask, XK_Return, (void (*)(void *))spawn, term }, 4.23 - { Mod1Mask, XK_w, (void (*)(void *))spawn, browse }, 4.24 - { Mod1Mask, XK_k, sel, "prev" }, 4.25 - { Mod1Mask, XK_j, sel, "next" }, 4.26 - { Mod1Mask, XK_space, toggle, NULL }, 4.27 - { Mod1Mask, XK_m, max, NULL }, 4.28 - { Mod1Mask | ShiftMask, XK_c, ckill, NULL }, 4.29 - { Mod1Mask | ShiftMask, XK_q, quit, NULL }, 4.30 -}; 4.31 - 4.32 -/********** CUSTOMIZE **********/ 4.33 - 4.34 -void 4.35 -update_keys(void) 4.36 -{ 4.37 - unsigned int i, len; 4.38 - KeyCode code; 4.39 - 4.40 - len = sizeof(key) / sizeof(key[0]); 4.41 - for(i = 0; i < len; i++) { 4.42 - code = XKeysymToKeycode(dpy, key[i].keysym); 4.43 - XUngrabKey(dpy, code, key[i].mod, root); 4.44 - XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync); 4.45 - } 4.46 -} 4.47 - 4.48 -void 4.49 -keypress(XEvent *e) 4.50 -{ 4.51 - XKeyEvent *ev = &e->xkey; 4.52 - unsigned int i, len; 4.53 - KeySym keysym; 4.54 - 4.55 - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 4.56 - len = sizeof(key) / sizeof(key[0]); 4.57 - for(i = 0; i < len; i++) 4.58 - if((keysym == key[i].keysym) && (key[i].mod == ev->state)) { 4.59 - if(key[i].func) 4.60 - key[i].func(key[i].aux); 4.61 - return; 4.62 - } 4.63 -}
5.1 --- a/mouse.c Thu Jul 13 10:25:57 2006 +0200 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,81 +0,0 @@ 5.4 -/* 5.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 5.6 - * See LICENSE file for license details. 5.7 - */ 5.8 - 5.9 -#include <stdlib.h> 5.10 -#include <string.h> 5.11 -#include <unistd.h> 5.12 - 5.13 -#include "wm.h" 5.14 - 5.15 -#define ButtonMask (ButtonPressMask | ButtonReleaseMask) 5.16 -#define MouseMask (ButtonMask | PointerMotionMask) 5.17 - 5.18 -void 5.19 -mresize(Client *c) 5.20 -{ 5.21 - XEvent ev; 5.22 - int ocx, ocy; 5.23 - 5.24 - ocx = c->x; 5.25 - ocy = c->y; 5.26 - if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, 5.27 - None, cursor[CurResize], CurrentTime) != GrabSuccess) 5.28 - return; 5.29 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); 5.30 - for(;;) { 5.31 - XMaskEvent(dpy, MouseMask | ExposureMask, &ev); 5.32 - switch(ev.type) { 5.33 - default: break; 5.34 - case Expose: 5.35 - handler[Expose](&ev); 5.36 - break; 5.37 - case MotionNotify: 5.38 - XFlush(dpy); 5.39 - c->w = abs(ocx - ev.xmotion.x); 5.40 - c->h = abs(ocy - ev.xmotion.y); 5.41 - c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; 5.42 - c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; 5.43 - resize(c); 5.44 - break; 5.45 - case ButtonRelease: 5.46 - XUngrabPointer(dpy, CurrentTime); 5.47 - return; 5.48 - } 5.49 - } 5.50 -} 5.51 - 5.52 -void 5.53 -mmove(Client *c) 5.54 -{ 5.55 - XEvent ev; 5.56 - int x1, y1, ocx, ocy, di; 5.57 - unsigned int dui; 5.58 - Window dummy; 5.59 - 5.60 - ocx = c->x; 5.61 - ocy = c->y; 5.62 - if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, 5.63 - None, cursor[CurMove], CurrentTime) != GrabSuccess) 5.64 - return; 5.65 - XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); 5.66 - for(;;) { 5.67 - XMaskEvent(dpy, MouseMask | ExposureMask, &ev); 5.68 - switch (ev.type) { 5.69 - default: break; 5.70 - case Expose: 5.71 - handler[Expose](&ev); 5.72 - break; 5.73 - case MotionNotify: 5.74 - XFlush(dpy); 5.75 - c->x = ocx + (ev.xmotion.x - x1); 5.76 - c->y = ocy + (ev.xmotion.y - y1); 5.77 - resize(c); 5.78 - break; 5.79 - case ButtonRelease: 5.80 - XUngrabPointer(dpy, CurrentTime); 5.81 - return; 5.82 - } 5.83 - } 5.84 -}
6.1 --- a/wm.h Thu Jul 13 10:25:57 2006 +0200 6.2 +++ b/wm.h Thu Jul 13 10:34:55 2006 +0200 6.3 @@ -115,11 +115,9 @@ 6.4 /* event.c */ 6.5 extern void discard_events(long even_mask); 6.6 6.7 -/* kb.c */ 6.8 +/* dev.c */ 6.9 extern void update_keys(void); 6.10 extern void keypress(XEvent *e); 6.11 - 6.12 -/* mouse.c */ 6.13 extern void mresize(Client *c); 6.14 extern void mmove(Client *c); 6.15