Re: [hackers] [dwm][Patch] Gestures for 6.2

From: Abdullah <abdullah_AT_abdullah.today>
Date: Sat, 3 Aug 2019 06:07:55 +0500

Can't I use to do like, if I do a three fingers gestures left or right on
touchpad, dwm should go to next or previous tag?


On 01/08, Jost Brandstetter wrote:
> Simple fix for currrent revision

> From c818904c9c736cb2d1e0f6b9b55bdc7a8580784b Mon Sep 17 00:00:00 2001
> From: JostBrand <brandstetterj_AT_airmail.cc>
> Date: Thu, 1 Aug 2019 21:04:46 +0200
> Subject: [PATCH] Gestures Patch Fixed for 6.2
>
> ---
> config.def.h | 13 ++++++++++
> dwm.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 83 insertions(+)
>
> diff --git a/config.def.h b/config.def.h
> index 1c0b587..4671abc 100644
> --- a/config.def.h
> +++ b/config.def.h
> _AT_@ -59,6 +59,18 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
> static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
> static const char *termcmd[] = { "st", NULL };
>
> +//may want to reuse the architecture present in buttons[] and keys[]
> +static Gesture gestures[] = {
> + {"dl", spawn, SHCMD("")},
> + {"dr", spawn, SHCMD("")},
> + {"l", spawn, SHCMD("")},
> + {"ld", spawn, SHCMD("")},
> + {"lr", spawn, SHCMD("")},
> + {"r", spawn, SHCMD("firefox")},
> + {"rl", spawn, SHCMD("pavucontrol")},
> + {"du", spawn, SHCMD("st")},
> +};
> +
> static Key keys[] = {
> /* modifier key function argument */
> { MODKEY, XK_p, spawn, {.v = dmenucmd } },
> _AT_@ -111,5 +123,6 @@ static Button buttons[] = {
> { ClkTagBar, 0, Button3, toggleview, {0} },
> { ClkTagBar, MODKEY, Button1, tag, {0} },
> { ClkTagBar, MODKEY, Button3, toggletag, {0} },
> + { ClkWinTitle, 0, Button3, startgesture, {0} },
> };
>
> diff --git a/dwm.c b/dwm.c
> index 4465af1..5cbcaed 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -82,6 +82,12 @@ typedef struct {
> const Arg arg;
> } Button;
>
> +typedef struct {
> + char *name;
> + void (*func)(const Arg *arg);
> + const Arg arg;
> +} Gesture;
> +
> typedef struct Monitor Monitor;
> typedef struct Client Client;
> struct Client {
> _AT_@ -235,6 +241,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
> static void zoom(const Arg *arg);
>
> /* variables */
> +static void startgesture(const Arg *arg);
> static const char broken[] = "broken";
> static char stext[256];
> static int screen;
> _AT_@ -1344,6 +1351,69 @@ resizemouse(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]->cursor, 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);
> +}
> +
> void
> restack(Monitor *m)
> {
> --
> 2.22.0
>



A K

C20F 2707 3025 2569 BAC5
534B 7820 6670 C19D 1580

Received on Sat Aug 03 2019 - 03:07:55 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 03 2019 - 03:12:23 CEST