-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14-dwm-6.0-remember-tags.diff
91 lines (86 loc) · 3.19 KB
/
14-dwm-6.0-remember-tags.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
82
83
84
85
86
87
88
89
90
91
Homepage: http://hg.punctweb.ro
--- a/dwm.c 2013-02-11 22:11:39.290773224 +0200
+++ b/dwm.c 2013-02-11 22:11:39.292773224 +0200
@@ -63,6 +63,7 @@ enum { NetSupported, NetWMName, NetWMSta
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
+enum { DWMTags, DWMLast }; /* DWM atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -273,6 +274,7 @@ static void gaplessgrid(Monitor *m);
static void pidgin(Monitor *m);
static void togglescratch(const Arg *arg);
static void togglemax(const Arg *arg);
+static void settagsatom(Window w, unsigned int tags);
/* variables */
static const char broken[] = "broken";
@@ -298,7 +300,7 @@ static void (*handler[LASTEvent]) (XEven
[PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify
};
-static Atom wmatom[WMLast], netatom[NetLast];
+static Atom wmatom[WMLast], netatom[NetLast], dwmatom[DWMLast];
static Bool running = True;
static Cursor cursor[CurLast];
static Display *dpy;
@@ -1166,6 +1168,10 @@ manage(Window w, XWindowAttributes *wa)
Client *c, *t = NULL;
Window trans = None;
XWindowChanges wc;
+ int format;
+ unsigned int *ptags;
+ unsigned long n, extra;
+ Atom atom;
if(!(c = calloc(1, sizeof(Client))))
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
@@ -1178,7 +1184,13 @@ manage(Window w, XWindowAttributes *wa)
else {
c->mon = selmon;
applyrules(c);
+ if(XGetWindowProperty(dpy, c->win, dwmatom[DWMTags], 0L, 1L, False, XA_CARDINAL,
+ &atom, &format, &n, &extra, (unsigned char **)&ptags) == Success && n == 1 && *ptags != 0) {
+ c->tags = *ptags;
+ XFree(ptags);
+ }
}
+ settagsatom(c->win, c->tags);
/* geometry */
c->x = c->oldx = wa->x;
c->y = c->oldy = wa->y;
@@ -1681,6 +1693,7 @@ setup(void) {
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
+ dwmatom[DWMTags] = XInternAtom(dpy, "_DWM_TAGS", False);
/* init cursors */
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
@@ -1758,6 +1771,7 @@ void
tag(const Arg *arg) {
if(selmon->sel && arg->ui & TAGMASK) {
selmon->sel->tags = arg->ui & TAGMASK;
+ settagsatom(selmon->sel->win, selmon->sel->tags);
focus(NULL);
arrange(selmon);
if(viewontag)
@@ -1850,6 +1864,7 @@ toggletag(const Arg *arg) {
}
selmon->sel->tags = newtags;
selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ settagsatom(selmon->sel->win, selmon->sel->tags);
focus(NULL);
arrange(selmon);
}
@@ -2512,6 +2527,12 @@ togglemax(const Arg *arg) {
}
}
+void
+settagsatom(Window w, unsigned int tags) {
+ XChangeProperty(dpy, w, dwmatom[DWMTags], XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char*)&tags, 1);
+}
+
int
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))