aboutsummaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-18 14:20:56 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-18 14:20:56 +0200
commit0c6062041035105c6266f6bedb286c1990516fa7 (patch)
tree0333fb545f61fa6a409e8fd9d1167ee2f9b25428 /layout.c
parent50be6c8b67c500ee4aa07919609fa80785fd389d (diff)
downloaddwm-0c6062041035105c6266f6bedb286c1990516fa7.tar.gz
hmm I doubt the usefulness of storing this information...
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/layout.c b/layout.c
index 030c282..aa3bff5 100644
--- a/layout.c
+++ b/layout.c
@@ -1,6 +1,9 @@
/* See LICENSE file for copyright and license details. */
#include "dwm.h"
#include <stdlib.h>
+#include <string.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
/* static */
@@ -10,6 +13,7 @@ typedef struct {
} Layout;
unsigned int blw = 0;
+static char prop[128];
static unsigned int ltidx = 0; /* default */
static void
@@ -103,6 +107,28 @@ initlayouts(void) {
}
}
+void
+loaddwmprops(void) {
+ unsigned int i;
+ XTextProperty name;
+
+ /* check if window has set a property */
+ name.nitems = 0;
+ XGetTextProperty(dpy, root, &name, dwmprops);
+ 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++)
+ seltags[i] = prop[i] == '1';
+ if(i < sizeof prop - 1 && prop[i] != '\0') {
+ i = prop[i] - '0';
+ if(i < nlayouts)
+ ltidx = i;
+ }
+ }
+}
+
Client *
nexttiled(Client *c) {
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
@@ -139,6 +165,19 @@ restack(void) {
}
void
+savedwmprops(void) {
+ unsigned int i;
+
+ for(i = 0; i < ntags && i < sizeof prop - 1; i++)
+ prop[i] = seltags[i] ? '1' : '0';
+ if(i < sizeof prop - 1)
+ prop[i++] = (char)ltidx;
+ prop[i] = '\0';
+ XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
+ PropModeReplace, (unsigned char *)prop, i);
+}
+
+void
setlayout(const char *arg) {
int i;
@@ -156,6 +195,7 @@ setlayout(const char *arg) {
arrange();
else
drawstatus();
+ savedwmprops();
}
void