dwm-scratchpad-20240321-061e9fe.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-scratchpad-20240321-061e9fe.diff (3592B)
---
1 From b9f3c11c3150f0b5d5b297a4eeeb2012764c98f5 Mon Sep 17 00:00:00 2001
2 From: visil <workregor@mail.ru>
3 Date: Thu, 21 Mar 2024 15:16:39 +0300
4 Subject: [PATCH] Patch updated to 6.5
5
6 ---
7 config.def.h | 3 +++
8 dwm.c | 34 ++++++++++++++++++++++++++++++++++
9 2 files changed, 37 insertions(+)
10
11 diff --git a/config.def.h b/config.def.h
12 index 9efa774..0b8b310 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -59,11 +59,14 @@ static const Layout layouts[] = {
16 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
17 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
18 static const char *termcmd[] = { "st", NULL };
19 +static const char scratchpadname[] = "scratchpad";
20 +static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
21
22 static const Key keys[] = {
23 /* modifier key function argument */
24 { MODKEY, XK_p, spawn, {.v = dmenucmd } },
25 { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
26 + { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
27 { MODKEY, XK_b, togglebar, {0} },
28 { MODKEY, XK_j, focusstack, {.i = +1 } },
29 { MODKEY, XK_k, focusstack, {.i = -1 } },
30 diff --git a/dwm.c b/dwm.c
31 index f1d86b2..a8db21a 100644
32 --- a/dwm.c
33 +++ b/dwm.c
34 @@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
35 static void tile(Monitor *m);
36 static void togglebar(const Arg *arg);
37 static void togglefloating(const Arg *arg);
38 +static void togglescratch(const Arg *arg);
39 static void toggletag(const Arg *arg);
40 static void toggleview(const Arg *arg);
41 static void unfocus(Client *c, int setfocus);
42 @@ -271,6 +272,8 @@ static Window root, wmcheckwin;
43 /* configuration, allows nested code to access above variables */
44 #include "config.h"
45
46 +static unsigned int scratchtag = 1 << LENGTH(tags);
47 +
48 /* compile-time check if all tags fit into an unsigned int bit array. */
49 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
50
51 @@ -1061,6 +1064,14 @@ manage(Window w, XWindowAttributes *wa)
52 c->y = MAX(c->y, c->mon->wy);
53 c->bw = borderpx;
54
55 + selmon->tagset[selmon->seltags] &= ~scratchtag;
56 + if (!strcmp(c->name, scratchpadname)) {
57 + c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
58 + c->isfloating = True;
59 + c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
60 + c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
61 + }
62 +
63 wc.border_width = c->bw;
64 XConfigureWindow(dpy, w, CWBorderWidth, &wc);
65 XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
66 @@ -1651,6 +1662,7 @@ spawn(const Arg *arg)
67
68 if (arg->v == dmenucmd)
69 dmenumon[0] = '0' + selmon->num;
70 + selmon->tagset[selmon->seltags] &= ~scratchtag;
71 if (fork() == 0) {
72 if (dpy)
73 close(ConnectionNumber(dpy));
74 @@ -1735,6 +1747,28 @@ togglefloating(const Arg *arg)
75 arrange(selmon);
76 }
77
78 +void
79 +togglescratch(const Arg *arg)
80 +{
81 + Client *c;
82 + unsigned int found = 0;
83 +
84 + for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
85 + if (found) {
86 + unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
87 + if (newtagset) {
88 + selmon->tagset[selmon->seltags] = newtagset;
89 + focus(NULL);
90 + arrange(selmon);
91 + }
92 + if (ISVISIBLE(c)) {
93 + focus(c);
94 + restack(selmon);
95 + }
96 + } else
97 + spawn(arg);
98 +}
99 +
100 void
101 toggletag(const Arg *arg)
102 {
103 --
104 2.44.0
105