changeset: 949:99ee5c370f94
tag: tip
user: Anselm R. Garbe <garbeam_AT_gmail.com>
date: Mon Aug 13 20:06:00 2007 +0200
summary: tags should be persistent now during X server run
diff -r 4d9c86f8ed65 -r 99ee5c370f94 dwm.h
--- a/dwm.h Mon Aug 13 19:22:51 2007 +0200
+++ b/dwm.h Mon Aug 13 20:06:00 2007 +0200
@@ -81,7 +81,7 @@ extern unsigned int bh, blw, bpos; /* b
extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */
extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
-extern Atom wmatom[WMLast], netatom[NetLast];
+extern Atom dwmtags, wmatom[WMLast], netatom[NetLast];
extern Bool selscreen, *seltag; /* seltag is array of Bool */
extern Client *clients, *sel, *stack; /* global client list and stack */
extern Cursor cursor[CurLast];
diff -r 4d9c86f8ed65 -r 99ee5c370f94 layout.c
--- a/layout.c Mon Aug 13 19:22:51 2007 +0200
+++ b/layout.c Mon Aug 13 20:06:00 2007 +0200
@@ -1,6 +1,8 @@
/* See LICENSE file for copyright and license details. */
#include "dwm.h"
#include <stdlib.h>
+
+/* static */
typedef struct {
const char *symbol;
@@ -10,10 +12,8 @@ unsigned int blw = 0;
unsigned int blw = 0;
static Layout *lt = NULL;
-/* static */
-
static void
-floating(void) {
+floating(void) { /* default floating layout */
Client *c;
for(c = clients; c; c = c->next)
diff -r 4d9c86f8ed65 -r 99ee5c370f94 main.c
--- a/main.c Mon Aug 13 19:22:51 2007 +0200
+++ b/main.c Mon Aug 13 20:06:00 2007 +0200
@@ -19,7 +19,7 @@ unsigned int bh, ntags;
unsigned int bh, ntags;
unsigned int bpos = BARPOS;
unsigned int numlockmask = 0;
-Atom wmatom[WMLast], netatom[NetLast];
+Atom dwmtags, wmatom[WMLast], netatom[NetLast];
Bool *seltag;
Bool selscreen = True;
Client *clients = NULL;
@@ -139,6 +139,7 @@ setup(void) {
XSetWindowAttributes wa;
/* init atoms */
+ dwmtags = XInternAtom(dpy, "__DWM_TAGS", False);
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
diff -r 4d9c86f8ed65 -r 99ee5c370f94 tag.c
--- a/tag.c Mon Aug 13 19:22:51 2007 +0200
+++ b/tag.c Mon Aug 13 20:06:00 2007 +0200
@@ -3,6 +3,8 @@
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <X11/Xatom.h>
#include <X11/Xutil.h>
/* static */
@@ -23,6 +25,7 @@ RULES
static Regs *regs = NULL;
static unsigned int nrules = 0;
+static char prop[512];
/* extern */
@@ -65,16 +68,32 @@ isvisible(Client *c) {
void
settags(Client *c, Client *trans) {
- char prop[512];
unsigned int i, j;
regmatch_t tmp;
Bool matched = trans != NULL;
XClassHint ch = { 0 };
+ XTextProperty name;
- if(matched)
+ if(matched) {
for(i = 0; i < ntags; i++)
c->tags[i] = trans->tags[i];
+ return;
+ }
else {
+ /* check if window has set a property */
+ name.nitems = 0;
+ XGetTextProperty(dpy, c->win, &name, dwmtags);
+ if(name.nitems && name.encoding == XA_STRING) {
+ strncpy(prop, (char *)name.value, sizeof prop - 1);
+ prop[sizeof prop - 1] = '\0';
+ XFree(name.value);
+ for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
+ if((c->tags[i] = prop[i] == '+'))
+ matched = True;
+ }
+ if(matched)
+ return;
+ /* rule matching */
XGetClassHint(dpy, c->win, &ch);
snprintf(prop, sizeof prop, "%s:%s:%s",
ch.res_class ? ch.res_class : "",
@@ -110,6 +129,12 @@ tag(const char *arg) {
i = arg ? atoi(arg) : 0;
if(i >= 0 && i < ntags)
sel->tags[i] = True;
+ if(sel) {
+ for(i = 0; i < ntags && i < sizeof prop - 1; i++)
+ prop[i] = sel->tags[i] ? '+' : '-';
+ prop[i] = '\0';
+ XChangeProperty(dpy, sel->win, dwmtags, XA_STRING, 8, PropModeReplace, (unsigned char *)prop, i);
+ }
arrange();
}
Received on Mon Aug 13 2007 - 20:09:44 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:52 UTC