From 137723ad08c9062a346b29d72b4b2ce55971c217 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 | 3 ++- client.c | 21 ++++++++++----------- cwmrc.5 | 14 ++++++++++++-- parse.y | 14 +++++++++++--- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/calmwm.h b/calmwm.h index 3c7b21a..bae2362 100644 --- a/calmwm.h +++ b/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.28 2008/04/09 18:10:47 okan Exp $ + * $Id: calmwm.h,v 1.29 2008/04/15 18:46:58 oga Exp $ */ #ifndef _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 264d025..678e6b7 100644 --- a/client.c +++ b/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.15 2008/04/09 18:10:47 okan Exp $ + * $Id: client.c,v 1.16 2008/04/15 18:46:58 oga Exp $ */ #include "headers.h" @@ -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 fa22213..219175f 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.1 2008/03/23 15:09:21 simon Exp $ +.\" $OpenBSD: cwmrc.5,v 1.2 2008/04/15 18:46:58 oga Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -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: March 23 2008 $ +.Dd $Mdocdate: April 15 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 b40e5cd..947d09c 100644 --- a/parse.y +++ b/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.2 2008/04/15 18:22:08 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.3 2008/04/15 18:46:58 oga Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -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 v1.2.3-2-gb3c3