[hackers] [tabbed] [PATCH] add -k to close tabbed foreground client on WMDelete

From: Justin Keogh <suckless_AT_v6y.net>
Date: Mon, 21 Mar 2016 02:16:12 +0000

Hello, this is useful when you want to use the same key binding that closes windows to close tabs. I got tired of loosing my tabbed/surf session when I hit my WM's close key. "Last tab" behavior still respects -c/-f.

Cheers
-J


From 829e95855f0fe78a368788a5e72231bd6456a8cf Mon Sep 17 00:00:00 2001
From: jakeogh <github.com_AT_v6y.net>
Date: Mon, 21 Mar 2016 01:36:28 +0000
Subject: [PATCH] add -k to close foreground tabbed client on WM_DELETE_WINDOW

---
 tabbed.1 |  5 +++++
 tabbed.c | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/tabbed.1 b/tabbed.1
index 874e306..bc28b8c 100644
--- a/tabbed.1
+++ b/tabbed.1
_AT_@ -5,6 +5,7 @@ tabbed \- generic tabbed interface
 .B tabbed
 .RB [ \-c ]
 .RB [ \-d ]
+.RB [ \-k ]
 .RB [ \-s ]
 .RB [ \-v ]
 .RB [ \-g
_AT_@ -56,6 +57,10 @@ See
 .BR XParseGeometry (3)
 for further details.
 .TP
+.B \-k
+close foreground tabbed client (instead of tabbed and all clients) when
+WM_DELETE_WINDOW is sent.
+.TP
 .BI \-n " name"
 will set the WM_CLASS attribute to
 .I name.
diff --git a/tabbed.c b/tabbed.c
index a9050ae..9a44795 100644
--- a/tabbed.c
+++ b/tabbed.c
_AT_@ -155,7 +155,8 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
 static int bh, wx, wy, ww, wh;
 static unsigned int numlockmask;
 static Bool running = True, nextfocus, doinitspawn = True,
-            fillagain = False, closelastclient = False;
+            fillagain = False, closelastclient = False,
+            killclientsfirst = False;
 static Display *dpy;
 static DC dc;
 static Atom wmatom[WMLast];
_AT_@ -236,8 +237,13 @@ clientmessage(const XEvent *e)
        const XClientMessageEvent *ev = &e->xclient;
 
        if (ev->message_type == wmatom[WMProtocols] &&
-           ev->data.l[0] == wmatom[WMDelete])
+           ev->data.l[0] == wmatom[WMDelete]) {
+               if (nclients > 1 && killclientsfirst) {
+                       killclient(0);
+                       return;
+               }
                running = False;
+       }
 }
 
 void
_AT_@ -1247,7 +1253,7 @@ xsettitle(Window w, const char *str)
 void
 usage(void)
 {
-       die("usage: %s [-dfsv] [-g geometry] [-n name] [-p [s+/-]pos]\n"
+       die("usage: %s [-dfksv] [-g geometry] [-n name] [-p [s+/-]pos]\n"
            "       [-r narg] [-o color] [-O color] [-t color] [-T color]\n"
            "       [-u color] [-U color] command...\n", argv0);
 }
_AT_@ -1273,6 +1279,9 @@ main(int argc, char *argv[])
        case 'g':
                geometry = EARGF(usage());
                break;
+       case 'k':
+               killclientsfirst = True;
+               break;
        case 'n':
                wmname = EARGF(usage());
                break;
-- 
2.4.10
Received on Mon Mar 21 2016 - 03:16:12 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 21 2016 - 03:24:15 CET