summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dwm.h2
-rw-r--r--layout.c6
-rw-r--r--main.c3
-rw-r--r--tag.c29
4 files changed, 33 insertions, 7 deletions
diff --git a/dwm.h b/dwm.h
index 8f5ffdb..b26bd8c 100644
--- a/dwm.h
+++ b/dwm.h
@@ -81,7 +81,7 @@ extern int wax, way, wah, waw; /* windowarea geometry */
81extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ 81extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */
82extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ 82extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */
83extern void (*handler[LASTEvent])(XEvent *); /* event handler */ 83extern void (*handler[LASTEvent])(XEvent *); /* event handler */
84extern Atom wmatom[WMLast], netatom[NetLast]; 84extern Atom dwmtags, wmatom[WMLast], netatom[NetLast];
85extern Bool selscreen, *seltag; /* seltag is array of Bool */ 85extern Bool selscreen, *seltag; /* seltag is array of Bool */
86extern Client *clients, *sel, *stack; /* global client list and stack */ 86extern Client *clients, *sel, *stack; /* global client list and stack */
87extern Cursor cursor[CurLast]; 87extern Cursor cursor[CurLast];
diff --git a/layout.c b/layout.c
index a660fd7..4fb0be3 100644
--- a/layout.c
+++ b/layout.c
@@ -2,6 +2,8 @@
2#include "dwm.h" 2#include "dwm.h"
3#include <stdlib.h> 3#include <stdlib.h>
4 4
5/* static */
6
5typedef struct { 7typedef struct {
6 const char *symbol; 8 const char *symbol;
7 void (*arrange)(void); 9 void (*arrange)(void);
@@ -10,10 +12,8 @@ typedef struct {
10unsigned int blw = 0; 12unsigned int blw = 0;
11static Layout *lt = NULL; 13static Layout *lt = NULL;
12 14
13/* static */
14
15static void 15static void
16floating(void) { 16floating(void) { /* default floating layout */
17 Client *c; 17 Client *c;
18 18
19 for(c = clients; c; c = c->next) 19 for(c = clients; c; c = c->next)
diff --git a/main.c b/main.c
index d72f13d..2140d89 100644
--- a/main.c
+++ b/main.c
@@ -19,7 +19,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah;
19unsigned int bh, ntags; 19unsigned int bh, ntags;
20unsigned int bpos = BARPOS; 20unsigned int bpos = BARPOS;
21unsigned int numlockmask = 0; 21unsigned int numlockmask = 0;
22Atom wmatom[WMLast], netatom[NetLast]; 22Atom dwmtags, wmatom[WMLast], netatom[NetLast];
23Bool *seltag; 23Bool *seltag;
24Bool selscreen = True; 24Bool selscreen = True;
25Client *clients = NULL; 25Client *clients = NULL;
@@ -139,6 +139,7 @@ setup(void) {
139 XSetWindowAttributes wa; 139 XSetWindowAttributes wa;
140 140
141 /* init atoms */ 141 /* init atoms */
142 dwmtags = XInternAtom(dpy, "__DWM_TAGS", False);
142 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); 143 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
143 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); 144 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
144 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); 145 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
diff --git a/tag.c b/tag.c
index bbed872..5161ae2 100644
--- a/tag.c
+++ b/tag.c
@@ -3,6 +3,8 @@
3#include <regex.h> 3#include <regex.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <stdlib.h> 5#include <stdlib.h>
6#include <string.h>
7#include <X11/Xatom.h>
6#include <X11/Xutil.h> 8#include <X11/Xutil.h>
7 9
8/* static */ 10/* static */
@@ -23,6 +25,7 @@ RULES
23 25
24static Regs *regs = NULL; 26static Regs *regs = NULL;
25static unsigned int nrules = 0; 27static unsigned int nrules = 0;
28static char prop[512];
26 29
27/* extern */ 30/* extern */
28 31
@@ -65,16 +68,32 @@ isvisible(Client *c) {
65 68
66void 69void
67settags(Client *c, Client *trans) { 70settags(Client *c, Client *trans) {
68 char prop[512];
69 unsigned int i, j; 71 unsigned int i, j;
70 regmatch_t tmp; 72 regmatch_t tmp;
71 Bool matched = trans != NULL; 73 Bool matched = trans != NULL;
72 XClassHint ch = { 0 }; 74 XClassHint ch = { 0 };
75 XTextProperty name;
73 76
74 if(matched) 77 if(matched) {
75 for(i = 0; i < ntags; i++) 78 for(i = 0; i < ntags; i++)
76 c->tags[i] = trans->tags[i]; 79 c->tags[i] = trans->tags[i];
80 return;
81 }
77 else { 82 else {
83 /* check if window has set a property */
84 name.nitems = 0;
85 XGetTextProperty(dpy, c->win, &name, dwmtags);
86 if(name.nitems && name.encoding == XA_STRING) {
87 strncpy(prop, (char *)name.value, sizeof prop - 1);
88 prop[sizeof prop - 1] = '\0';
89 XFree(name.value);
90 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
91 if((c->tags[i] = prop[i] == '+'))
92 matched = True;
93 }
94 if(matched)
95 return;
96 /* rule matching */
78 XGetClassHint(dpy, c->win, &ch); 97 XGetClassHint(dpy, c->win, &ch);
79 snprintf(prop, sizeof prop, "%s:%s:%s", 98 snprintf(prop, sizeof prop, "%s:%s:%s",
80 ch.res_class ? ch.res_class : "", 99 ch.res_class ? ch.res_class : "",
@@ -110,6 +129,12 @@ tag(const char *arg) {
110 i = arg ? atoi(arg) : 0; 129 i = arg ? atoi(arg) : 0;
111 if(i >= 0 && i < ntags) 130 if(i >= 0 && i < ntags)
112 sel->tags[i] = True; 131 sel->tags[i] = True;
132 if(sel) {
133 for(i = 0; i < ntags && i < sizeof prop - 1; i++)
134 prop[i] = sel->tags[i] ? '+' : '-';
135 prop[i] = '\0';
136 XChangeProperty(dpy, sel->win, dwmtags, XA_STRING, 8, PropModeReplace, (unsigned char *)prop, i);
137 }
113 arrange(); 138 arrange();
114} 139}
115 140