diff options
Diffstat (limited to '')
| -rw-r--r-- | client.c | 38 | ||||
| -rw-r--r-- | config.mk | 4 | ||||
| -rw-r--r-- | dwm.h | 8 | ||||
| -rw-r--r-- | layout.c | 40 | ||||
| -rw-r--r-- | main.c | 5 | ||||
| -rw-r--r-- | tag.c | 10 |
6 files changed, 74 insertions, 31 deletions
| @@ -7,7 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | /* static */ | 8 | /* static */ |
| 9 | 9 | ||
| 10 | static char config[128]; | 10 | static char prop[128]; |
| 11 | 11 | ||
| 12 | static void | 12 | static void |
| 13 | attachstack(Client *c) { | 13 | attachstack(Client *c) { |
| @@ -182,23 +182,23 @@ killclient(const char *arg) { | |||
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | Bool | 184 | Bool |
| 185 | loadconfig(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 | XTextProperty name; |
| 189 | 189 | ||
| 190 | /* check if window has set a property */ | 190 | /* check if window has set a property */ |
| 191 | name.nitems = 0; | 191 | name.nitems = 0; |
| 192 | XGetTextProperty(dpy, c->win, &name, dwmconfig); | 192 | XGetTextProperty(dpy, c->win, &name, dwmprops); |
| 193 | if(name.nitems && name.encoding == XA_STRING) { | 193 | if(name.nitems && name.encoding == XA_STRING) { |
| 194 | strncpy(config, (char *)name.value, sizeof config - 1); | 194 | strncpy(prop, (char *)name.value, sizeof prop - 1); |
| 195 | config[sizeof config - 1] = '\0'; | 195 | prop[sizeof prop - 1] = '\0'; |
| 196 | XFree(name.value); | 196 | XFree(name.value); |
| 197 | for(i = 0; i < ntags && i < sizeof config - 1 && config[i] != '\0'; i++) | 197 | for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) |
| 198 | if((c->tags[i] = config[i] == '1')) | 198 | if((c->tags[i] = prop[i] == '1')) |
| 199 | result = True; | 199 | result = True; |
| 200 | if(i < sizeof config - 1 && config[i] != '\0') | 200 | if(i < sizeof prop - 1 && prop[i] != '\0') |
| 201 | c->isfloating = config[i] == '1'; | 201 | c->isfloating = prop[i] == '1'; |
| 202 | } | 202 | } |
| 203 | return result; | 203 | return result; |
| 204 | } | 204 | } |
| @@ -249,11 +249,11 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 249 | if(t) | 249 | if(t) |
| 250 | for(i = 0; i < ntags; i++) | 250 | for(i = 0; i < ntags; i++) |
| 251 | c->tags[i] = t->tags[i]; | 251 | c->tags[i] = t->tags[i]; |
| 252 | if(!loadconfig(c)) | 252 | if(!loadprops(c)) |
| 253 | applyrules(c); | 253 | applyrules(c); |
| 254 | if(!c->isfloating) | 254 | if(!c->isfloating) |
| 255 | c->isfloating = (rettrans == Success) || c->isfixed; | 255 | c->isfloating = (rettrans == Success) || c->isfixed; |
| 256 | saveconfig(c); | 256 | saveprops(c); |
| 257 | attach(c); | 257 | attach(c); |
| 258 | attachstack(c); | 258 | attachstack(c); |
| 259 | XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ | 259 | XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ |
| @@ -325,16 +325,16 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { | |||
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | void | 327 | void |
| 328 | saveconfig(Client *c) { | 328 | saveprops(Client *c) { |
| 329 | unsigned int i; | 329 | unsigned int i; |
| 330 | 330 | ||
| 331 | for(i = 0; i < ntags && i < sizeof config - 1; i++) | 331 | for(i = 0; i < ntags && i < sizeof prop - 1; i++) |
| 332 | config[i] = c->tags[i] ? '1' : '0'; | 332 | prop[i] = c->tags[i] ? '1' : '0'; |
| 333 | if(i < sizeof config - 1) | 333 | if(i < sizeof prop - 1) |
| 334 | config[i++] = c->isfloating ? '1' : '0'; | 334 | prop[i++] = c->isfloating ? '1' : '0'; |
| 335 | config[i] = '\0'; | 335 | prop[i] = '\0'; |
| 336 | XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8, | 336 | XChangeProperty(dpy, c->win, dwmprops, XA_STRING, 8, |
| 337 | PropModeReplace, (unsigned char *)config, i); | 337 | PropModeReplace, (unsigned char *)prop, i); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | void | 340 | void |
| @@ -20,8 +20,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | |||
| 20 | # flags | 20 | # flags |
| 21 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | 21 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" |
| 22 | LDFLAGS = -s ${LIBS} | 22 | LDFLAGS = -s ${LIBS} |
| 23 | #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | 23 | CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" |
| 24 | #LDFLAGS = -g ${LIBS} | 24 | LDFLAGS = -g ${LIBS} |
| 25 | 25 | ||
| 26 | # Solaris | 26 | # Solaris |
| 27 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | 27 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" |
| @@ -81,7 +81,7 @@ extern int wax, way, wah, waw; /* windowarea geometry */ | |||
| 81 | extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ | 81 | extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ |
| 82 | extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ | 82 | extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ |
| 83 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ | 83 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ |
| 84 | extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast]; | 84 | extern Atom dwmprops, wmatom[WMLast], netatom[NetLast]; |
| 85 | extern Bool selscreen, *seltags; /* seltags is array of Bool */ | 85 | extern Bool selscreen, *seltags; /* seltags is array of Bool */ |
| 86 | extern Client *clients, *sel, *stack; /* global client list and stack */ | 86 | extern Client *clients, *sel, *stack; /* global client list and stack */ |
| 87 | extern Cursor cursor[CurLast]; | 87 | extern Cursor cursor[CurLast]; |
| @@ -96,11 +96,11 @@ void configure(Client *c); /* send synthetic configure event */ | |||
| 96 | void detach(Client *c); /* detaches c from global client list */ | 96 | void detach(Client *c); /* detaches c from global client list */ |
| 97 | void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ | 97 | void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ |
| 98 | void killclient(const char *arg); /* kill sel nicely */ | 98 | void killclient(const char *arg); /* kill sel nicely */ |
| 99 | Bool loadconfig(Client *c); /* loads client properties */ | 99 | Bool loadprops(Client *c); /* loads client properties */ |
| 100 | void manage(Window w, XWindowAttributes *wa); /* manage new client */ | 100 | void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
| 101 | void resize(Client *c, int x, int y, | 101 | void resize(Client *c, int x, int y, |
| 102 | int w, int h, Bool sizehints); /* resize with given coordinates c*/ | 102 | int w, int h, Bool sizehints); /* resize with given coordinates c*/ |
| 103 | void saveconfig(Client *c); /* saves client properties */ | 103 | void saveprops(Client *c); /* saves client properties */ |
| 104 | void unban(Client *c); /* unbans c */ | 104 | void unban(Client *c); /* unbans c */ |
| 105 | void unmanage(Client *c, long state); /* unmanage c */ | 105 | void unmanage(Client *c, long state); /* unmanage c */ |
| 106 | void updatesizehints(Client *c); /* update the size hint variables of c */ | 106 | void updatesizehints(Client *c); /* update the size hint variables of c */ |
| @@ -122,8 +122,10 @@ const char *getsymbol(void); /* returns symbol of enabled layout */ | |||
| 122 | Bool isfloating(void); /* returns True if floating layout is enabled */ | 122 | Bool isfloating(void); /* returns True if floating layout is enabled */ |
| 123 | Bool isarrange(void (*func)()); /* returns True if func is the layout function in use */ | 123 | Bool isarrange(void (*func)()); /* returns True if func is the layout function in use */ |
| 124 | void initlayouts(void); /* initialize layout array */ | 124 | void initlayouts(void); /* initialize layout array */ |
| 125 | void loaddwmprops(void); /* loads dwm properties */ | ||
| 125 | Client *nexttiled(Client *c); /* returns tiled successor of c */ | 126 | Client *nexttiled(Client *c); /* returns tiled successor of c */ |
| 126 | void restack(void); /* restores z layers of all clients */ | 127 | void restack(void); /* restores z layers of all clients */ |
| 128 | void savedwmprops(void); /* saves dwm properties */ | ||
| 127 | void setlayout(const char *arg); /* sets layout, NULL means next layout */ | 129 | void setlayout(const char *arg); /* sets layout, NULL means next layout */ |
| 128 | void togglebar(const char *arg); /* shows/hides the bar */ | 130 | void togglebar(const char *arg); /* shows/hides the bar */ |
| 129 | void togglemax(const char *arg); /* toggles maximization of floating client */ | 131 | void togglemax(const char *arg); /* toggles maximization of floating client */ |
| @@ -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 | ||
| 12 | unsigned int blw = 0; | 15 | unsigned int blw = 0; |
| 16 | static char prop[128]; | ||
| 13 | static unsigned int ltidx = 0; /* default */ | 17 | static unsigned int ltidx = 0; /* default */ |
| 14 | 18 | ||
| 15 | static void | 19 | static void |
| @@ -103,6 +107,28 @@ initlayouts(void) { | |||
| 103 | } | 107 | } |
| 104 | } | 108 | } |
| 105 | 109 | ||
| 110 | void | ||
| 111 | loaddwmprops(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 | |||
| 106 | Client * | 132 | Client * |
| 107 | nexttiled(Client *c) { | 133 | nexttiled(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 | ||
| 141 | void | 167 | void |
| 168 | savedwmprops(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 | |||
| 180 | void | ||
| 142 | setlayout(const char *arg) { | 181 | setlayout(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 | ||
| 161 | void | 201 | void |
| @@ -20,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah; | |||
| 20 | unsigned int bh, ntags; | 20 | unsigned int bh, ntags; |
| 21 | unsigned int bpos = BARPOS; | 21 | unsigned int bpos = BARPOS; |
| 22 | unsigned int numlockmask = 0; | 22 | unsigned int numlockmask = 0; |
| 23 | Atom dwmconfig, wmatom[WMLast], netatom[NetLast]; | 23 | Atom dwmprops, wmatom[WMLast], netatom[NetLast]; |
| 24 | Bool *seltags; | 24 | Bool *seltags; |
| 25 | Bool selscreen = True; | 25 | Bool selscreen = True; |
| 26 | Client *clients = NULL; | 26 | Client *clients = NULL; |
| @@ -140,7 +140,7 @@ setup(void) { | |||
| 140 | XSetWindowAttributes wa; | 140 | XSetWindowAttributes wa; |
| 141 | 141 | ||
| 142 | /* init atoms */ | 142 | /* init atoms */ |
| 143 | dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", 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[WMState] = XInternAtom(dpy, "WM_STATE", False); | 146 | wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); |
| @@ -205,6 +205,7 @@ setup(void) { | |||
| 205 | XSetFont(dpy, dc.gc, dc.font.xfont->fid); | 205 | XSetFont(dpy, dc.gc, dc.font.xfont->fid); |
| 206 | /* multihead support */ | 206 | /* multihead support */ |
| 207 | selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); | 207 | selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
| 208 | loaddwmprops(); | ||
| 208 | } | 209 | } |
| 209 | 210 | ||
| 210 | /* | 211 | /* |
| @@ -3,8 +3,6 @@ | |||
| 3 | #include <regex.h> | 3 | #include <regex.h> |
| 4 | #include <stdio.h> | 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| 6 | #include <string.h> | ||
| 7 | #include <X11/Xatom.h> | ||
| 8 | #include <X11/Xutil.h> | 6 | #include <X11/Xutil.h> |
| 9 | 7 | ||
| 10 | /* static */ | 8 | /* static */ |
| @@ -118,7 +116,7 @@ tag(const char *arg) { | |||
| 118 | i = idxoftag(arg); | 116 | i = idxoftag(arg); |
| 119 | if(i >= 0 && i < ntags) | 117 | if(i >= 0 && i < ntags) |
| 120 | sel->tags[i] = True; | 118 | sel->tags[i] = True; |
| 121 | saveconfig(sel); | 119 | saveprops(sel); |
| 122 | arrange(); | 120 | arrange(); |
| 123 | } | 121 | } |
| 124 | 122 | ||
| @@ -129,7 +127,7 @@ togglefloating(const char *arg) { | |||
| 129 | sel->isfloating = !sel->isfloating; | 127 | sel->isfloating = !sel->isfloating; |
| 130 | if(sel->isfloating) { | 128 | if(sel->isfloating) { |
| 131 | resize(sel, sel->x, sel->y, sel->w, sel->h, True); | 129 | resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
| 132 | saveconfig(sel); | 130 | saveprops(sel); |
| 133 | } | 131 | } |
| 134 | arrange(); | 132 | arrange(); |
| 135 | } | 133 | } |
| @@ -145,7 +143,7 @@ toggletag(const char *arg) { | |||
| 145 | for(j = 0; j < ntags && !sel->tags[j]; j++); | 143 | for(j = 0; j < ntags && !sel->tags[j]; j++); |
| 146 | if(j == ntags) | 144 | if(j == ntags) |
| 147 | sel->tags[i] = True; | 145 | sel->tags[i] = True; |
| 148 | saveconfig(sel); | 146 | saveprops(sel); |
| 149 | arrange(); | 147 | arrange(); |
| 150 | } | 148 | } |
| 151 | 149 | ||
| @@ -158,6 +156,7 @@ toggleview(const char *arg) { | |||
| 158 | for(j = 0; j < ntags && !seltags[j]; j++); | 156 | for(j = 0; j < ntags && !seltags[j]; j++); |
| 159 | if(j == ntags) | 157 | if(j == ntags) |
| 160 | seltags[i] = True; /* cannot toggle last view */ | 158 | seltags[i] = True; /* cannot toggle last view */ |
| 159 | savedwmprops(); | ||
| 161 | arrange(); | 160 | arrange(); |
| 162 | } | 161 | } |
| 163 | 162 | ||
| @@ -170,5 +169,6 @@ view(const char *arg) { | |||
| 170 | i = idxoftag(arg); | 169 | i = idxoftag(arg); |
| 171 | if(i >= 0 && i < ntags) | 170 | if(i >= 0 && i < ntags) |
| 172 | seltags[i] = True; | 171 | seltags[i] = True; |
| 172 | savedwmprops(); | ||
| 173 | arrange(); | 173 | arrange(); |
| 174 | } | 174 | } |
