summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-19 10:40:07 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-19 10:40:07 +0200
commit96d7fe16eaf6b656800f08da3156bacd75ca3b08 (patch)
tree98d884e096b5108d8181914540718b6b82c6893e
parentsmall fix (diff)
downloaddwm-96d7fe16eaf6b656800f08da3156bacd75ca3b08.tar.gz
dwm-96d7fe16eaf6b656800f08da3156bacd75ca3b08.zip
prepared merging layout.c and tag.c into screen.c
Diffstat (limited to '')
-rw-r--r--client.c36
-rw-r--r--dwm.h4
-rw-r--r--layout.c17
-rw-r--r--main.c28
4 files changed, 39 insertions, 46 deletions
diff --git a/client.c b/client.c
index d11ef7f..d94c0ed 100644
--- a/client.c
+++ b/client.c
@@ -185,15 +185,8 @@ Bool
185loadprops(Client *c) { 185loadprops(Client *c) {
186 unsigned int i; 186 unsigned int i;
187 Bool result = False; 187 Bool result = False;
188 XTextProperty name; 188
189 189 if(gettextprop(c->win, dwmprops, prop, sizeof prop)) {
190 /* check if window has set a property */
191 name.nitems = 0;
192 XGetTextProperty(dpy, c->win, &name, dwmprops);
193 if(name.nitems && name.encoding == XA_STRING) {
194 strncpy(prop, (char *)name.value, sizeof prop - 1);
195 prop[sizeof prop - 1] = '\0';
196 XFree(name.value);
197 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) 190 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
198 if((c->tags[i] = prop[i] == '1')) 191 if((c->tags[i] = prop[i] == '1'))
199 result = True; 192 result = True;
@@ -424,27 +417,6 @@ updatesizehints(Client *c) {
424 417
425void 418void
426updatetitle(Client *c) { 419updatetitle(Client *c) {
427 char **list = NULL; 420 if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
428 int n; 421 gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
429 XTextProperty name;
430
431 name.nitems = 0;
432 c->name[0] = 0;
433 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
434 if(!name.nitems)
435 XGetWMName(dpy, c->win, &name);
436 if(!name.nitems)
437 return;
438 if(name.encoding == XA_STRING)
439 strncpy(c->name, (char *)name.value, sizeof c->name - 1);
440 else {
441 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
442 && n > 0 && *list)
443 {
444 strncpy(c->name, *list, sizeof c->name - 1);
445 XFreeStringList(list);
446 }
447 }
448 c->name[sizeof c->name - 1] = '\0';
449 XFree(name.value);
450} 422}
diff --git a/dwm.h b/dwm.h
index 9dd764f..36a0266 100644
--- a/dwm.h
+++ b/dwm.h
@@ -39,7 +39,7 @@ enum { BarTop, BarBot, BarOff }; /* bar position */
39enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 39enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
40enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ 40enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
41enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ 41enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
42enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ 42enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
43 43
44typedef struct Client Client; 44typedef struct Client Client;
45struct Client { 45struct Client {
@@ -131,6 +131,8 @@ void togglebar(const char *arg); /* shows/hides the bar */
131void togglemax(const char *arg); /* toggles maximization of floating client */ 131void togglemax(const char *arg); /* toggles maximization of floating client */
132 132
133/* main.c */ 133/* main.c */
134Bool gettextprop(Window w, Atom atom,
135 char *text, unsigned int size); /* return text property, UTF-8 compliant */
134void updatebarpos(void); /* updates the bar position */ 136void updatebarpos(void); /* updates the bar position */
135void quit(const char *arg); /* quit dwm nicely */ 137void quit(const char *arg); /* quit dwm nicely */
136int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ 138int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
diff --git a/layout.c b/layout.c
index 96e125a..2763d2c 100644
--- a/layout.c
+++ b/layout.c
@@ -98,7 +98,6 @@ void
98initlayouts(void) { 98initlayouts(void) {
99 unsigned int i, w; 99 unsigned int i, w;
100 100
101 /* TODO deserialize ltidx if present */
102 nlayouts = sizeof layouts / sizeof layouts[0]; 101 nlayouts = sizeof layouts / sizeof layouts[0];
103 for(blw = i = 0; i < nlayouts; i++) { 102 for(blw = i = 0; i < nlayouts; i++) {
104 w = textw(layouts[i].symbol); 103 w = textw(layouts[i].symbol);
@@ -110,21 +109,13 @@ initlayouts(void) {
110void 109void
111loaddwmprops(void) { 110loaddwmprops(void) {
112 unsigned int i; 111 unsigned int i;
113 XTextProperty name; 112
114 113 if(gettextprop(root, dwmprops, prop, sizeof prop)) {
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++) 114 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
123 seltags[i] = prop[i] == '1'; 115 seltags[i] = prop[i] == '1';
124 if(i < sizeof prop - 1 && prop[i] != '\0') { 116 if(i < sizeof prop - 1 && prop[i] != '\0') {
125 i = prop[i]; 117 if(prop[i] < nlayouts)
126 if(i < nlayouts) 118 ltidx = prop[i];
127 ltidx = i;
128 } 119 }
129 } 120 }
130} 121}
diff --git a/main.c b/main.c
index 7cc5ecf..9127d16 100644
--- a/main.c
+++ b/main.c
@@ -143,6 +143,7 @@ setup(void) {
143 dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False); 143 dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False);
144 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); 144 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
145 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); 145 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
146 wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
146 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); 147 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
147 netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); 148 netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
148 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); 149 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
@@ -220,6 +221,33 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
220 221
221/* extern */ 222/* extern */
222 223
224Bool
225gettextprop(Window w, Atom atom, char *text, unsigned int size) {
226 char **list = NULL;
227 int n;
228 XTextProperty name;
229
230 if(!text || size == 0)
231 return False;
232 text[0] = '\0';
233 XGetTextProperty(dpy, w, &name, atom);
234 if(!name.nitems)
235 return False;
236 if(name.encoding == XA_STRING)
237 strncpy(text, (char *)name.value, size - 1);
238 else {
239 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
240 && n > 0 && *list)
241 {
242 strncpy(text, *list, size - 1);
243 XFreeStringList(list);
244 }
245 }
246 text[size - 1] = '\0';
247 XFree(name.value);
248 return True;
249}
250
223void 251void
224quit(const char *arg) { 252quit(const char *arg) {
225 readin = running = False; 253 readin = running = False;