hmm I doubt the usefulness of storing this information...
This commit is contained in:
		
							parent
							
								
									50be6c8b67
								
							
						
					
					
						commit
						0c60620410
					
				
							
								
								
									
										38
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								client.c
									
									
									
									
									
								
							| @ -7,7 +7,7 @@ | |||||||
| 
 | 
 | ||||||
| /* static */ | /* static */ | ||||||
| 
 | 
 | ||||||
| static char config[128]; | static char prop[128]; | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
| attachstack(Client *c) { | attachstack(Client *c) { | ||||||
| @ -182,23 +182,23 @@ killclient(const char *arg) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Bool | Bool | ||||||
| loadconfig(Client *c) { | loadprops(Client *c) { | ||||||
| 	unsigned int i; | 	unsigned int i; | ||||||
| 	Bool result = False; | 	Bool result = False; | ||||||
| 	XTextProperty name; | 	XTextProperty name; | ||||||
| 
 | 
 | ||||||
| 	/* check if window has set a property */ | 	/* check if window has set a property */ | ||||||
| 	name.nitems = 0; | 	name.nitems = 0; | ||||||
| 	XGetTextProperty(dpy, c->win, &name, dwmconfig); | 	XGetTextProperty(dpy, c->win, &name, dwmprops); | ||||||
| 	if(name.nitems && name.encoding == XA_STRING) { | 	if(name.nitems && name.encoding == XA_STRING) { | ||||||
| 		strncpy(config, (char *)name.value, sizeof config - 1); | 		strncpy(prop, (char *)name.value, sizeof prop - 1); | ||||||
| 		config[sizeof config - 1] = '\0'; | 		prop[sizeof prop - 1] = '\0'; | ||||||
| 		XFree(name.value); | 		XFree(name.value); | ||||||
| 		for(i = 0; i < ntags && i < sizeof config - 1 && config[i] != '\0'; i++) | 		for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) | ||||||
| 			if((c->tags[i] = config[i] == '1')) | 			if((c->tags[i] = prop[i] == '1')) | ||||||
| 				result = True; | 				result = True; | ||||||
| 		if(i < sizeof config - 1 && config[i] != '\0') | 		if(i < sizeof prop - 1 && prop[i] != '\0') | ||||||
| 			c->isfloating = config[i] == '1'; | 			c->isfloating = prop[i] == '1'; | ||||||
| 	} | 	} | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
| @ -249,11 +249,11 @@ manage(Window w, XWindowAttributes *wa) { | |||||||
| 	if(t) | 	if(t) | ||||||
| 		for(i = 0; i < ntags; i++) | 		for(i = 0; i < ntags; i++) | ||||||
| 			c->tags[i] = t->tags[i]; | 			c->tags[i] = t->tags[i]; | ||||||
| 	if(!loadconfig(c)) | 	if(!loadprops(c)) | ||||||
| 		applyrules(c); | 		applyrules(c); | ||||||
| 	if(!c->isfloating) | 	if(!c->isfloating) | ||||||
| 		c->isfloating = (rettrans == Success) || c->isfixed; | 		c->isfloating = (rettrans == Success) || c->isfixed; | ||||||
| 	saveconfig(c); | 	saveprops(c); | ||||||
| 	attach(c); | 	attach(c); | ||||||
| 	attachstack(c); | 	attachstack(c); | ||||||
| 	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ | 	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) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void | void | ||||||
| saveconfig(Client *c) { | saveprops(Client *c) { | ||||||
| 	unsigned int i; | 	unsigned int i; | ||||||
| 
 | 
 | ||||||
| 	for(i = 0; i < ntags && i < sizeof config - 1; i++) | 	for(i = 0; i < ntags && i < sizeof prop - 1; i++) | ||||||
| 		config[i] = c->tags[i] ? '1' : '0'; | 		prop[i] = c->tags[i] ? '1' : '0'; | ||||||
| 	if(i < sizeof config - 1) | 	if(i < sizeof prop - 1) | ||||||
| 		config[i++] = c->isfloating ? '1' : '0'; | 		prop[i++] = c->isfloating ? '1' : '0'; | ||||||
| 	config[i] = '\0'; | 	prop[i] = '\0'; | ||||||
| 	XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8, | 	XChangeProperty(dpy, c->win, dwmprops, XA_STRING, 8, | ||||||
| 			PropModeReplace, (unsigned char *)config, i); | 			PropModeReplace, (unsigned char *)prop, i); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void | void | ||||||
|  | |||||||
| @ -20,8 +20,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | |||||||
| # flags
 | # flags
 | ||||||
| CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | ||||||
| LDFLAGS = -s ${LIBS} | LDFLAGS = -s ${LIBS} | ||||||
| #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
 | CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | ||||||
| #LDFLAGS = -g ${LIBS}
 | LDFLAGS = -g ${LIBS} | ||||||
| 
 | 
 | ||||||
| # Solaris
 | # Solaris
 | ||||||
| #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
 | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								dwm.h
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								dwm.h
									
									
									
									
									
								
							| @ -81,7 +81,7 @@ extern int wax, way, wah, waw;			/* windowarea geometry */ | |||||||
| extern unsigned int bh, blw, bpos;		/* bar height, bar layout label width, bar position */ | extern unsigned int bh, blw, bpos;		/* bar height, bar layout label width, bar position */ | ||||||
| extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */ | extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */ | ||||||
| extern void (*handler[LASTEvent])(XEvent *);	/* event handler */ | extern void (*handler[LASTEvent])(XEvent *);	/* event handler */ | ||||||
| extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast]; | extern Atom dwmprops, wmatom[WMLast], netatom[NetLast]; | ||||||
| extern Bool selscreen, *seltags;		/* seltags is array of Bool */ | extern Bool selscreen, *seltags;		/* seltags is array of Bool */ | ||||||
| extern Client *clients, *sel, *stack;		/* global client list and stack */ | extern Client *clients, *sel, *stack;		/* global client list and stack */ | ||||||
| extern Cursor cursor[CurLast]; | extern Cursor cursor[CurLast]; | ||||||
| @ -96,11 +96,11 @@ void configure(Client *c);		/* send synthetic configure event */ | |||||||
| void detach(Client *c);			/* detaches c from global client list */ | void detach(Client *c);			/* detaches c from global client list */ | ||||||
| void focus(Client *c);			/* focus c if visible && !NULL, or focus top visible */ | void focus(Client *c);			/* focus c if visible && !NULL, or focus top visible */ | ||||||
| void killclient(const char *arg);	/* kill sel  nicely */ | void killclient(const char *arg);	/* kill sel  nicely */ | ||||||
| Bool loadconfig(Client *c);		/* loads client properties */ | Bool loadprops(Client *c);		/* loads client properties */ | ||||||
| void manage(Window w, XWindowAttributes *wa);	/* manage new client */ | void manage(Window w, XWindowAttributes *wa);	/* manage new client */ | ||||||
| void resize(Client *c, int x, int y, | void resize(Client *c, int x, int y, | ||||||
| 		int w, int h, Bool sizehints);	/* resize with given coordinates c*/ | 		int w, int h, Bool sizehints);	/* resize with given coordinates c*/ | ||||||
| void saveconfig(Client *c);		/* saves client properties */ | void saveprops(Client *c);		/* saves client properties */ | ||||||
| void unban(Client *c);			/* unbans c */ | void unban(Client *c);			/* unbans c */ | ||||||
| void unmanage(Client *c, long state);	/* unmanage c */ | void unmanage(Client *c, long state);	/* unmanage c */ | ||||||
| void updatesizehints(Client *c);	/* update the size hint variables of c */ | void updatesizehints(Client *c);	/* update the size hint variables of c */ | ||||||
| @ -122,8 +122,10 @@ const char *getsymbol(void);		/* returns symbol of enabled layout */ | |||||||
| Bool isfloating(void);			/* returns True if floating layout is enabled */ | Bool isfloating(void);			/* returns True if floating layout is enabled */ | ||||||
| Bool isarrange(void (*func)());		/* returns True if func is the layout function in use */ | Bool isarrange(void (*func)());		/* returns True if func is the layout function in use */ | ||||||
| void initlayouts(void);			/* initialize layout array */ | void initlayouts(void);			/* initialize layout array */ | ||||||
|  | void loaddwmprops(void);		/* loads dwm properties */ | ||||||
| Client *nexttiled(Client *c);		/* returns tiled successor of c */ | Client *nexttiled(Client *c);		/* returns tiled successor of c */ | ||||||
| void restack(void);			/* restores z layers of all clients */ | void restack(void);			/* restores z layers of all clients */ | ||||||
|  | void savedwmprops(void);		/* saves dwm properties */ | ||||||
| void setlayout(const char *arg);	/* sets layout, NULL means next layout */ | void setlayout(const char *arg);	/* sets layout, NULL means next layout */ | ||||||
| void togglebar(const char *arg);	/* shows/hides the bar */ | void togglebar(const char *arg);	/* shows/hides the bar */ | ||||||
| void togglemax(const char *arg);	/* toggles maximization of floating client */ | void togglemax(const char *arg);	/* toggles maximization of floating client */ | ||||||
|  | |||||||
							
								
								
									
										40
									
								
								layout.c
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								layout.c
									
									
									
									
									
								
							| @ -1,6 +1,9 @@ | |||||||
| /* See LICENSE file for copyright and license details. */ | /* See LICENSE file for copyright and license details. */ | ||||||
| #include "dwm.h" | #include "dwm.h" | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  | #include <string.h> | ||||||
|  | #include <X11/Xatom.h> | ||||||
|  | #include <X11/Xutil.h> | ||||||
| 
 | 
 | ||||||
| /* static */ | /* static */ | ||||||
| 
 | 
 | ||||||
| @ -10,6 +13,7 @@ typedef struct { | |||||||
| } Layout; | } Layout; | ||||||
| 
 | 
 | ||||||
| unsigned int blw = 0; | unsigned int blw = 0; | ||||||
|  | static char prop[128]; | ||||||
| static unsigned int ltidx = 0; /* default */ | static unsigned int ltidx = 0; /* default */ | ||||||
| 
 | 
 | ||||||
| static void | 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 * | Client * | ||||||
| nexttiled(Client *c) { | nexttiled(Client *c) { | ||||||
| 	for(; c && (c->isfloating || !isvisible(c)); c = c->next); | 	for(; c && (c->isfloating || !isvisible(c)); c = c->next); | ||||||
| @ -138,6 +164,19 @@ restack(void) { | |||||||
| 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 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 | void | ||||||
| setlayout(const char *arg) { | setlayout(const char *arg) { | ||||||
| 	int i; | 	int i; | ||||||
| @ -156,6 +195,7 @@ setlayout(const char *arg) { | |||||||
| 		arrange(); | 		arrange(); | ||||||
| 	else | 	else | ||||||
| 		drawstatus(); | 		drawstatus(); | ||||||
|  | 	savedwmprops(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void | void | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								main.c
									
									
									
									
									
								
							| @ -20,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah; | |||||||
| unsigned int bh, ntags; | unsigned int bh, ntags; | ||||||
| unsigned int bpos = BARPOS; | unsigned int bpos = BARPOS; | ||||||
| unsigned int numlockmask = 0; | unsigned int numlockmask = 0; | ||||||
| Atom dwmconfig, wmatom[WMLast], netatom[NetLast]; | Atom dwmprops, wmatom[WMLast], netatom[NetLast]; | ||||||
| Bool *seltags; | Bool *seltags; | ||||||
| Bool selscreen = True; | Bool selscreen = True; | ||||||
| Client *clients = NULL; | Client *clients = NULL; | ||||||
| @ -140,7 +140,7 @@ setup(void) { | |||||||
| 	XSetWindowAttributes wa; | 	XSetWindowAttributes wa; | ||||||
| 
 | 
 | ||||||
| 	/* init atoms */ | 	/* init atoms */ | ||||||
| 	dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False); | 	dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False); | ||||||
| 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); | 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); | ||||||
| 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); | 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); | ||||||
| 	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); | 	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); | ||||||
| @ -205,6 +205,7 @@ setup(void) { | |||||||
| 		XSetFont(dpy, dc.gc, dc.font.xfont->fid); | 		XSetFont(dpy, dc.gc, dc.font.xfont->fid); | ||||||
| 	/* multihead support */ | 	/* multihead support */ | ||||||
| 	selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); | 	selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); | ||||||
|  | 	loaddwmprops(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								tag.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								tag.c
									
									
									
									
									
								
							| @ -3,8 +3,6 @@ | |||||||
| #include <regex.h> | #include <regex.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> |  | ||||||
| #include <X11/Xatom.h> |  | ||||||
| #include <X11/Xutil.h> | #include <X11/Xutil.h> | ||||||
| 
 | 
 | ||||||
| /* static */ | /* static */ | ||||||
| @ -118,7 +116,7 @@ tag(const char *arg) { | |||||||
| 	i = idxoftag(arg); | 	i = idxoftag(arg); | ||||||
| 	if(i >= 0 && i < ntags) | 	if(i >= 0 && i < ntags) | ||||||
| 		sel->tags[i] = True; | 		sel->tags[i] = True; | ||||||
| 	saveconfig(sel); | 	saveprops(sel); | ||||||
| 	arrange(); | 	arrange(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -129,7 +127,7 @@ togglefloating(const char *arg) { | |||||||
| 	sel->isfloating = !sel->isfloating; | 	sel->isfloating = !sel->isfloating; | ||||||
| 	if(sel->isfloating) { | 	if(sel->isfloating) { | ||||||
| 		resize(sel, sel->x, sel->y, sel->w, sel->h, True); | 		resize(sel, sel->x, sel->y, sel->w, sel->h, True); | ||||||
| 		saveconfig(sel); | 		saveprops(sel); | ||||||
| 	} | 	} | ||||||
| 	arrange(); | 	arrange(); | ||||||
| } | } | ||||||
| @ -145,7 +143,7 @@ toggletag(const char *arg) { | |||||||
| 	for(j = 0; j < ntags && !sel->tags[j]; j++); | 	for(j = 0; j < ntags && !sel->tags[j]; j++); | ||||||
| 	if(j == ntags) | 	if(j == ntags) | ||||||
| 		sel->tags[i] = True; | 		sel->tags[i] = True; | ||||||
| 	saveconfig(sel); | 	saveprops(sel); | ||||||
| 	arrange(); | 	arrange(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -158,6 +156,7 @@ toggleview(const char *arg) { | |||||||
| 	for(j = 0; j < ntags && !seltags[j]; j++); | 	for(j = 0; j < ntags && !seltags[j]; j++); | ||||||
| 	if(j == ntags) | 	if(j == ntags) | ||||||
| 		seltags[i] = True; /* cannot toggle last view */ | 		seltags[i] = True; /* cannot toggle last view */ | ||||||
|  | 	savedwmprops(); | ||||||
| 	arrange(); | 	arrange(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -170,5 +169,6 @@ view(const char *arg) { | |||||||
| 	i = idxoftag(arg); | 	i = idxoftag(arg); | ||||||
| 	if(i >= 0 && i < ntags) | 	if(i >= 0 && i < ntags) | ||||||
| 		seltags[i] = True; | 		seltags[i] = True; | ||||||
|  | 	savedwmprops(); | ||||||
| 	arrange(); | 	arrange(); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user