forked from ok100/dwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-dwm-6.0-scratchpad-stay.diff
81 lines (75 loc) · 2.68 KB
/
03-dwm-6.0-scratchpad-stay.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--- dwm.c.orig 2011-12-19 18:19:17.275713017 +0100
+++ dwm.c 2011-12-19 18:20:58.811158588 +0100
@@ -240,6 +240,7 @@ static int textnw(const char *text, unsi
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglescratch(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, Bool setfocus);
@@ -298,6 +299,8 @@ static Window root;
/* configuration, allows nested code to access above variables */
#include "config.h"
+static unsigned int scratchpadtag = 1 << LENGTH(tags); /* This tag specially for you, Scratchpad. */
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -1170,6 +1173,16 @@ 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) == 0) {
+ c->tags = scratchpadtag;
+ c->isfloating = True;
+ c->x = (c->mon->mw - c->w) - 10;
+ c->y = 20;
+ c->mon->tagset[c->mon->seltags] |= c->tags;
+ } else { /* make sure non-scratchpads stay out of scratchpadtag */
+ c->tags &= TAGMASK;
+ }
+
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
@@ -1775,6 +1788,25 @@ togglefloating(const Arg *arg) {
}
void
+togglescratch(const Arg *arg) {
+ Client *c = NULL;
+ unsigned int found = 0;
+ /* check if a scratchpad is already there in scratchpadtag */
+ for(c = selmon->clients; c && !(found = c->tags & scratchpadtag); c = c->next);
+ if(!found) { /* not found: launch it and put it in its tag (see manage()) */
+ spawn(arg);
+ return;
+ }
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchpadtag;
+ if(newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ arrange(selmon);
+ }
+ focus(c);
+}
+
+
+void
toggletag(const Arg *arg) {
unsigned int i, newtags;
@@ -2083,8 +2115,9 @@ updatewmhints(Client *c) {
void
view(const Arg *arg) {
unsigned int i;
+ unsigned int stag = selmon->tagset[selmon->seltags] & scratchpadtag;
- if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ if((arg->ui & TAGMASK) == (selmon->tagset[selmon->seltags] & TAGMASK))
return;
selmon->seltags ^= 1; /* toggle sel tagset */
if(arg->ui & TAGMASK) {
@@ -2101,6 +2134,7 @@ view(const Arg *arg) {
selmon->curtag^= selmon->prevtag;
selmon->prevtag= selmon->curtag ^ selmon->prevtag;
}
+ selmon->tagset[selmon->seltags] |= stag;
selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
focus(NULL);
arrange(selmon);