diff options
-rw-r--r-- | calmwm.c | 1 | ||||
-rw-r--r-- | calmwm.h | 10 | ||||
-rw-r--r-- | client.c | 40 | ||||
-rw-r--r-- | conf.c | 7 | ||||
-rw-r--r-- | parse.y | 11 | ||||
-rw-r--r-- | screen.c | 10 |
6 files changed, 47 insertions, 32 deletions
diff --git a/calmwm.c b/calmwm.c index d28dde5..2b4fdd9 100644 --- a/calmwm.c +++ b/calmwm.c @@ -159,6 +159,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which) sc->which = which; sc->rootwin = RootWindow(X_Dpy, sc->which); + conf_gap(&Conf, sc); screen_update_geometry(sc, DisplayWidth(X_Dpy, sc->which), DisplayHeight(X_Dpy, sc->which)); diff --git a/calmwm.h b/calmwm.h index 7ce92a7..0f82243 100644 --- a/calmwm.h +++ b/calmwm.h @@ -65,6 +65,12 @@ struct color { unsigned long pixel; char *name; }; +struct gap { + int top; + int bottom; + int left; + int right; +}; struct client_ctx; @@ -97,6 +103,7 @@ struct screen_ctx { int xmax; int ymax; + struct gap gap; struct cycle_entry_q mruq; XftDraw *xftdraw; @@ -284,6 +291,7 @@ struct conf { int bwidth; #define CONF_MAMOUNT 1 int mamount; + struct gap gap; #define CONF_COLOR_ACTIVEBORDER "#CCCCCC" #define CONF_COLOR_INACTIVEBORDER "#666666" @@ -298,7 +306,6 @@ struct conf { #define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold" char *DefaultFontName; - int gap_top, gap_bottom, gap_left, gap_right; }; /* Menu stuff */ @@ -423,6 +430,7 @@ void conf_bindname(struct conf *, char *, char *); void conf_mousebind(struct conf *, char *, char *); void conf_grab_mouse(struct client_ctx *); void conf_reload(struct conf *); +void conf_gap(struct conf *, struct screen_ctx *); void conf_font(struct conf *, struct screen_ctx *); void conf_color(struct conf *, struct screen_ctx *); void conf_init(struct conf *); diff --git a/client.c b/client.c index 2818890..7c569b7 100644 --- a/client.c +++ b/client.c @@ -294,10 +294,10 @@ client_maximize(struct client_ctx *cc) ymax = xine->height; } calc: - cc->geom.x = x_org + Conf.gap_left; - cc->geom.y = y_org + Conf.gap_top; - cc->geom.height = ymax - (Conf.gap_top + Conf.gap_bottom); - cc->geom.width = xmax - (Conf.gap_left + Conf.gap_right); + cc->geom.x = x_org + sc->gap.left; + cc->geom.y = y_org + sc->gap.top; + cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom); + cc->geom.width = xmax - (sc->gap.left + sc->gap.right); cc->flags |= CLIENT_DOMAXIMIZE; } @@ -326,9 +326,9 @@ client_vertmaximize(struct client_ctx *cc) ymax = xine->height; } calc: - cc->geom.y = y_org + Conf.gap_top; - cc->geom.height = ymax - (cc->bwidth * 2) - (Conf.gap_top + - Conf.gap_bottom); + cc->geom.y = y_org + sc->gap.top; + cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top + + sc->gap.bottom); cc->flags |= CLIENT_DOVMAXIMIZE; } @@ -357,9 +357,9 @@ client_horizmaximize(struct client_ctx *cc) xmax = xine->width; } calc: - cc->geom.x = x_org + Conf.gap_left; - cc->geom.width = xmax - (cc->bwidth * 2) - (Conf.gap_left + - Conf.gap_right); + cc->geom.x = x_org + sc->gap.left; + cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left + + sc->gap.right); cc->flags |= CLIENT_DOHMAXIMIZE; } @@ -672,21 +672,21 @@ noxine: if (xslack >= xorig) { cc->geom.x = MAX(MIN(xmouse, xslack), - xorig + Conf.gap_left); - if (cc->geom.x > (xslack - Conf.gap_right)) - cc->geom.x -= Conf.gap_right; + xorig + sc->gap.left); + if (cc->geom.x > (xslack - sc->gap.right)) + cc->geom.x -= sc->gap.right; } else { - cc->geom.x = xorig + Conf.gap_left; - cc->geom.width = xmax - Conf.gap_left; + cc->geom.x = xorig + sc->gap.left; + cc->geom.width = xmax - sc->gap.left; } if (yslack >= yorig) { cc->geom.y = MAX(MIN(ymouse, yslack), - yorig + Conf.gap_top); - if (cc->geom.y > (yslack - Conf.gap_bottom)) - cc->geom.y -= Conf.gap_bottom; + yorig + sc->gap.top); + if (cc->geom.y > (yslack - sc->gap.bottom)) + cc->geom.y -= sc->gap.bottom; } else { - cc->geom.y = yorig + Conf.gap_top; - cc->geom.height = ymax - Conf.gap_top; + cc->geom.y = yorig + sc->gap.top; + cc->geom.height = ymax - sc->gap.top; } } } diff --git a/conf.c b/conf.c index 0764a4a..10135a6 100644 --- a/conf.c +++ b/conf.c @@ -61,6 +61,12 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags) } void +conf_gap(struct conf *c, struct screen_ctx *sc) +{ + sc->gap = c->gap; +} + +void conf_font(struct conf *c, struct screen_ctx *sc) { sc->font = font_make(sc, c->DefaultFontName); @@ -92,6 +98,7 @@ conf_reload(struct conf *c) TAILQ_FOREACH(cc, &Clientq, entry) client_draw_border(cc); TAILQ_FOREACH(sc, &Screenq, entry) { + conf_gap(c, sc); conf_color(c, sc); conf_font(c, sc); } diff --git a/parse.y b/parse.y index 9d049c9..20b1d8b 100644 --- a/parse.y +++ b/parse.y @@ -150,10 +150,10 @@ main : FONTNAME STRING { free($3); } | GAP NUMBER NUMBER NUMBER NUMBER { - conf->gap_top = $2; - conf->gap_bottom = $3; - conf->gap_left = $4; - conf->gap_right = $5; + conf->gap.top = $2; + conf->gap.bottom = $3; + conf->gap.left = $4; + conf->gap.right = $5; } | MOUSEBIND STRING string { conf_mousebind(conf, $2, $3); @@ -522,6 +522,7 @@ parse_config(const char *filename, struct conf *xconf) xconf->flags = conf->flags; xconf->bwidth = conf->bwidth; xconf->mamount = conf->mamount; + xconf->gap = conf->gap; while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) { TAILQ_REMOVE(&conf->cmdq, cmd, entry); @@ -557,8 +558,6 @@ parse_config(const char *filename, struct conf *xconf) xconf->color[i].name = conf->color[i].name; xconf->DefaultFontName = conf->DefaultFontName; - - bcopy(&(conf->gap_top), &(xconf->gap_top), sizeof(int) * 4); } free(conf); diff --git a/screen.c b/screen.c index 0998b92..a58ece4 100644 --- a/screen.c +++ b/screen.c @@ -119,12 +119,12 @@ screen_update_geometry(struct screen_ctx *sc, int width, int height) XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)geom , 2); - /* x, y, width, height. XXX gap */ + /* x, y, width, height. */ for (i = 0; i < CALMWM_NGROUPS; i++) { - workareas[i][0] = 0; - workareas[i][1] = 0; - workareas[i][2] = width; - workareas[i][3] = height; + workareas[i][0] = sc->gap.left; + workareas[i][1] = sc->gap.top; + workareas[i][2] = width - (sc->gap.left + sc->gap.right); + workareas[i][3] = height - (sc->gap.top + sc->gap.bottom); } XChangeProperty(X_Dpy, sc->rootwin, _NET_WORKAREA, |