dwm-bulkill-systray-20231029-9f88553.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-bulkill-systray-20231029-9f88553.diff (2778B)
---
1 From 82eb2e651e54560540e77ba5dd292803cec8a6e3 Mon Sep 17 00:00:00 2001
2 From: ysl2 <www.songli.yu@gmail.com>
3 Date: Sun, 29 Oct 2023 15:42:52 +0800
4 Subject: [PATCH] Give killclient an augument to control the beheviour: arg.ui
5 == 0 for normal kill current client; arg.ui == 1 for kill other clients in
6 current tag (except current focusing client); arg.ui == 2 for kill all
7 clients in current tag (include focusing client).
8
9 ---
10 config.def.h | 2 ++
11 dwm.c | 31 ++++++++++++++++++++++++-------
12 2 files changed, 26 insertions(+), 7 deletions(-)
13
14 diff --git a/config.def.h b/config.def.h
15 index 750529d..ef1efe8 100644
16 --- a/config.def.h
17 +++ b/config.def.h
18 @@ -79,6 +79,8 @@ static const Key keys[] = {
19 { MODKEY, XK_Return, zoom, {0} },
20 { MODKEY, XK_Tab, view, {0} },
21 { MODKEY|ShiftMask, XK_c, killclient, {0} },
22 + { MODKEY|ControlMask, XK_c, killclient, {.ui = 1} }, // kill unselect
23 + { MODKEY|ShiftMask|ControlMask, XK_c, killclient, {.ui = 2} }, // killall
24 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
25 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
26 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
27 diff --git a/dwm.c b/dwm.c
28 index f9e7e4a..9819ec5 100644
29 --- a/dwm.c
30 +++ b/dwm.c
31 @@ -199,6 +199,7 @@ static void grabbuttons(Client *c, int focused);
32 static void grabkeys(void);
33 static void incnmaster(const Arg *arg);
34 static void keypress(XEvent *e);
35 +static void killthis(Window w);
36 static void killclient(const Arg *arg);
37 static void manage(Window w, XWindowAttributes *wa);
38 static void mappingnotify(XEvent *e);
39 @@ -1131,22 +1132,38 @@ keypress(XEvent *e)
40 }
41
42 void
43 -killclient(const Arg *arg)
44 -{
45 - if (!selmon->sel)
46 - return;
47 -
48 - if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0 , 0, 0)) {
49 +killthis(Window w) {
50 + if (!sendevent(w, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) {
51 XGrabServer(dpy);
52 XSetErrorHandler(xerrordummy);
53 XSetCloseDownMode(dpy, DestroyAll);
54 - XKillClient(dpy, selmon->sel->win);
55 + XKillClient(dpy, w);
56 XSync(dpy, False);
57 XSetErrorHandler(xerror);
58 XUngrabServer(dpy);
59 }
60 }
61
62 +void
63 +killclient(const Arg *arg)
64 +{
65 + Client *c;
66 +
67 + if (!selmon->sel)
68 + return;
69 +
70 + if (!arg->ui || arg->ui == 0) {
71 + killthis(selmon->sel->win);
72 + return;
73 + }
74 +
75 + for (c = selmon->clients; c; c = c->next) {
76 + if (!ISVISIBLE(c) || (arg->ui == 1 && c == selmon->sel))
77 + continue;
78 + killthis(c->win);
79 + }
80 +}
81 +
82 void
83 manage(Window w, XWindowAttributes *wa)
84 {
85 --
86 2.20.1
87