From 649e5970e98b0073763f42a25dcab02aadea688f Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 30 Oct 2020 08:55:56 +0000 Subject: Add a -O flag to display-menu to change the mouse behaviour and not close the menu when the mouse is released, from teo_paul1 at yahoo dot com. --- menu.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'menu.c') diff --git a/menu.c b/menu.c index 4fcf660a..3bd56ab1 100644 --- a/menu.c +++ b/menu.c @@ -203,16 +203,28 @@ menu_key_cb(struct client *c, struct key_event *event) m->x > md->px + 4 + menu->width || m->y < md->py + 1 || m->y > md->py + 1 + count - 1) { - if (MOUSE_RELEASE(m->b)) - return (1); + if (~md->flags & MENU_STAYOPEN) { + if (MOUSE_RELEASE(m->b)) + return (1); + } else { + if (!MOUSE_RELEASE(m->b) && + MOUSE_WHEEL(m->b) == 0 && + !MOUSE_DRAG(m->b)) + return (1); + } if (md->choice != -1) { md->choice = -1; c->flags |= CLIENT_REDRAWOVERLAY; } return (0); } - if (MOUSE_RELEASE(m->b)) - goto chosen; + if (~md->flags & MENU_STAYOPEN) { + if (MOUSE_RELEASE(m->b)) + goto chosen; + } else { + if (MOUSE_WHEEL(m->b) == 0 && !MOUSE_DRAG(m->b)) + goto chosen; + } md->choice = m->y - (md->py + 1); if (md->choice != old) c->flags |= CLIENT_REDRAWOVERLAY; @@ -303,6 +315,8 @@ chosen: if (md->choice == -1) return (1); item = &menu->items[md->choice]; + if ((md->flags & MENU_STAYOPEN) && item->name == NULL) + return (0); if (item->name == NULL || *item->name == '-') return (1); if (md->cb != NULL) { -- cgit