- allow per-screen gap; not (yet) user configurable.

- teach _NET_WORKAREA about gap.

ok oga@
This commit is contained in:
okan 2010-01-27 03:04:50 +00:00
parent ccb207a8a8
commit e88bda0df5
6 changed files with 47 additions and 32 deletions

View File

@ -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));

View File

@ -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 *);

View File

@ -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;
}
}
}

7
conf.c
View File

@ -60,6 +60,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)
{
@ -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);
}

11
parse.y
View File

@ -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);

View File

@ -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,