sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 09cbad148c4e2356c20b37b0aec3f6541cb76abf
parent 4e9c00deef6dabea6a2afcc860f09335f874ad3e
Author: dspr <unknown>
Date:   Wed, 23 Jun 2010 19:42:05 -0400

changes the naming of the gestures patch to be standard. Also updated it so that a gesture can
call any dwn function, rather than just calling execlp on a string.
Diffstat:
Adwm.suckless.org/patches/dwm-5.8-gestures.diff | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddwm.suckless.org/patches/gesturepatch.diff | 122-------------------------------------------------------------------------------
Mdwm.suckless.org/patches/gestures.md | 6+++---
3 files changed, 97 insertions(+), 125 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-5.8-gestures.diff b/dwm.suckless.org/patches/dwm-5.8-gestures.diff @@ -0,0 +1,94 @@ +diff dwm-5.8.2/config.h dwm-5.8.2mod/config.h +92a93 +> { ClkWinTitle, 0, Button3, startgesture, {0} }, +100a102,113 +> }; +> +> //may want to reuse the architecture present in buttons[] and keys[] +> static Gesture gestures[] = { +> {"dl", spawn, SHCMD("konqueror") }, +> {"dr", spawn, SHCMD("pidgin" ) }, +> {"l", spawn, SHCMD("xterm") }, +> {"ld", spawn, SHCMD("gimp" ) }, +> {"lr", spawn, SHCMD("google-chrome") }, +> {"r" , spawn, SHCMD("firefox") }, +> {"rl", spawn, SHCMD("pavucontrol") }, +> {"du", spawn, SHCMD("kate") }, +Only in dwm-5.8.2mod: config.h~ +Binary files dwm-5.8.2/dwm and dwm-5.8.2mod/dwm differ +diff dwm-5.8.2/dwm.c dwm-5.8.2mod/dwm.c +73a74,79 +> char *name; +> void (*func)(const Arg *arg); +> const Arg arg; +> } Gesture; +> +> typedef struct { +244a251 +> static void startgesture(const Arg *arg); +1248a1256,1318 +> +> void +> startgesture(const Arg *arg) { +> int x, y, dx, dy, q; +> int valid=0, listpos=0, gestpos=0, count=0; +> char move, currGest[10]; +> XEvent ev; +> +> if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, +> None, cursor[CurMove], CurrentTime) != GrabSuccess) +> return; +> if(!getrootptr(&x, &y)) +> return; +> do { +> XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); +> switch (ev.type) { +> case ConfigureRequest: +> case Expose: +> case MapRequest: +> handler[ev.type](&ev); +> break; +> case MotionNotify: +> if(count++ < 10) +> break; +> count = 0; +> dx = ev.xmotion.x - x; +> dy = ev.xmotion.y - y; +> x = ev.xmotion.x; +> y = ev.xmotion.y; +> +> if( abs(dx)/(abs(dy)+1) == 0 ) +> move = dy<0?'u':'d'; +> else +> move = dx<0?'l':'r'; +> +> if(move!=currGest[gestpos-1]) +> { +> if(gestpos>9) +> { ev.type++; +> break; +> } +> +> currGest[gestpos] = move; +> currGest[++gestpos] = '\0'; +> +> valid = 0; +> for(q = 0; q<LENGTH(gestures); q++) +> { if(!strcmp(currGest, gestures[q].name)) +> { valid++; +> listpos = q; +> } +> } +> } +> +> } +> } while(ev.type != ButtonRelease); +> +> if(valid) +> gestures[listpos].func(&(gestures[listpos].arg)); +> +> XUngrabPointer(dpy, CurrentTime); +> } +> +Only in dwm-5.8.2mod: dwm.c~ +Binary files dwm-5.8.2/dwm.o and dwm-5.8.2mod/dwm.o differ diff --git a/dwm.suckless.org/patches/gesturepatch.diff b/dwm.suckless.org/patches/gesturepatch.diff @@ -1,122 +0,0 @@ -diff -up dwm-5.8.2/config.h dwm-5.8.2mod/config.h ---- dwm-5.8.2/config.h 2010-06-23 15:24:00.000000000 -0400 -+++ dwm-5.8.2mod/config.h 2010-06-23 15:26:05.000000000 -0400 -@@ -90,6 +90,7 @@ static Button buttons[] = { - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, -+ { ClkWinTitle, 0, Button3, startgesture, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, -@@ -100,3 +101,15 @@ static Button buttons[] = { - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, - }; - -+//may want to reuse the architecture present in buttons[] and keys[] -+static Gesture gestures[] = { -+ {"dl", "konqueror" }, -+ {"dr", "pidgin" }, -+ {"l", "xterm"}, -+ {"ld", "gimp" }, -+ {"lr", "google-chrome"}, -+ {"r" , "firefox"}, -+ {"rl", "pavucontrol"}, -+ {"du", "kate"}, -+}; -+ -Binary files dwm-5.8.2/dwm and dwm-5.8.2mod/dwm differ -diff -up dwm-5.8.2/dwm.c dwm-5.8.2mod/dwm.c ---- dwm-5.8.2/dwm.c 2010-06-04 06:39:15.000000000 -0400 -+++ dwm-5.8.2mod/dwm.c 2010-06-23 15:29:30.000000000 -0400 -@@ -71,6 +71,11 @@ typedef union { - } Arg; - - typedef struct { -+ char *name; -+ char *cmd; -+} Gesture; -+ -+typedef struct { - unsigned int click; - unsigned int mask; - unsigned int button; -@@ -242,6 +247,7 @@ static int xerror(Display *dpy, XErrorEv - static int xerrordummy(Display *dpy, XErrorEvent *ee); - static int xerrorstart(Display *dpy, XErrorEvent *ee); - static void zoom(const Arg *arg); -+static void startgesture(const Arg *arg); - - /* variables */ - static const char broken[] = "broken"; -@@ -1247,6 +1253,69 @@ movemouse(const Arg *arg) { - } - } - -+void -+startgesture(const Arg *arg) { -+ int x, y, dx, dy, q; -+ int valid=0, listpos=0, gestpos=0, count=0; -+ char move, currGest[10]; -+ XEvent ev; -+ -+ if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, -+ None, cursor[CurMove], CurrentTime) != GrabSuccess) -+ return; -+ if(!getrootptr(&x, &y)) -+ return; -+ do { -+ XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); -+ switch (ev.type) { -+ case ConfigureRequest: -+ case Expose: -+ case MapRequest: -+ handler[ev.type](&ev); -+ break; -+ case MotionNotify: -+ if(count++ < 10) -+ break; -+ count = 0; -+ dx = ev.xmotion.x - x; -+ dy = ev.xmotion.y - y; -+ x = ev.xmotion.x; -+ y = ev.xmotion.y; -+ -+ if( abs(dx)/(abs(dy)+1) == 0 ) -+ move = dy<0?'u':'d'; -+ else -+ move = dx<0?'l':'r'; -+ -+ if(move!=currGest[gestpos-1]) -+ { -+ if(gestpos>9) -+ { ev.type++; -+ break; -+ } -+ -+ currGest[gestpos] = move; -+ currGest[++gestpos] = '\0'; -+ -+ valid = 0; -+ for(q = 0; q<LENGTH(gestures); q++) -+ { if(!strcmp(currGest, gestures[q].name)) -+ { valid++; -+ listpos = q; -+ } -+ } -+ } -+ -+ } -+ } while(ev.type != ButtonRelease); -+ -+ if(valid && !fork()) -+ execlp(gestures[listpos].cmd, gestures[listpos].cmd, NULL); -+ -+ XUngrabPointer(dpy, CurrentTime); -+} -+ -+ - Client * - nexttiled(Client *c) { - for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); -Binary files dwm-5.8.2/dwm.o and dwm-5.8.2mod/dwm.o differ diff --git a/dwm.suckless.org/patches/gestures.md b/dwm.suckless.org/patches/gestures.md @@ -3,12 +3,12 @@ GESTURES Description ----------- -`gestures` adds support for simple mouse gestures to dwm. Currently gestures are -only used for the execution of programs. +`gestures` adds support for simple mouse gestures to dwm. The patch assumes make has been run +and adds a gestures array to config.h. A gesture can call any dwm function. I usually call spawn. Download -------- -* [gesturepatch.diff](gesturepatch.diff) (4.0K) (20100623) +* [dwm-5.8-gestures.diff](dwm-5.8-gestures.diff) Author ------