summary refs log tree commit diff
diff options
context:
space:
mode:
authoroga <oga>2008-04-15 18:46:58 +0000
committeroga <oga>2008-04-15 18:46:58 +0000
commit3a94c57afc6067c60b639944ef2042b0d73fb47e (patch)
tree803a2c9146119a6e3971f98e93b4df41dfa6e740
parent4bbb472a25c62b8266de2225c5f98b96ab829e1c (diff)
downloadcwm-3a94c57afc6067c60b639944ef2042b0d73fb47e.tar.gz
cwm-3a94c57afc6067c60b639944ef2042b0d73fb47e.tar.xz
cwm-3a94c57afc6067c60b639944ef2042b0d73fb47e.zip
Add "gap" support to .cwmrc. The options put in here make gaps on the edge
of the screen where an application won't be {,vert}maximized over. used for
placing a statusbar or something like xclock.

Patch from Edd Barrett, with input from myself and okan. Thanks!

ok okan@.
-rw-r--r--calmwm.h1
-rw-r--r--client.c19
-rw-r--r--cwmrc.512
-rw-r--r--parse.y12
4 files changed, 31 insertions, 13 deletions
diff --git a/calmwm.h b/calmwm.h
index 4114c44..d7955a6 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -274,6 +274,7 @@ struct conf {
 
 #define	DEFAULTFONTNAME		"sans-serif:pixelsize=14:bold"
 	char			*DefaultFontName;
+	int			gap_top, gap_bottom, gap_left, gap_right;
 };
 
 /* Menu stuff */
diff --git a/client.c b/client.c
index 6691c6b..7b56e23 100644
--- a/client.c
+++ b/client.c
@@ -339,10 +339,12 @@ client_maximize(struct client_ctx *cc)
 		XGetWindowAttributes(X_Dpy, sc->rootwin, &rootwin_geom);
 		if (!(cc->flags & CLIENT_VMAXIMIZED))
 			cc->savegeom = cc->geom;
-		cc->geom.x = 0;
-		cc->geom.y = 0;
-		cc->geom.height = rootwin_geom.height;
-		cc->geom.width = rootwin_geom.width;
+		cc->geom.x = Conf.gap_left;
+		cc->geom.y = Conf.gap_top;
+		cc->geom.height = rootwin_geom.height -
+			(Conf.gap_top + Conf.gap_bottom);
+		cc->geom.width = rootwin_geom.width -
+			(Conf.gap_left + Conf.gap_right);
 		cc->flags |= CLIENT_DOMAXIMIZE;
 	}
 
@@ -765,12 +767,9 @@ client_vertmaximize(struct client_ctx *cc)
         
 		if (!(cc->flags & CLIENT_MAXIMIZED)) 
 			cc->savegeom = cc->geom;
-		cc->geom.y = cc->bwidth;
-		if (cc->geom.min_dx == 0)
-			cc->geom.height = display_height; 
-		else
-			cc->geom.height = display_height -
-			    (display_height % cc->geom.min_dx);
+		cc->geom.y = cc->bwidth + Conf.gap_top;
+		cc->geom.height = display_height -
+			(Conf.gap_top + Conf.gap_bottom); 
 		cc->flags |= CLIENT_DOVMAXIMIZE;
 	}
 
diff --git a/cwmrc.5 b/cwmrc.5
index 5695057..f744e65 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -15,7 +15,7 @@
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
 .\" The following requests are required for all man pages.
-.Dd $Mdocdate$
+.Dd $Mdocdate: March 23 2008 $
 .Dt CWMRC 1
 .Os
 .Sh NAME
@@ -138,6 +138,16 @@ Remove a keybinding for Mod4-o
 .Bd -literal -offset indent
 bind 4-o "unmap"
 .Ed
+.It Ic gap Ar top bottom left right
+Define "gaps" at the edge of the screen, so that when a window is maximized it will not overlap this area.
+This gap can be used for other applications such as
+.Xr xclock 1 ,
+which the user may wish to remain visible.
+.Pp
+.Pa top bottom left
+and
+.Pa right
+are the sizes of each the gap in pixels.
 .El
 .Sh SEE ALSO
 .Xr cwm 1
diff --git a/parse.y b/parse.y
index 7322bbe..fbe13ba 100644
--- a/parse.y
+++ b/parse.y
@@ -65,7 +65,7 @@ typedef struct {
 
 %}
 
-%token	FONTNAME STICKY
+%token	FONTNAME STICKY GAP
 %token	AUTOGROUP BIND COMMAND IGNORE
 %token	YES NO
 %token	ERROR
@@ -161,8 +161,13 @@ main		: FONTNAME STRING		{
 			free($2);
 			free($3);
 		}
+		| GAP NUMBER NUMBER NUMBER NUMBER {
+			conf->gap_top = $2;
+			conf->gap_bottom = $3;
+			conf->gap_left = $4;
+			conf->gap_right = $5;
+		}
 		;
-
 %%
 
 struct keywords {
@@ -199,6 +204,7 @@ lookup(char *s)
 		{ "bind",		BIND},
 		{ "command",		COMMAND},
 		{ "fontname",		FONTNAME},
+		{ "gap",		GAP},
 		{ "ignore",		IGNORE},
 		{ "no",			NO},
 		{ "sticky",		STICKY},
@@ -574,6 +580,8 @@ parse_config(const char *filename, struct conf *xconf)
 		strlcpy(xconf->lockpath, conf->lockpath, sizeof(xconf->lockpath));
 
 		xconf->DefaultFontName = conf->DefaultFontName;
+
+		bcopy(&(conf->gap_top), &(xconf->gap_top), sizeof(int) * 4);
 	}
 
 	free(conf);