[wiki] [sites] Add pathes to handle keyrelease actions and hidetabs based on keyrelease || LeelaPakanati

From: <git_AT_suckless.org>
Date: Tue, 17 Dec 2019 01:01:36 +0100

commit 40940c7ce907b3c831c127a9e54404ba9e331d26
Author: LeelaPakanati <LeelaPakanati.gmail.com>
Date: Mon Dec 16 19:00:36 2019 -0500

    Add pathes to handle keyrelease actions and hidetabs based on keyrelease

diff --git a/tools.suckless.org/tabbed/patches/hidetabs/index.md b/tools.suckless.org/tabbed/patches/hidetabs/index.md
new file mode 100644
index 00000000..95962a0a
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/hidetabs/index.md
_AT_@ -0,0 +1,22 @@
+Hide Tabs
+=====
+
+Description
+-----------
+This patch hides all the tabs and only shows them when Mod+Shift is pressed.
+All functions with switching, rotating, and creating tabs involve Mod+Shift.
+When not doing one of these functions, visibility of the tabs is not needed.
+
+This patch relies on the keyrelease patch to support show/hide on
+keypress/keyrelease.
+
+This patch was inspired by and borrows from the autohide patch originally
+by Carlos Pita.
+
+Download
+--------
+* [tabbed-hidetabs-20191216-b5f9ec6.diff](tabbed-hidetabs-20191216-b5f9ec6.diff)
+
+Author
+------
+* Leela Pakanati - <leela.pakanati_AT_gmail.com>
diff --git a/tools.suckless.org/tabbed/patches/hidetabs/tabbed-hidetabs-20191216-b5f9e6.diff b/tools.suckless.org/tabbed/patches/hidetabs/tabbed-hidetabs-20191216-b5f9e6.diff
new file mode 100644
index 00000000..424519d6
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/hidetabs/tabbed-hidetabs-20191216-b5f9e6.diff
_AT_@ -0,0 +1,105 @@
+From 52708d468acace9543d01e6d8afae799f8d6fccd Mon Sep 17 00:00:00 2001
+From: LeelaPakanati <leela.pakanati_AT_gmail.com>
+Date: Mon, 16 Dec 2019 18:57:32 -0500
+Subject: [PATCH] Add hide tabs feature
+
+---
+ config.def.h | 7 +++++--
+ tabbed.c | 24 +++++++++++++++++++++---
+ 2 files changed, 26 insertions(+), 5 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 7bfda30..bb7ef0e 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -63,10 +63,13 @@ static Key keys[] = {
+ { MODKEY|ShiftMask, XK_u, toggle, { .v = (void*) &urgentswitch } },
+
+ { 0, XK_F11, fullscreen, { 0 } },
++
++ { MODKEY, XK_Shift_L, showbar, { .i = 1 } },
++ { ShiftMask, XK_Control_L, showbar, { .i = 1 } },
+ };
+
+ static Key keyreleases[] = {
+ /* modifier key function argument */
+- { 0, XK_Shift_L, NULL, { 0 } },
+-
++ { MODKEY|ShiftMask, XK_Shift_L, showbar, { .i = 0 } },
++ { MODKEY|ShiftMask, XK_Control_L, showbar, { .i = 0 } },
+ };
+diff --git a/tabbed.c b/tabbed.c
+index fe38b9d..352dab2 100644
+--- a/tabbed.c
++++ b/tabbed.c
+_AT_@ -127,6 +127,7 @@ static void sendxembed(int c, long msg, long detail, long d1, long d2);
+ static void setcmd(int argc, char *argv[], int);
+ static void setup(void);
+ static void sigchld(int unused);
++static void showbar(const Arg *arg);
+ static void spawn(const Arg *arg);
+ static int textnw(const char *text, unsigned int len);
+ static void toggle(const Arg *arg);
+_AT_@ -154,7 +155,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
+ [MapRequest] = maprequest,
+ [PropertyNotify] = propertynotify,
+ };
+-static int bh, wx, wy, ww, wh;
++static int bh, wx, wy, ww, wh, vbh;
+ static unsigned int numlockmask;
+ static Bool running = True, nextfocus, doinitspawn = True,
+ fillagain = False, closelastclient = False,
+_AT_@ -171,6 +172,7 @@ static char winid[64];
+ static char **cmd;
+ static char *wmname = "tabbed";
+ static const char *geometry;
++static Bool barvisibility = False;
+
+ char *argv0;
+
+_AT_@ -317,9 +319,18 @@ void
+ drawbar(void)
+ {
+ XftColor *col;
+- int c, cc, fc, width;
++ int c, cc, fc, width, nbh;
+ char *name = NULL;
+
++ nbh = barvisibility ? vbh : 0;
++ if (nbh != bh) {
++ bh = nbh;
++ for (c = 0; c < nclients; c++)
++ XMoveResizeWindow(dpy, clients[c]->win, 0, bh, ww, wh-bh);
++ }
++
++ if (bh == 0) return;
++
+ if (nclients == 0) {
+ dc.x = 0;
+ dc.w = ww;
+_AT_@ -1003,7 +1014,7 @@ setup(void)
+ screen = DefaultScreen(dpy);
+ root = RootWindow(dpy, screen);
+ initfont(font);
+- bh = dc.h = dc.font.height + 2;
++ vbh = dc.h = dc.font.height + 2;
+
+ /* init atoms */
+ wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
+_AT_@ -1096,6 +1107,13 @@ setup(void)
+ focus(-1);
+ }
+
++void
++showbar(const Arg *arg)
++{
++ barvisibility = arg->i;
++ drawbar();
++}
++
+ void
+ sigchld(int unused)
+ {
+--
+2.24.0
+
diff --git a/tools.suckless.org/tabbed/patches/keyrelease/index.md b/tools.suckless.org/tabbed/patches/keyrelease/index.md
new file mode 100644
index 00000000..29d9a3e8
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/keyrelease/index.md
_AT_@ -0,0 +1,15 @@
+Key Release
+=====
+
+Description
+-----------
+This patch enables for function handling on KeyRelease events.
+For example usage see: hidetabs
+
+Download
+--------
+* [tabbed-keypress-20191213-b5f9ec6.diff](tabbed-keypress-20191213-b5f9ec6.diff)
+
+Author
+------
+* Leela Pakanati - <leela.pakanati_AT_gmail.com>
diff --git a/tools.suckless.org/tabbed/patches/keyrelease/tabbed-keyrelease-20191213-b5f9ec6.diff b/tools.suckless.org/tabbed/patches/keyrelease/tabbed-keyrelease-20191213-b5f9ec6.diff
new file mode 100644
index 00000000..1ac50011
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/keyrelease/tabbed-keyrelease-20191213-b5f9ec6.diff
_AT_@ -0,0 +1,96 @@
+From 1cb625c1d9606df518d4de89d6af4bef18cdd62e Mon Sep 17 00:00:00 2001
+From: LeelaPakanati <LeelaPakanati.gmail.com>
+Date: Fri, 13 Dec 2019 16:56:42 -0500
+Subject: [PATCH] Add function handling at keyrelease
+
+---
+ config.def.h | 6 ++++++
+ tabbed.c | 30 +++++++++++++++++++++++++++++-
+ 2 files changed, 35 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index defa426..7bfda30 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -64,3 +64,9 @@ static Key keys[] = {
+
+ { 0, XK_F11, fullscreen, { 0 } },
+ };
++
++static Key keyreleases[] = {
++ /* modifier key function argument */
++ { 0, XK_Shift_L, NULL, { 0 } },
++
++};
+diff --git a/tabbed.c b/tabbed.c
+index ff3ada0..8d03bc6 100644
+--- a/tabbed.c
++++ b/tabbed.c
+_AT_@ -113,6 +113,7 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+ static void initfont(const char *fontstr);
+ static Bool isprotodel(int c);
+ static void keypress(const XEvent *e);
++static void keyrelease(const XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window win);
+ static void maprequest(const XEvent *e);
+_AT_@ -149,6 +150,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
++ [KeyRelease] = keyrelease,
+ [MapRequest] = maprequest,
+ [PropertyNotify] = propertynotify,
+ };
+_AT_@ -664,6 +666,22 @@ keypress(const XEvent *e)
+ }
+ }
+
++void
++keyrelease(const XEvent *e)
++{
++ const XKeyEvent *ev = &e->xkey;
++ unsigned int i;
++ KeySym keysym;
++
++ keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
++ for (i = 0; i < LENGTH(keys); i++) {
++ if (keysym == keyreleases[i].keysym &&
++ CLEANMASK(keyreleases[i].mod) == CLEANMASK(ev->state) &&
++ keyreleases[i].func)
++ keyreleases[i].func(&(keyreleases[i].arg));
++ }
++}
++
+ void
+ killclient(const Arg *arg)
+ {
+_AT_@ -714,6 +732,16 @@ manage(Window w)
+ }
+ }
+
++ for (i = 0; i < LENGTH(keyreleases); i++) {
++ if ((code = XKeysymToKeycode(dpy, keyreleases[i].keysym))) {
++ for (j = 0; j < LENGTH(modifiers); j++) {
++ XGrabKey(dpy, code, keyreleases[i].mod |
++ modifiers[j], w, True,
++ GrabModeAsync, GrabModeAsync);
++ }
++ }
++ }
++
+ c = ecalloc(1, sizeof *c);
+ c->win = w;
+
+_AT_@ -1036,7 +1064,7 @@ setup(void)
+ XMapRaised(dpy, win);
+ XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask |
+ ButtonPressMask | ExposureMask | KeyPressMask |
+- PropertyChangeMask | StructureNotifyMask |
++ KeyReleaseMask | PropertyChangeMask | StructureNotifyMask |
+ SubstructureRedirectMask);
+ xerrorxlib = XSetErrorHandler(xerror);
+
+--
+2.24.0
+
diff --git a/tools.suckless.org/tabbed/patches/keyrelease/tabbed-keyrelease-20191216-b5f9e6.diff b/tools.suckless.org/tabbed/patches/keyrelease/tabbed-keyrelease-20191216-b5f9e6.diff
new file mode 100644
index 00000000..143a0082
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/keyrelease/tabbed-keyrelease-20191216-b5f9e6.diff
_AT_@ -0,0 +1,96 @@
+From 6c58b480b7b6ce6a28beafc60a096069fbd51532 Mon Sep 17 00:00:00 2001
+From: LeelaPakanati <LeelaPakanati.gmail.com>
+Date: Fri, 13 Dec 2019 16:56:42 -0500
+Subject: [PATCH] Add function handling at keyrelease
+
+---
+ config.def.h | 6 ++++++
+ tabbed.c | 30 +++++++++++++++++++++++++++++-
+ 2 files changed, 35 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index defa426..7bfda30 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -64,3 +64,9 @@ static Key keys[] = {
+
+ { 0, XK_F11, fullscreen, { 0 } },
+ };
++
++static Key keyreleases[] = {
++ /* modifier key function argument */
++ { 0, XK_Shift_L, NULL, { 0 } },
++
++};
+diff --git a/tabbed.c b/tabbed.c
+index ff3ada0..fe38b9d 100644
+--- a/tabbed.c
++++ b/tabbed.c
+_AT_@ -113,6 +113,7 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+ static void initfont(const char *fontstr);
+ static Bool isprotodel(int c);
+ static void keypress(const XEvent *e);
++static void keyrelease(const XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window win);
+ static void maprequest(const XEvent *e);
+_AT_@ -149,6 +150,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
++ [KeyRelease] = keyrelease,
+ [MapRequest] = maprequest,
+ [PropertyNotify] = propertynotify,
+ };
+_AT_@ -664,6 +666,22 @@ keypress(const XEvent *e)
+ }
+ }
+
++void
++keyrelease(const XEvent *e)
++{
++ const XKeyEvent *ev = &e->xkey;
++ unsigned int i;
++ KeySym keysym;
++
++ keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
++ for (i = 0; i < LENGTH(keyreleases); i++) {
++ if (keysym == keyreleases[i].keysym &&
++ CLEANMASK(keyreleases[i].mod) == CLEANMASK(ev->state) &&
++ keyreleases[i].func)
++ keyreleases[i].func(&(keyreleases[i].arg));
++ }
++}
++
+ void
+ killclient(const Arg *arg)
+ {
+_AT_@ -714,6 +732,16 @@ manage(Window w)
+ }
+ }
+
++ for (i = 0; i < LENGTH(keyreleases); i++) {
++ if ((code = XKeysymToKeycode(dpy, keyreleases[i].keysym))) {
++ for (j = 0; j < LENGTH(modifiers); j++) {
++ XGrabKey(dpy, code, keyreleases[i].mod |
++ modifiers[j], w, True,
++ GrabModeAsync, GrabModeAsync);
++ }
++ }
++ }
++
+ c = ecalloc(1, sizeof *c);
+ c->win = w;
+
+_AT_@ -1036,7 +1064,7 @@ setup(void)
+ XMapRaised(dpy, win);
+ XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask |
+ ButtonPressMask | ExposureMask | KeyPressMask |
+- PropertyChangeMask | StructureNotifyMask |
++ KeyReleaseMask | PropertyChangeMask | StructureNotifyMask |
+ SubstructureRedirectMask);
+ xerrorxlib = XSetErrorHandler(xerror);
+
+--
+2.24.0
+
Received on Tue Dec 17 2019 - 01:01:36 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 17 2019 - 01:12:38 CET