summaryrefslogtreecommitdiffstats
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
parentcleaned up settags-handling (diff)
downloaddwm-0c6062041035105c6266f6bedb286c1990516fa7.tar.gz
dwm-0c6062041035105c6266f6bedb286c1990516fa7.zip
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 @@
1/* See LICENSE file for copyright and license details. */ 1/* See LICENSE file for copyright and license details. */
2#include "dwm.h" 2#include "dwm.h"
3#include <stdlib.h> 3#include <stdlib.h>
4#include <string.h>
5#include <X11/Xatom.h>
6#include <X11/Xutil.h>
4 7
5/* static */ 8/* static */
6 9
@@ -10,6 +13,7 @@ typedef struct {
10} Layout; 13} Layout;
11 14
12unsigned int blw = 0; 15unsigned int blw = 0;
16static char prop[128];
13static unsigned int ltidx = 0; /* default */ 17static unsigned int ltidx = 0; /* default */
14 18
15static void 19static void
@@ -103,6 +107,28 @@ initlayouts(void) {
103 } 107 }
104} 108}
105 109
110void
111loaddwmprops(void) {
112 unsigned int i;
113 XTextProperty name;
114
115 /* check if window has set a property */
116 name.nitems = 0;
117 XGetTextProperty(dpy, root, &name, dwmprops);
118 if(name.nitems && name.encoding == XA_STRING) {
119 strncpy(prop, (char *)name.value, sizeof prop - 1);
120 prop[sizeof prop - 1] = '\0';
121 XFree(name.value);
122 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
123 seltags[i] = prop[i] == '1';
124 if(i < sizeof prop - 1 && prop[i] != '\0') {
125 i = prop[i] - '0';
126 if(i < nlayouts)
127 ltidx = i;
128 }
129 }
130}
131
106Client * 132Client *
107nexttiled(Client *c) { 133nexttiled(Client *c) {
108 for(; c && (c->isfloating || !isvisible(c)); c = c->next); 134 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
@@ -139,6 +165,19 @@ restack(void) {
139} 165}
140 166
141void 167void
168savedwmprops(void) {
169 unsigned int i;
170
171 for(i = 0; i < ntags && i < sizeof prop - 1; i++)
172 prop[i] = seltags[i] ? '1' : '0';
173 if(i < sizeof prop - 1)
174 prop[i++] = (char)ltidx;
175 prop[i] = '\0';
176 XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
177 PropModeReplace, (unsigned char *)prop, i);
178}
179
180void
142setlayout(const char *arg) { 181setlayout(const char *arg) {
143 int i; 182 int i;
144 183
@@ -156,6 +195,7 @@ setlayout(const char *arg) {
156 arrange(); 195 arrange();
157 else 196 else
158 drawstatus(); 197 drawstatus();
198 savedwmprops();
159} 199}
160 200
161void 201void