diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2013-05-02 20:18:36 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2013-05-02 20:18:36 +0000 |
commit | b461ef67e2ae52bae82057ccd2a46af048612b8a (patch) | |
tree | 279757b33148119e8fe6aba472f6348e5e3082b2 /app | |
parent | f7b6ee723339bcf16a5fc61f2100aaf3b60d4533 (diff) |
- no need to position and size the menu window before an Expose event
since we'll be calculating required size later anyway; allows us to
consolidate all prompt/display/search string building goop into
menu_draw.
- reset the pos/size of menuwin when leaving a menu.
- reverse the 'prompt' NULL check to be consistent with 'initial' one
and fix a whitespace nit while here.
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/menu.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/app/cwm/menu.c b/app/cwm/menu.c index 5d908af8b..ecde9722c 100644 --- a/app/cwm/menu.c +++ b/app/cwm/menu.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: menu.c,v 1.56 2013/05/02 19:41:52 okan Exp $ + * $OpenBSD: menu.c,v 1.57 2013/05/02 20:18:35 okan Exp $ */ #include <sys/param.h> @@ -42,7 +42,7 @@ enum ctltype { }; struct menu_ctx { - struct screen_ctx *sc; + struct screen_ctx *sc; char searchstr[MENU_MAXENTRY + 1]; char dispstr[MENU_MAXENTRY*2 + 1]; char promptstr[MENU_MAXENTRY + 1]; @@ -112,21 +112,14 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, mc.sc = sc; mc.flags = flags; - if (prompt == NULL) { + if (prompt != NULL) { + evmask = MENUMASK | KEYMASK; /* accept keys as well */ + (void)strlcpy(mc.promptstr, prompt, sizeof(mc.promptstr)); + mc.hasprompt = 1; + } else { evmask = MENUMASK; - mc.promptstr[0] = '\0'; mc.list = 1; - } else { - evmask = MENUMASK | KEYMASK; /* only accept keys if prompt */ - (void)snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%s", - prompt, PROMPT_SCHAR); - (void)snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%s", - mc.promptstr, mc.searchstr, PROMPT_ECHAR); - mc.width = font_width(sc->xftfont, mc.dispstr, - strlen(mc.dispstr)); - mc.hasprompt = 1; } - mc.height = sc->xftfont->height + 1; if (initial != NULL) (void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr)); @@ -137,7 +130,6 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, mc.print = print; mc.entry = mc.prev = -1; - XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width, mc.height); XSelectInput(X_Dpy, sc->menuwin, evmask); XMapRaised(X_Dpy, sc->menuwin); @@ -193,6 +185,7 @@ out: xu_ptr_setpos(sc->rootwin, xsave, ysave); xu_ptr_ungrab(); + XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, 1, 1); XUnmapWindow(X_Dpy, sc->menuwin); XUngrabKeyboard(X_Dpy, CurrentTime); @@ -372,8 +365,8 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->width = 0; mc->height = 0; if (mc->hasprompt) { - (void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s", - mc->promptstr, mc->searchstr, PROMPT_ECHAR); + (void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s%s", + mc->promptstr, PROMPT_SCHAR, mc->searchstr, PROMPT_ECHAR); mc->width = font_width(sc->xftfont, mc->dispstr, strlen(mc->dispstr)); mc->height = sc->xftfont->height + 1; |