diff options
| author | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-19 10:40:07 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-19 10:40:07 +0200 |
| commit | 96d7fe16eaf6b656800f08da3156bacd75ca3b08 (patch) | |
| tree | 98d884e096b5108d8181914540718b6b82c6893e | |
| parent | small fix (diff) | |
| download | dwm-96d7fe16eaf6b656800f08da3156bacd75ca3b08.tar.gz dwm-96d7fe16eaf6b656800f08da3156bacd75ca3b08.zip | |
prepared merging layout.c and tag.c into screen.c
| -rw-r--r-- | client.c | 36 | ||||
| -rw-r--r-- | dwm.h | 4 | ||||
| -rw-r--r-- | layout.c | 17 | ||||
| -rw-r--r-- | main.c | 28 |
4 files changed, 39 insertions, 46 deletions
| @@ -185,15 +185,8 @@ Bool | |||
| 185 | loadprops(Client *c) { | 185 | loadprops(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 | ||
| 425 | void | 418 | void |
| 426 | updatetitle(Client *c) { | 419 | updatetitle(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 | } |
| @@ -39,7 +39,7 @@ enum { BarTop, BarBot, BarOff }; /* bar position */ | |||
| 39 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | 39 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
| 40 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ | 40 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ |
| 41 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ | 41 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
| 42 | enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ | 42 | enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ |
| 43 | 43 | ||
| 44 | typedef struct Client Client; | 44 | typedef struct Client Client; |
| 45 | struct Client { | 45 | struct Client { |
| @@ -131,6 +131,8 @@ void togglebar(const char *arg); /* shows/hides the bar */ | |||
| 131 | void togglemax(const char *arg); /* toggles maximization of floating client */ | 131 | void togglemax(const char *arg); /* toggles maximization of floating client */ |
| 132 | 132 | ||
| 133 | /* main.c */ | 133 | /* main.c */ |
| 134 | Bool gettextprop(Window w, Atom atom, | ||
| 135 | char *text, unsigned int size); /* return text property, UTF-8 compliant */ | ||
| 134 | void updatebarpos(void); /* updates the bar position */ | 136 | void updatebarpos(void); /* updates the bar position */ |
| 135 | void quit(const char *arg); /* quit dwm nicely */ | 137 | void quit(const char *arg); /* quit dwm nicely */ |
| 136 | int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | 138 | int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
| @@ -98,7 +98,6 @@ void | |||
| 98 | initlayouts(void) { | 98 | initlayouts(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) { | |||
| 110 | void | 109 | void |
| 111 | loaddwmprops(void) { | 110 | loaddwmprops(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 | } |
| @@ -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 | ||
| 224 | Bool | ||
| 225 | gettextprop(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 | |||
| 223 | void | 251 | void |
| 224 | quit(const char *arg) { | 252 | quit(const char *arg) { |
| 225 | readin = running = False; | 253 | readin = running = False; |
