- 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.
This commit is contained in:
parent
c3f5c37243
commit
72e88bc952
@ -16,7 +16,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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>
|
#include <sys/param.h>
|
||||||
@ -112,21 +112,14 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
|||||||
|
|
||||||
mc.sc = sc;
|
mc.sc = sc;
|
||||||
mc.flags = flags;
|
mc.flags = flags;
|
||||||
if (prompt == NULL) {
|
if (prompt != NULL) {
|
||||||
evmask = MENUMASK;
|
evmask = MENUMASK | KEYMASK; /* accept keys as well */
|
||||||
mc.promptstr[0] = '\0';
|
(void)strlcpy(mc.promptstr, prompt, sizeof(mc.promptstr));
|
||||||
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.hasprompt = 1;
|
||||||
|
} else {
|
||||||
|
evmask = MENUMASK;
|
||||||
|
mc.list = 1;
|
||||||
}
|
}
|
||||||
mc.height = sc->xftfont->height + 1;
|
|
||||||
|
|
||||||
if (initial != NULL)
|
if (initial != NULL)
|
||||||
(void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
|
(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.print = print;
|
||||||
mc.entry = mc.prev = -1;
|
mc.entry = mc.prev = -1;
|
||||||
|
|
||||||
XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width, mc.height);
|
|
||||||
XSelectInput(X_Dpy, sc->menuwin, evmask);
|
XSelectInput(X_Dpy, sc->menuwin, evmask);
|
||||||
XMapRaised(X_Dpy, sc->menuwin);
|
XMapRaised(X_Dpy, sc->menuwin);
|
||||||
|
|
||||||
@ -193,6 +185,7 @@ out:
|
|||||||
xu_ptr_setpos(sc->rootwin, xsave, ysave);
|
xu_ptr_setpos(sc->rootwin, xsave, ysave);
|
||||||
xu_ptr_ungrab();
|
xu_ptr_ungrab();
|
||||||
|
|
||||||
|
XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, 1, 1);
|
||||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||||
XUngrabKeyboard(X_Dpy, CurrentTime);
|
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->width = 0;
|
||||||
mc->height = 0;
|
mc->height = 0;
|
||||||
if (mc->hasprompt) {
|
if (mc->hasprompt) {
|
||||||
(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s",
|
(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s%s",
|
||||||
mc->promptstr, mc->searchstr, PROMPT_ECHAR);
|
mc->promptstr, PROMPT_SCHAR, mc->searchstr, PROMPT_ECHAR);
|
||||||
mc->width = font_width(sc->xftfont, mc->dispstr,
|
mc->width = font_width(sc->xftfont, mc->dispstr,
|
||||||
strlen(mc->dispstr));
|
strlen(mc->dispstr));
|
||||||
mc->height = sc->xftfont->height + 1;
|
mc->height = sc->xftfont->height + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user