From 0957fbbee2426faa00ca759ad772e650f87c745c Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 1 Jan 2013 14:19:56 +0000 Subject: [PATCH 01/15] make num of groups no longer off-by-one; from Alexander Polakov note that a re-exec of cwm will not rewrite the group number atom of *existing* clients, so they will remain off-by-one until each client has its atom updated, or of course a restart of X. --- calmwm.h | 4 +--- client.c | 2 +- group.c | 10 +++++----- kbfunc.c | 6 +++--- xutil.c | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/calmwm.h b/calmwm.h index edac516..849a803 100644 --- a/calmwm.h +++ b/calmwm.h @@ -74,8 +74,6 @@ #define CWM_MENU_DUMMY 0x0001 #define CWM_MENU_FILE 0x0002 -#define KBTOGROUP(X) ((X) - 1) - union arg { char *c; int i; @@ -222,7 +220,7 @@ struct screen_ctx { XftFont *xftfont; int xinerama_no; XineramaScreenInfo *xinerama; -#define CALMWM_NGROUPS 9 +#define CALMWM_NGROUPS 10 struct group_ctx groups[CALMWM_NGROUPS]; struct group_ctx_q groupq; int group_hideall; diff --git a/client.c b/client.c index 2bdfe28..3a20e00 100644 --- a/client.c +++ b/client.c @@ -876,7 +876,7 @@ client_transient(struct client_ctx *cc) if (XGetTransientForHint(X_Dpy, cc->win, &trans)) { if ((tc = client_find(trans)) && tc->group) { - group_movetogroup(cc, tc->group->shortcut - 1); + group_movetogroup(cc, tc->group->shortcut); if (tc->flags & CLIENT_IGNORE) cc->flags |= CLIENT_IGNORE; } diff --git a/group.c b/group.c index 847cddd..de3f6b9 100644 --- a/group.c +++ b/group.c @@ -132,7 +132,7 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc) free(winlist); gc->hidden = 0; - group_setactive(sc, gc->shortcut - 1); + group_setactive(sc, gc->shortcut); } void @@ -151,7 +151,7 @@ group_init(struct screen_ctx *sc) for (i = 0; i < CALMWM_NGROUPS; i++) { TAILQ_INIT(&sc->groups[i].clients); sc->groups[i].hidden = 0; - sc->groups[i].shortcut = i + 1; + sc->groups[i].shortcut = i; TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry); } @@ -327,7 +327,7 @@ group_cycle(struct screen_ctx *sc, int flags) if (showgroup->hidden) group_show(sc, showgroup); else - group_setactive(sc, showgroup->shortcut - 1); + group_setactive(sc, showgroup->shortcut); } /* called when a client is deleted */ @@ -420,7 +420,7 @@ group_autogroup(struct client_ctx *cc) else if (*grpno > CALMWM_NGROUPS || *grpno < 0) no = CALMWM_NGROUPS - 1; else - no = *grpno + 1; + no = *grpno; XFree(grpno); } else { TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { @@ -480,7 +480,7 @@ group_update_names(struct screen_ctx *sc) */ if (n < CALMWM_NGROUPS) { setnames = 1; - i = 1; + i = 0; while (n < CALMWM_NGROUPS) strings[n++] = xstrdup(shortcut_to_name[i++]); } diff --git a/kbfunc.c b/kbfunc.c index 452ca0a..e9181a1 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -406,13 +406,13 @@ kbfunc_client_delete(struct client_ctx *cc, union arg *arg) void kbfunc_client_group(struct client_ctx *cc, union arg *arg) { - group_hidetoggle(cc->sc, KBTOGROUP(arg->i)); + group_hidetoggle(cc->sc, arg->i); } void kbfunc_client_grouponly(struct client_ctx *cc, union arg *arg) { - group_only(cc->sc, KBTOGROUP(arg->i)); + group_only(cc->sc, arg->i); } void @@ -440,7 +440,7 @@ kbfunc_client_grouptoggle(struct client_ctx *cc, union arg *arg) void kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg) { - group_movetogroup(cc, KBTOGROUP(arg->i)); + group_movetogroup(cc, arg->i); } void diff --git a/xutil.c b/xutil.c index b910906..32a9974 100644 --- a/xutil.c +++ b/xutil.c @@ -411,7 +411,7 @@ xu_ewmh_net_wm_desktop(struct client_ctx *cc) long no = 0xffffffff; if (gc) - no = gc->shortcut - 1; + no = gc->shortcut; XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP].atom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1); From 6cb334e50375837365cea46b962a534c852df055 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 1 Jan 2013 14:26:29 +0000 Subject: [PATCH 02/15] replace emptystring with strdup here as well so we know we are free'ing a malloc'd variable everytime; from Tiago Cunha --- client.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/client.c b/client.c index 3a20e00..cb477e1 100644 --- a/client.c +++ b/client.c @@ -41,7 +41,6 @@ static void client_gethints(struct client_ctx *); static void client_freehints(struct client_ctx *); static int client_inbound(struct client_ctx *, int, int); -static char emptystring[] = ""; struct client_ctx *_curcc = NULL; struct client_ctx * @@ -166,8 +165,7 @@ client_delete(struct client_ctx *cc) while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) { TAILQ_REMOVE(&cc->nameq, wn, entry); - if (wn->name != emptystring) - free(wn->name); + free(wn->name); free(wn); } @@ -558,7 +556,7 @@ client_setname(struct client_ctx *cc) if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME].atom, &newname)) if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname)) - newname = emptystring; + newname = xstrdup(""); TAILQ_FOREACH(wn, &cc->nameq, entry) if (strcmp(wn->name, newname) == 0) { @@ -581,8 +579,7 @@ match: wn = TAILQ_FIRST(&cc->nameq); assert(wn != NULL); TAILQ_REMOVE(&cc->nameq, wn, entry); - if (wn->name != emptystring) - free(wn->name); + free(wn->name); free(wn); cc->nameqlen--; } From ccbb1f1529e539dce9b4520349407b146cd07edd Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 1 Jan 2013 14:33:52 +0000 Subject: [PATCH 03/15] least intrusive way to plug a memleak when unbinding a duplicate key for kbfunc_cmdexec; from Tiago Cunha --- calmwm.h | 3 +++ conf.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/calmwm.h b/calmwm.h index 849a803..9543341 100644 --- a/calmwm.h +++ b/calmwm.h @@ -74,6 +74,8 @@ #define CWM_MENU_DUMMY 0x0001 #define CWM_MENU_FILE 0x0002 +#define ARG_CHAR 0x0001 +#define ARG_INT 0x0002 union arg { char *c; int i; @@ -239,6 +241,7 @@ struct keybinding { int keycode; #define KBFLAG_NEEDCLIENT 0x0001 int flags; + int argtype; }; TAILQ_HEAD(keybinding_q, keybinding); diff --git a/conf.c b/conf.c index 2541f81..f583f78 100644 --- a/conf.c +++ b/conf.c @@ -470,14 +470,16 @@ conf_bindname(struct conf *c, char *name, char *binding) current_binding->callback = name_to_kbfunc[i].handler; current_binding->flags = name_to_kbfunc[i].flags; current_binding->argument = name_to_kbfunc[i].argument; + current_binding->argtype |= ARG_INT; conf_grab(c, current_binding); TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry); return; } current_binding->callback = kbfunc_cmdexec; - current_binding->argument.c = xstrdup(binding); current_binding->flags = 0; + current_binding->argument.c = xstrdup(binding); + current_binding->argtype |= ARG_CHAR; conf_grab(c, current_binding); TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry); } @@ -496,6 +498,8 @@ conf_unbind(struct conf *c, struct keybinding *unbind) key->keysym == unbind->keysym) { conf_ungrab(c, key); TAILQ_REMOVE(&c->keybindingq, key, entry); + if (key->argtype & ARG_CHAR) + free(key->argument.c); free(key); } } From afb36484404f5664f1f4533cfa97989f0af3b04c Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 1 Jan 2013 14:50:01 +0000 Subject: [PATCH 04/15] after we toggle a group hidden, it makes no sense to set it as active (in sticky or non-stick mode), regardless of existing clients assigned to that group; oga marked this bit XXX in -r1.34 for it didn't seem make sense then either. pulled from a diff from from Alexander Polakov. --- group.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/group.c b/group.c index de3f6b9..d226578 100644 --- a/group.c +++ b/group.c @@ -269,12 +269,8 @@ group_hidetoggle(struct screen_ctx *sc, int idx) if (gc->hidden) group_show(sc, gc); - else { + else group_hide(sc, gc); - /* XXX wtf? */ - if (TAILQ_EMPTY(&gc->clients)) - group_setactive(sc, idx); - } } void From 2d28b71a1b0253b4b0d58019b8c15bf4631e7914 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 2 Jan 2013 02:02:08 +0000 Subject: [PATCH 05/15] info->xine, for consistent variable names --- client.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client.c b/client.c index cb477e1..a1c7ef6 100644 --- a/client.c +++ b/client.c @@ -682,17 +682,17 @@ client_placecalc(struct client_ctx *cc) if (cc->size->y > 0) cc->geom.y = MIN(cc->size->y, yslack); } else { - XineramaScreenInfo *info; + XineramaScreenInfo *xine; int xmouse, ymouse, xorig, yorig; int xmax, ymax; xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); - info = screen_find_xinerama(sc, xmouse, ymouse); - if (info) { - xorig = info->x_org; - yorig = info->y_org; - xmax = xorig + info->width; - ymax = yorig + info->height; + xine = screen_find_xinerama(sc, xmouse, ymouse); + if (xine) { + xorig = xine->x_org; + yorig = xine->y_org; + xmax = xorig + xine->width; + ymax = yorig + xine->height; } else { xorig = yorig = 0; xmax = sc->view.w; From e492ed8e4138b3552349c314d45f2514ad3e62d5 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 2 Jan 2013 02:19:20 +0000 Subject: [PATCH 06/15] more variable consistency --- client.c | 40 ++++++++++++++++++++-------------------- menu.c | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/client.c b/client.c index a1c7ef6..fe35d94 100644 --- a/client.c +++ b/client.c @@ -255,8 +255,8 @@ void client_maximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - int x_org, y_org, xmax, ymax; XineramaScreenInfo *xine; + int x_org, y_org, xmax, ymax; if (cc->flags & CLIENT_FREEZE) return; @@ -312,8 +312,8 @@ void client_vertmaximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - int y_org, ymax; XineramaScreenInfo *xine; + int y_org, ymax; if (cc->flags & CLIENT_FREEZE) return; @@ -361,8 +361,8 @@ void client_horizmaximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - int x_org, xmax; XineramaScreenInfo *xine; + int x_org, xmax; if (cc->flags & CLIENT_FREEZE) return; @@ -683,46 +683,46 @@ client_placecalc(struct client_ctx *cc) cc->geom.y = MIN(cc->size->y, yslack); } else { XineramaScreenInfo *xine; - int xmouse, ymouse, xorig, yorig; - int xmax, ymax; + int x_org, y_org, xmax, ymax; + int xmouse, ymouse; xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); xine = screen_find_xinerama(sc, xmouse, ymouse); if (xine) { - xorig = xine->x_org; - yorig = xine->y_org; - xmax = xorig + xine->width; - ymax = yorig + xine->height; + x_org = xine->x_org; + y_org = xine->y_org; + xmax = xine->x_org + xine->width; + ymax = xine->y_org + xine->height; } else { - xorig = yorig = 0; + x_org = y_org = 0; xmax = sc->view.w; ymax = sc->view.h; } - xmouse = MAX(xmouse, xorig) - cc->geom.w / 2; - ymouse = MAX(ymouse, yorig) - cc->geom.h / 2; + xmouse = MAX(xmouse, x_org) - cc->geom.w / 2; + ymouse = MAX(ymouse, y_org) - cc->geom.h / 2; - xmouse = MAX(xmouse, xorig); - ymouse = MAX(ymouse, yorig); + xmouse = MAX(xmouse, x_org); + ymouse = MAX(ymouse, y_org); xslack = xmax - cc->geom.w - cc->bwidth * 2; yslack = ymax - cc->geom.h - cc->bwidth * 2; - if (xslack >= xorig) { + if (xslack >= x_org) { cc->geom.x = MAX(MIN(xmouse, xslack), - xorig + sc->gap.left); + x_org + sc->gap.left); if (cc->geom.x > (xslack - sc->gap.right)) cc->geom.x -= sc->gap.right; } else { - cc->geom.x = xorig + sc->gap.left; + cc->geom.x = x_org + sc->gap.left; cc->geom.w = xmax - sc->gap.left; } - if (yslack >= yorig) { + if (yslack >= y_org) { cc->geom.y = MAX(MIN(ymouse, yslack), - yorig + sc->gap.top); + y_org + sc->gap.top); if (cc->geom.y > (yslack - sc->gap.bottom)) cc->geom.y -= sc->gap.bottom; } else { - cc->geom.y = yorig + sc->gap.top; + cc->geom.y = y_org + sc->gap.top; cc->geom.h = ymax - sc->gap.top; } } diff --git a/menu.c b/menu.c index 3889d96..c5ceea9 100644 --- a/menu.c +++ b/menu.c @@ -351,7 +351,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, { struct menu *mi; XineramaScreenInfo *xine; - int xmin, xmax, ymin, ymax; + int x_org, y_org, xmax, ymax; int n, xsave, ysave; if (mc->list) { @@ -396,12 +396,12 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, xine = screen_find_xinerama(sc, mc->x, mc->y); if (xine) { - xmin = xine->x_org; + x_org = xine->x_org; + y_org = xine->y_org; xmax = xine->x_org + xine->width; - ymin = xine->y_org; ymax = xine->y_org + xine->height; } else { - xmin = ymin = 0; + x_org = y_org = 0; xmax = sc->view.w; ymax = sc->view.h; } @@ -412,15 +412,15 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, /* Never hide the top, or left side, of the menu. */ if (mc->x + mc->width >= xmax) mc->x = xmax - mc->width; - if (mc->x < xmin) { - mc->x = xmin; - mc->width = xmax - xmin; + if (mc->x < x_org) { + mc->x = x_org; + mc->width = xmax - x_org; } if (mc->y + mc->height >= ymax) mc->y = ymax - mc->height; - if (mc->y < ymin) { - mc->y = ymin; - mc->height = ymax - ymin; + if (mc->y < y_org) { + mc->y = y_org; + mc->height = ymax - y_org; } if (mc->x != xsave || mc->y != ysave) From ce8ef02ed22041e88d23c20341060b3b977906a5 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 2 Jan 2013 16:26:34 +0000 Subject: [PATCH 07/15] have screen_find_xinerama() return struct geom *reliably* instead of XineramaScreenInfo; simplifies goop around the callers. --- calmwm.h | 2 +- client.c | 90 ++++++++++++++++---------------------------------------- menu.c | 35 ++++++++-------------- screen.c | 18 ++++++++---- 4 files changed, 52 insertions(+), 93 deletions(-) diff --git a/calmwm.h b/calmwm.h index 9543341..7237e28 100644 --- a/calmwm.h +++ b/calmwm.h @@ -372,7 +372,7 @@ void search_match_text(struct menu_q *, struct menu_q *, char *); void search_print_client(struct menu *, int); -XineramaScreenInfo *screen_find_xinerama(struct screen_ctx *, int, int); +struct geom screen_find_xinerama(struct screen_ctx *, int, int); struct screen_ctx *screen_fromroot(Window); void screen_init(struct screen_ctx *, u_int); void screen_update_geometry(struct screen_ctx *); diff --git a/client.c b/client.c index fe35d94..c162dac 100644 --- a/client.c +++ b/client.c @@ -255,8 +255,7 @@ void client_maximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - XineramaScreenInfo *xine; - int x_org, y_org, xmax, ymax; + struct geom xine; if (cc->flags & CLIENT_FREEZE) return; @@ -286,21 +285,11 @@ client_maximize(struct client_ctx *cc) xine = screen_find_xinerama(sc, cc->geom.x + cc->geom.w / 2, cc->geom.y + cc->geom.h / 2); - if (xine) { - x_org = xine->x_org; - y_org = xine->y_org; - xmax = xine->width; - ymax = xine->height; - } else { - x_org = y_org = 0; - xmax = sc->view.w; - ymax = sc->view.h; - } - cc->geom.x = x_org + sc->gap.left; - cc->geom.y = y_org + sc->gap.top; - cc->geom.h = ymax - (sc->gap.top + sc->gap.bottom); - cc->geom.w = xmax - (sc->gap.left + sc->gap.right); + cc->geom.x = xine.x + sc->gap.left; + cc->geom.y = xine.y + sc->gap.top; + cc->geom.h = xine.h - (sc->gap.top + sc->gap.bottom); + cc->geom.w = xine.w - (sc->gap.left + sc->gap.right); cc->bwidth = 0; cc->flags |= CLIENT_MAXIMIZED; @@ -312,8 +301,7 @@ void client_vertmaximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - XineramaScreenInfo *xine; - int y_org, ymax; + struct geom xine; if (cc->flags & CLIENT_FREEZE) return; @@ -340,16 +328,9 @@ client_vertmaximize(struct client_ctx *cc) xine = screen_find_xinerama(sc, cc->geom.x + cc->geom.w / 2, cc->geom.y + cc->geom.h / 2); - if (xine) { - y_org = xine->y_org; - ymax = xine->height; - } else { - y_org = 0; - ymax = sc->view.h; - } - cc->geom.y = y_org + sc->gap.top; - cc->geom.h = ymax - (cc->bwidth * 2) - (sc->gap.top + + cc->geom.y = xine.y + sc->gap.top; + cc->geom.h = xine.h - (cc->bwidth * 2) - (sc->gap.top + sc->gap.bottom); cc->flags |= CLIENT_VMAXIMIZED; @@ -361,8 +342,7 @@ void client_horizmaximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - XineramaScreenInfo *xine; - int x_org, xmax; + struct geom xine; if (cc->flags & CLIENT_FREEZE) return; @@ -389,16 +369,9 @@ client_horizmaximize(struct client_ctx *cc) xine = screen_find_xinerama(sc, cc->geom.x + cc->geom.w / 2, cc->geom.y + cc->geom.h / 2); - if (xine) { - x_org = xine->x_org; - xmax = xine->width; - } else { - x_org = 0; - xmax = sc->view.w; - } - cc->geom.x = x_org + sc->gap.left; - cc->geom.w = xmax - (cc->bwidth * 2) - (sc->gap.left + + cc->geom.x = xine.x + sc->gap.left; + cc->geom.w = xine.w - (cc->bwidth * 2) - (sc->gap.left + sc->gap.right); cc->flags |= CLIENT_HMAXIMIZED; @@ -682,48 +655,37 @@ client_placecalc(struct client_ctx *cc) if (cc->size->y > 0) cc->geom.y = MIN(cc->size->y, yslack); } else { - XineramaScreenInfo *xine; - int x_org, y_org, xmax, ymax; + struct geom xine; int xmouse, ymouse; xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); xine = screen_find_xinerama(sc, xmouse, ymouse); - if (xine) { - x_org = xine->x_org; - y_org = xine->y_org; - xmax = xine->x_org + xine->width; - ymax = xine->y_org + xine->height; - } else { - x_org = y_org = 0; - xmax = sc->view.w; - ymax = sc->view.h; - } - xmouse = MAX(xmouse, x_org) - cc->geom.w / 2; - ymouse = MAX(ymouse, y_org) - cc->geom.h / 2; + xmouse = MAX(xmouse, xine.x) - cc->geom.w / 2; + ymouse = MAX(ymouse, xine.y) - cc->geom.h / 2; - xmouse = MAX(xmouse, x_org); - ymouse = MAX(ymouse, y_org); + xmouse = MAX(xmouse, xine.x); + ymouse = MAX(ymouse, xine.y); - xslack = xmax - cc->geom.w - cc->bwidth * 2; - yslack = ymax - cc->geom.h - cc->bwidth * 2; + xslack = xine.w - cc->geom.w - cc->bwidth * 2; + yslack = xine.h - cc->geom.h - cc->bwidth * 2; - if (xslack >= x_org) { + if (xslack >= xine.x) { cc->geom.x = MAX(MIN(xmouse, xslack), - x_org + sc->gap.left); + xine.x + sc->gap.left); if (cc->geom.x > (xslack - sc->gap.right)) cc->geom.x -= sc->gap.right; } else { - cc->geom.x = x_org + sc->gap.left; - cc->geom.w = xmax - sc->gap.left; + cc->geom.x = xine.x + sc->gap.left; + cc->geom.w = xine.w - sc->gap.left; } - if (yslack >= y_org) { + if (yslack >= xine.y) { cc->geom.y = MAX(MIN(ymouse, yslack), - y_org + sc->gap.top); + xine.y + sc->gap.top); if (cc->geom.y > (yslack - sc->gap.bottom)) cc->geom.y -= sc->gap.bottom; } else { - cc->geom.y = y_org + sc->gap.top; - cc->geom.h = ymax - sc->gap.top; + cc->geom.y = xine.y + sc->gap.top; + cc->geom.h = xine.h - sc->gap.top; } } } diff --git a/menu.c b/menu.c index c5ceea9..f0d8f54 100644 --- a/menu.c +++ b/menu.c @@ -350,8 +350,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) { struct menu *mi; - XineramaScreenInfo *xine; - int x_org, y_org, xmax, ymax; + struct geom xine; int n, xsave, ysave; if (mc->list) { @@ -395,32 +394,22 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, } xine = screen_find_xinerama(sc, mc->x, mc->y); - if (xine) { - x_org = xine->x_org; - y_org = xine->y_org; - xmax = xine->x_org + xine->width; - ymax = xine->y_org + xine->height; - } else { - x_org = y_org = 0; - xmax = sc->view.w; - ymax = sc->view.h; - } xsave = mc->x; ysave = mc->y; /* Never hide the top, or left side, of the menu. */ - if (mc->x + mc->width >= xmax) - mc->x = xmax - mc->width; - if (mc->x < x_org) { - mc->x = x_org; - mc->width = xmax - x_org; + if (mc->x + mc->width >= xine.w) + mc->x = xine.w - mc->width; + if (mc->x < xine.x) { + mc->x = xine.x; + mc->width = xine.w - xine.x; } - if (mc->y + mc->height >= ymax) - mc->y = ymax - mc->height; - if (mc->y < y_org) { - mc->y = y_org; - mc->height = ymax - y_org; + if (mc->y + mc->height >= xine.h) + mc->y = xine.h - mc->height; + if (mc->y < xine.y) { + mc->y = xine.y; + mc->height = xine.h - xine.y; } if (mc->x != xsave || mc->y != ysave) @@ -443,7 +432,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, int y = n * font_height(sc) + font_ascent(sc) + 1; /* Stop drawing when menu doesn't fit inside the screen. */ - if (mc->y + y > ymax) + if (mc->y + y > xine.h) break; font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY), diff --git a/screen.c b/screen.c index 461d308..a8ed509 100644 --- a/screen.c +++ b/screen.c @@ -146,22 +146,30 @@ screen_init_xinerama(struct screen_ctx *sc) /* * Find which xinerama screen the coordinates (x,y) is on. */ -XineramaScreenInfo * +struct geom screen_find_xinerama(struct screen_ctx *sc, int x, int y) { XineramaScreenInfo *info; + struct geom geom; int i; + geom = sc->view; + if (sc->xinerama == NULL) - return (NULL); + return (geom); for (i = 0; i < sc->xinerama_no; i++) { info = &sc->xinerama[i]; if (x >= info->x_org && x < info->x_org + info->width && - y >= info->y_org && y < info->y_org + info->height) - return (info); + y >= info->y_org && y < info->y_org + info->height) { + geom.x = info->x_org; + geom.y = info->y_org; + geom.w = info->width; + geom.h = info->height; + break; + } } - return (NULL); + return (geom); } void From 6e5dda99a62cb659d30cdb6a59478a042fb485ed Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 2 Jan 2013 18:11:23 +0000 Subject: [PATCH 08/15] merge in Xinerama screen query; no functional change. --- screen.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/screen.c b/screen.c index a8ed509..01c2f73 100644 --- a/screen.c +++ b/screen.c @@ -30,8 +30,6 @@ #include "calmwm.h" -static void screen_init_xinerama(struct screen_ctx *); - void screen_init(struct screen_ctx *sc, u_int which) { @@ -124,25 +122,6 @@ screen_updatestackingorder(struct screen_ctx *sc) XFree(wins); } -/* - * If we're using RandR then we'll redo this whenever the screen - * changes since a CTRC may have been added or removed - */ -void -screen_init_xinerama(struct screen_ctx *sc) -{ - XineramaScreenInfo *info = NULL; - int no = 0; - - if (XineramaIsActive(X_Dpy)) - info = XineramaQueryScreens(X_Dpy, &no); - - if (sc->xinerama != NULL) - XFree(sc->xinerama); - sc->xinerama = info; - sc->xinerama_no = no; -} - /* * Find which xinerama screen the coordinates (x,y) is on. */ @@ -175,6 +154,9 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y) void screen_update_geometry(struct screen_ctx *sc) { + XineramaScreenInfo *info = NULL; + int info_no = 0; + sc->view.x = 0; sc->view.y = 0; sc->view.w = DisplayWidth(X_Dpy, sc->which); @@ -185,7 +167,13 @@ screen_update_geometry(struct screen_ctx *sc) sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right); sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom); - screen_init_xinerama(sc); + /* RandR event may have a CTRC added or removed. */ + if (XineramaIsActive(X_Dpy)) + info = XineramaQueryScreens(X_Dpy, &info_no); + if (sc->xinerama != NULL) + XFree(sc->xinerama); + sc->xinerama = info; + sc->xinerama_no = info_no; xu_ewmh_net_desktop_geometry(sc); xu_ewmh_net_workarea(sc); From 2ac65bd2882c26dc4dddac26d1883dd140704fef Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 2 Jan 2013 21:37:21 +0000 Subject: [PATCH 09/15] re-work client_snapcalc() so it takes client and edge dimensions with snapdist; allows for simplier snap calculations. required for an upcoming diff for honoring gap. --- client.c | 14 ++++++-------- kbfunc.c | 8 ++++---- mousefunc.c | 8 ++++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/client.c b/client.c index c162dac..c76c1f4 100644 --- a/client.c +++ b/client.c @@ -850,19 +850,17 @@ client_inbound(struct client_ctx *cc, int x, int y) } int -client_snapcalc(int n, int dn, int nmax, int bwidth, int snapdist) +client_snapcalc(int n0, int n1, int e0, int e1, int snapdist) { - int n0, n1, s0, s1; + int s0, s1; s0 = s1 = 0; - n0 = n; - n1 = n + dn + (bwidth * 2); - if (abs(n0) <= snapdist) - s0 = -n0; + if (abs(e0 - n0) <= snapdist) + s0 = e0 - n0; - if (nmax - snapdist <= n1 && n1 <= nmax + snapdist) - s1 = nmax - n1; + if (abs(e1 - n1) <= snapdist) + s1 = e1 - n1; /* possible to snap in both directions */ if (s0 != 0 && s1 != 0) diff --git a/kbfunc.c b/kbfunc.c index e9181a1..6c8fef8 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -101,11 +101,11 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg) cc->geom.x = sc->view.w - 1; cc->geom.x += client_snapcalc(cc->geom.x, - cc->geom.w, sc->view.w, - cc->bwidth, Conf.snapdist); + cc->geom.x + cc->geom.w + (cc->bwidth * 2), + sc->view.x, sc->view.w, Conf.snapdist); cc->geom.y += client_snapcalc(cc->geom.y, - cc->geom.h, sc->view.h, - cc->bwidth, Conf.snapdist); + cc->geom.y + cc->geom.h + (cc->bwidth * 2), + sc->view.y, sc->view.h, Conf.snapdist); client_move(cc); xu_ptr_getpos(cc->win, &x, &y); diff --git a/mousefunc.c b/mousefunc.c index eb5171a..1b207ce 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -162,11 +162,11 @@ mousefunc_window_move(struct client_ctx *cc, void *arg) cc->geom.y = ev.xmotion.y_root - py - cc->bwidth; cc->geom.x += client_snapcalc(cc->geom.x, - cc->geom.w, sc->view.w, - cc->bwidth, Conf.snapdist); + cc->geom.x + cc->geom.w + (cc->bwidth * 2), + sc->view.x, sc->view.w, Conf.snapdist); cc->geom.y += client_snapcalc(cc->geom.y, - cc->geom.h, sc->view.h, - cc->bwidth, Conf.snapdist); + cc->geom.y + cc->geom.h + (cc->bwidth * 2), + sc->view.y, sc->view.h, Conf.snapdist); /* don't move more than 60 times / second */ if ((ev.xmotion.time - ltime) > (1000 / 60)) { From c139df129c45eab966836e622c71deec821ba370 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 2 Jan 2013 21:41:14 +0000 Subject: [PATCH 10/15] pass the screen workarea, as opposed to viewarea, allowing client snapping to honor gap. --- kbfunc.c | 4 ++-- mousefunc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kbfunc.c b/kbfunc.c index 6c8fef8..9f5ca9d 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -102,10 +102,10 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg) cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x + cc->geom.w + (cc->bwidth * 2), - sc->view.x, sc->view.w, Conf.snapdist); + sc->work.x, sc->work.w, Conf.snapdist); cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y + cc->geom.h + (cc->bwidth * 2), - sc->view.y, sc->view.h, Conf.snapdist); + sc->work.y, sc->work.h, Conf.snapdist); client_move(cc); xu_ptr_getpos(cc->win, &x, &y); diff --git a/mousefunc.c b/mousefunc.c index 1b207ce..1d2b287 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -163,10 +163,10 @@ mousefunc_window_move(struct client_ctx *cc, void *arg) cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x + cc->geom.w + (cc->bwidth * 2), - sc->view.x, sc->view.w, Conf.snapdist); + sc->work.x, sc->work.w, Conf.snapdist); cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y + cc->geom.h + (cc->bwidth * 2), - sc->view.y, sc->view.h, Conf.snapdist); + sc->work.y, sc->work.h, Conf.snapdist); /* don't move more than 60 times / second */ if ((ev.xmotion.time - ltime) > (1000 / 60)) { From 698530155d0e76265fa85c24159d58eaaea9ef31 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 4 Jan 2013 16:23:04 +0000 Subject: [PATCH 11/15] get rid of struct color --- calmwm.h | 9 ++------- client.c | 8 ++++---- conf.c | 16 ++++++++-------- parse.y | 18 +++++++++--------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/calmwm.h b/calmwm.h index 7237e28..543300e 100644 --- a/calmwm.h +++ b/calmwm.h @@ -97,11 +97,6 @@ enum cwmcolor { CWM_COLOR_MAX }; -struct color { - char *name; - unsigned long pixel; -}; - struct geom { int x; int y; @@ -211,7 +206,7 @@ struct screen_ctx { Colormap colormap; Window rootwin; Window menuwin; - struct color color[CWM_COLOR_MAX]; + unsigned long color[CWM_COLOR_MAX]; int cycling; struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ @@ -291,7 +286,7 @@ struct conf { #define CONF_SNAPDIST 0 int snapdist; struct gap gap; - struct color color[CWM_COLOR_MAX]; + char *color[CWM_COLOR_MAX]; char *menucolor[CWM_COLOR_MENU_MAX]; char termpath[MAXPATHLEN]; char lockpath[MAXPATHLEN]; diff --git a/client.c b/client.c index c76c1f4..b61b7ef 100644 --- a/client.c +++ b/client.c @@ -475,17 +475,17 @@ client_draw_border(struct client_ctx *cc) if (cc->active) switch (cc->flags & CLIENT_HIGHLIGHT) { case CLIENT_GROUP: - pixel = sc->color[CWM_COLOR_BORDER_GROUP].pixel; + pixel = sc->color[CWM_COLOR_BORDER_GROUP]; break; case CLIENT_UNGROUP: - pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel; + pixel = sc->color[CWM_COLOR_BORDER_UNGROUP]; break; default: - pixel = sc->color[CWM_COLOR_BORDER_ACTIVE].pixel; + pixel = sc->color[CWM_COLOR_BORDER_ACTIVE]; break; } else - pixel = sc->color[CWM_COLOR_BORDER_INACTIVE].pixel; + pixel = sc->color[CWM_COLOR_BORDER_INACTIVE]; XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth); XSetWindowBorder(X_Dpy, cc->win, pixel); diff --git a/conf.c b/conf.c index f583f78..b9f5bce 100644 --- a/conf.c +++ b/conf.c @@ -71,11 +71,11 @@ static char *menu_color_binds[CWM_COLOR_MENU_MAX] = { "", /* CWM_COLOR_MENU_FONT_SEL */ }; -static struct color color_binds[CWM_COLOR_MAX] = { - { "#CCCCCC", 0 }, /* CWM_COLOR_BORDER_ACTIVE */ - { "#666666", 0 }, /* CWM_COLOR_BORDER_INACTIVE */ - { "blue", 0 }, /* CWM_COLOR_BORDER_GROUP */ - { "red", 0 }, /* CWM_COLOR_BORDER_UNGROUP */ +static char *color_binds[CWM_COLOR_MAX] = { + "#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */ + "#666666", /* CWM_COLOR_BORDER_INACTIVE */ + "blue", /* CWM_COLOR_BORDER_GROUP */ + "red", /* CWM_COLOR_BORDER_UNGROUP */ }; void @@ -84,7 +84,7 @@ conf_color(struct conf *c, struct screen_ctx *sc) int i; for (i = 0; i < CWM_COLOR_MAX; i++) - sc->color[i].pixel = xu_getcolor(sc, c->color[i].name); + sc->color[i] = xu_getcolor(sc, c->color[i]); } static struct { @@ -184,7 +184,7 @@ conf_init(struct conf *c) conf_mousebind(c, m_binds[i].key, m_binds[i].func); for (i = 0; i < nitems(color_binds); i++) - c->color[i].name = xstrdup(color_binds[i].name); + c->color[i] = xstrdup(color_binds[i]); for (i = 0; i < nitems(menu_color_binds); i++) c->menucolor[i] = xstrdup(menu_color_binds[i]); @@ -237,7 +237,7 @@ conf_clear(struct conf *c) } for (i = 0; i < CWM_COLOR_MAX; i++) - free(c->color[i].name); + free(c->color[i]); free(c->font); } diff --git a/parse.y b/parse.y index 4f00198..fe8ddb2 100644 --- a/parse.y +++ b/parse.y @@ -171,20 +171,20 @@ color : COLOR colors ; colors : ACTIVEBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_ACTIVE].name); - conf->color[CWM_COLOR_BORDER_ACTIVE].name = $2; + free(conf->color[CWM_COLOR_BORDER_ACTIVE]); + conf->color[CWM_COLOR_BORDER_ACTIVE] = $2; } | INACTIVEBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_INACTIVE].name); - conf->color[CWM_COLOR_BORDER_INACTIVE].name = $2; + free(conf->color[CWM_COLOR_BORDER_INACTIVE]); + conf->color[CWM_COLOR_BORDER_INACTIVE] = $2; } | GROUPBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_GROUP].name); - conf->color[CWM_COLOR_BORDER_GROUP].name = $2; + free(conf->color[CWM_COLOR_BORDER_GROUP]); + conf->color[CWM_COLOR_BORDER_GROUP] = $2; } | UNGROUPBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_UNGROUP].name); - conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2; + free(conf->color[CWM_COLOR_BORDER_UNGROUP]); + conf->color[CWM_COLOR_BORDER_UNGROUP] = $2; } | MENUBG STRING { free(conf->menucolor[CWM_COLOR_MENU_BG]); @@ -579,7 +579,7 @@ parse_config(const char *filename, struct conf *xconf) sizeof(xconf->lockpath)); for (i = 0; i < CWM_COLOR_MAX; i++) - xconf->color[i].name = conf->color[i].name; + xconf->color[i] = conf->color[i]; for (i = 0; i < CWM_COLOR_MENU_MAX; i++) xconf->menucolor[i] = conf->menucolor[i]; From 96adffcd9d0187285f2236b2fd9f5646d21ee72a Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 4 Jan 2013 16:23:51 +0000 Subject: [PATCH 12/15] spacing --- conf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/conf.c b/conf.c index b9f5bce..808a5c1 100644 --- a/conf.c +++ b/conf.c @@ -65,17 +65,17 @@ conf_font(struct conf *c, struct screen_ctx *sc) } static char *menu_color_binds[CWM_COLOR_MENU_MAX] = { - "black", /* CWM_COLOR_MENU_FG */ - "white", /* CWM_COLOR_MENU_BG */ - "black", /* CWM_COLOR_MENU_FONT */ - "", /* CWM_COLOR_MENU_FONT_SEL */ + "black", /* CWM_COLOR_MENU_FG */ + "white", /* CWM_COLOR_MENU_BG */ + "black", /* CWM_COLOR_MENU_FONT */ + "", /* CWM_COLOR_MENU_FONT_SEL */ }; static char *color_binds[CWM_COLOR_MAX] = { - "#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */ - "#666666", /* CWM_COLOR_BORDER_INACTIVE */ - "blue", /* CWM_COLOR_BORDER_GROUP */ - "red", /* CWM_COLOR_BORDER_UNGROUP */ + "#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */ + "#666666", /* CWM_COLOR_BORDER_INACTIVE */ + "blue", /* CWM_COLOR_BORDER_GROUP */ + "red", /* CWM_COLOR_BORDER_UNGROUP */ }; void From 579f981718c9444630afc34f8ab5dfe6e983427a Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 4 Jan 2013 16:27:58 +0000 Subject: [PATCH 13/15] really these are just border colors, so adjust the define --- calmwm.h | 8 ++++---- conf.c | 6 +++--- parse.y | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/calmwm.h b/calmwm.h index 543300e..ab49afc 100644 --- a/calmwm.h +++ b/calmwm.h @@ -89,12 +89,12 @@ enum menucolor { CWM_COLOR_MENU_MAX }; -enum cwmcolor { +enum bordercolor { CWM_COLOR_BORDER_ACTIVE, CWM_COLOR_BORDER_INACTIVE, CWM_COLOR_BORDER_GROUP, CWM_COLOR_BORDER_UNGROUP, - CWM_COLOR_MAX + CWM_COLOR_BORDER_MAX }; struct geom { @@ -206,7 +206,7 @@ struct screen_ctx { Colormap colormap; Window rootwin; Window menuwin; - unsigned long color[CWM_COLOR_MAX]; + unsigned long color[CWM_COLOR_BORDER_MAX]; int cycling; struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ @@ -286,7 +286,7 @@ struct conf { #define CONF_SNAPDIST 0 int snapdist; struct gap gap; - char *color[CWM_COLOR_MAX]; + char *color[CWM_COLOR_BORDER_MAX]; char *menucolor[CWM_COLOR_MENU_MAX]; char termpath[MAXPATHLEN]; char lockpath[MAXPATHLEN]; diff --git a/conf.c b/conf.c index 808a5c1..6ef9375 100644 --- a/conf.c +++ b/conf.c @@ -71,7 +71,7 @@ static char *menu_color_binds[CWM_COLOR_MENU_MAX] = { "", /* CWM_COLOR_MENU_FONT_SEL */ }; -static char *color_binds[CWM_COLOR_MAX] = { +static char *color_binds[CWM_COLOR_BORDER_MAX] = { "#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */ "#666666", /* CWM_COLOR_BORDER_INACTIVE */ "blue", /* CWM_COLOR_BORDER_GROUP */ @@ -83,7 +83,7 @@ conf_color(struct conf *c, struct screen_ctx *sc) { int i; - for (i = 0; i < CWM_COLOR_MAX; i++) + for (i = 0; i < CWM_COLOR_BORDER_MAX; i++) sc->color[i] = xu_getcolor(sc, c->color[i]); } @@ -236,7 +236,7 @@ conf_clear(struct conf *c) free(mb); } - for (i = 0; i < CWM_COLOR_MAX; i++) + for (i = 0; i < CWM_COLOR_BORDER_MAX; i++) free(c->color[i]); free(c->font); diff --git a/parse.y b/parse.y index fe8ddb2..8173fe0 100644 --- a/parse.y +++ b/parse.y @@ -578,7 +578,7 @@ parse_config(const char *filename, struct conf *xconf) (void)strlcpy(xconf->lockpath, conf->lockpath, sizeof(xconf->lockpath)); - for (i = 0; i < CWM_COLOR_MAX; i++) + for (i = 0; i < CWM_COLOR_BORDER_MAX; i++) xconf->color[i] = conf->color[i]; for (i = 0; i < CWM_COLOR_MENU_MAX; i++) From 6d123cd96d889cbff140e5ed0d897462d9fec3d4 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 4 Jan 2013 16:30:03 +0000 Subject: [PATCH 14/15] rename {h,v}max functions for consistency; from Jan Stary --- calmwm.h | 4 ++-- client.c | 4 ++-- kbfunc.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/calmwm.h b/calmwm.h index ab49afc..47f60e7 100644 --- a/calmwm.h +++ b/calmwm.h @@ -320,7 +320,7 @@ struct client_ctx *client_find(Window); void client_freeze(struct client_ctx *); void client_getsizehints(struct client_ctx *); void client_hide(struct client_ctx *); -void client_horizmaximize(struct client_ctx *); +void client_hmaximize(struct client_ctx *); void client_leave(struct client_ctx *); void client_lower(struct client_ctx *); void client_map(struct client_ctx *); @@ -337,7 +337,7 @@ void client_setname(struct client_ctx *); int client_snapcalc(int, int, int, int, int); void client_transient(struct client_ctx *); void client_unhide(struct client_ctx *); -void client_vertmaximize(struct client_ctx *); +void client_vmaximize(struct client_ctx *); void client_warp(struct client_ctx *); void group_alltoggle(struct screen_ctx *); diff --git a/client.c b/client.c index b61b7ef..ad45aea 100644 --- a/client.c +++ b/client.c @@ -298,7 +298,7 @@ resize: } void -client_vertmaximize(struct client_ctx *cc) +client_vmaximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; struct geom xine; @@ -339,7 +339,7 @@ resize: } void -client_horizmaximize(struct client_ctx *cc) +client_hmaximize(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; struct geom xine; diff --git a/kbfunc.c b/kbfunc.c index 9f5ca9d..d61193f 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -452,13 +452,13 @@ kbfunc_client_maximize(struct client_ctx *cc, union arg *arg) void kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg) { - client_vertmaximize(cc); + client_vmaximize(cc); } void kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg) { - client_horizmaximize(cc); + client_hmaximize(cc); } void From c426254da5ff69102284524ddc560cfb00c73204 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 6 Jan 2013 01:01:26 +0000 Subject: [PATCH 15/15] use cc->bwidth in client_vmax since we've yet to reset it (matches client_hmax); from Jan Stary --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.c b/client.c index ad45aea..530a077 100644 --- a/client.c +++ b/client.c @@ -321,7 +321,7 @@ client_vmaximize(struct client_ctx *cc) /* if this will make us fully maximized then remove boundary */ if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) { - cc->geom.w += Conf.bwidth * 2; + cc->geom.w += cc->bwidth * 2; cc->bwidth = 0; }