-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10-dwm-6.0-scratchpad.diff
65 lines (59 loc) · 1.83 KB
/
10-dwm-6.0-scratchpad.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Homepage: http://hg.punctweb.ro
--- a/dwm.c 2013-02-11 22:11:39.242773227 +0200
+++ b/dwm.c 2013-02-11 22:11:39.244773226 +0200
@@ -271,6 +271,7 @@ static int shifttag(int dist);
static void tagcycle(const Arg *arg);
static void gaplessgrid(Monitor *m);
static void pidgin(Monitor *m);
+static void togglescratch(const Arg *arg);
/* variables */
static const char broken[] = "broken";
@@ -307,6 +308,8 @@ static Window root;
/* configuration, allows nested code to access above variables */
#include "config.h"
+static unsigned int scratchtag = 1 << LENGTH(tags);
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -1190,6 +1193,14 @@ manage(Window w, XWindowAttributes *wa)
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
c->bw = borderpx;
+ if(!strcmp(c->name, scratchpadname)) {
+ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
+ c->isfloating = True;
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
+ else
+ c->tags &= TAGMASK;
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
@@ -2439,6 +2450,28 @@ pidgin(Monitor *m) {
}
}
+void
+togglescratch(const Arg *arg) {
+ Client *c = NULL;
+ unsigned int found = 0;
+
+ for(c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
+ if(found) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if(newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+ if(ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ }
+ else
+ spawn(arg);
+}
+
int
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))