From c21d56e5a1c98eacb70f3197311232731ccf1a6f Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 23 Oct 2012 15:32:38 +0000 Subject: [PATCH 1/6] Stop drawing when menu doesn't fit inside the screen; picked from a larger diff from Alexander Polakov. --- menu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/menu.c b/menu.c index 29008e6..4090921 100644 --- a/menu.c +++ b/menu.c @@ -387,9 +387,14 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, TAILQ_FOREACH(mi, resultq, resultentry) { char *text = mi->print[0] != '\0' ? mi->print : mi->text; + 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) + break; font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY), - sc->menuwin, 0, n * font_height(sc) + font_ascent(sc) + 1); + sc->menuwin, 0, y); n++; } From 637c52abf81512406d0f157357d961e72628f1da Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 23 Oct 2012 15:50:15 +0000 Subject: [PATCH 2/6] treat menu width the same as the height is treated when deciding its max size and location; partially from a diff from Alexander Polakov. --- menu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/menu.c b/menu.c index 4090921..7a64cb2 100644 --- a/menu.c +++ b/menu.c @@ -358,10 +358,12 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, xsave = mc->x; ysave = mc->y; - if (mc->x < xmin) - mc->x = xmin; - else if (mc->x + mc->width >= xmax) + if (mc->x + mc->width >= xmax) mc->x = xmax - mc->width; + if (mc->x < xmin) { + mc->x = xmin; + mc->width = xmax - xmin; + } if (mc->y + dy >= ymax) mc->y = ymax - dy; From 710347df1b5545daf215a24699540e7940ba6fa7 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 23 Oct 2012 16:08:59 +0000 Subject: [PATCH 3/6] add a height to struct menu and use it in the most obvious of places. --- menu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/menu.c b/menu.c index 7a64cb2..b3ac7ec 100644 --- a/menu.c +++ b/menu.c @@ -51,6 +51,7 @@ struct menu_ctx { int noresult; int prev; int entry; + int height; int width; int num; int x; @@ -301,7 +302,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 n, dy, xsave, ysave; + int n, xsave, ysave; if (mc->list) { if (TAILQ_EMPTY(resultq) && mc->list) { @@ -317,12 +318,12 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->num = 0; mc->width = 0; - dy = 0; + mc->height = 0; if (mc->hasprompt) { (void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s", mc->promptstr, mc->searchstr, PROMPT_ECHAR); mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr)); - dy = font_height(sc); + mc->height = font_height(sc); mc->num = 1; } @@ -339,7 +340,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->width = MAX(mc->width, font_width(sc, text, MIN(strlen(text), MENU_MAXENTRY))); - dy += font_height(sc); + mc->height += font_height(sc); mc->num++; } @@ -365,19 +366,20 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->width = xmax - xmin; } - if (mc->y + dy >= ymax) - mc->y = ymax - dy; + if (mc->y + mc->height >= ymax) + mc->y = ymax - mc->height; /* never hide the top of the menu */ if (mc->y < ymin) { mc->y = ymin; - dy = ymax - ymin; + mc->height = ymax - ymin; } if (mc->x != xsave || mc->y != ysave) xu_ptr_setpos(sc->rootwin, mc->x, mc->y); XClearWindow(X_Dpy, sc->menuwin); - XMoveResizeWindow(X_Dpy, sc->menuwin, mc->x, mc->y, mc->width, dy); + XMoveResizeWindow(X_Dpy, sc->menuwin, mc->x, mc->y, + mc->width, mc->height); if (mc->hasprompt) { font_draw(sc, mc->dispstr, strlen(mc->dispstr), sc->menuwin, From 742bcec5222c199913a651f29b0b8d5238cfc7de Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 23 Oct 2012 16:13:59 +0000 Subject: [PATCH 4/6] comment what this whole bit does, not just part of it. --- menu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/menu.c b/menu.c index b3ac7ec..7b6e0dc 100644 --- a/menu.c +++ b/menu.c @@ -359,16 +359,15 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, 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 < xmin) { mc->x = xmin; mc->width = xmax - xmin; } - if (mc->y + mc->height >= ymax) mc->y = ymax - mc->height; - /* never hide the top of the menu */ if (mc->y < ymin) { mc->y = ymin; mc->height = ymax - ymin; From 56358be75520d6b631da07590b4a034d850062c6 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 28 Oct 2012 20:13:02 +0000 Subject: [PATCH 5/6] clarify autogroup option; based on diffs from kspillner@acm.org with feedback from jmc --- cwmrc.5 | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/cwmrc.5 b/cwmrc.5 index e09e35b..bc4311f 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 6 2011 $ +.Dd $Mdocdate: July 6 2012 $ .Dt CWMRC 5 .Os .Sh NAME @@ -39,18 +39,26 @@ Arguments containing whitespace should be surrounded by double quotes The following options are accepted: .Pp .Bl -tag -width Ds -compact -.It Ic autogroup Ar group windowname +.It Ic autogroup Ar group windowclass .It Ic autogroup Ar group windowname,windowclass -Control automatic window grouping, based on the name and/or class -properties, where +Automatically add new windows to +.Ar group +if their class property matches +.Ar windowclass , +or if their name and class properties match +.Ar windowname +and +.Ar windowclass , +respectively. .Ar group is a number between 0 and 9. -If the group number is 0, then the window will not be grouped; this to -allow for -.Dq sticky -windows in sticky group mode. +If +.Ar group +is 0, matching windows will not be added to any group; this may be +used to override +.Dq sticky group mode . .Pp -The name and class of a window may be obtained using +The name and class values for existing windows may be obtained using .Xr xprop 1 . .Pp .It Ic bind Ar keys command From c256052308d9135454b91fa16ba7aaef97923b4b Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 29 Oct 2012 19:46:03 +0000 Subject: [PATCH 6/6] on reload, run each client through conf_client to pick up potential ignore and bwidth changes; also add a hack for existing maximized windows so they don't inherit a new bwidth. based on a diff from, and discussion with, Tiago Cunha. --- conf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 8812c4f..8b26a0a 100644 --- a/conf.c +++ b/conf.c @@ -104,8 +104,13 @@ conf_reload(struct conf *c) conf_font(c, sc); menu_init(sc); } - TAILQ_FOREACH(cc, &Clientq, entry) + TAILQ_FOREACH(cc, &Clientq, entry) { + conf_client(cc); + /* XXX Does not take hmax/vmax into account. */ + if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) + cc->bwidth = 0; client_draw_border(cc); + } } static struct {