From 3a94c57afc6067c60b639944ef2042b0d73fb47e Mon Sep 17 00:00:00 2001 From: oga Date: Tue, 15 Apr 2008 18:46:58 +0000 Subject: 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@. --- calmwm.h | 1 + client.c | 19 +++++++++---------- cwmrc.5 | 12 +++++++++++- parse.y | 12 ++++++++++-- 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); -- cgit 1.4.1