summaryrefslogtreecommitdiff
path: root/app/cwm/mousefunc.c
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2014-01-20 18:58:04 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2014-01-20 18:58:04 +0000
commitc481d1252cc0c917f03eddb6e2e33327963331a3 (patch)
tree94da68987742f0da604d3b71cfaec0866d5badd8 /app/cwm/mousefunc.c
parent87c6bd4a72ae718671c5945a6964d863c4c077cf (diff)
Add a function that adds an entry to a menuq, normalizing a common code
path; from Tiago Cunha.
Diffstat (limited to 'app/cwm/mousefunc.c')
-rw-r--r--app/cwm/mousefunc.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c
index b7418ce91..3c33aed82 100644
--- a/app/cwm/mousefunc.c
+++ b/app/cwm/mousefunc.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: mousefunc.c,v 1.65 2014/01/02 21:30:20 okan Exp $
+ * $OpenBSD: mousefunc.c,v 1.66 2014/01/20 18:58:03 okan Exp $
*/
#include <sys/param.h>
@@ -234,11 +234,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, union arg *arg)
if (wname == NULL)
continue;
- mi = xcalloc(1, sizeof(*mi));
- (void)snprintf(mi->text, sizeof(mi->text), "(%d) %s",
+ menuq_add(&menuq, cc, "(%d) %s",
cc->group ? cc->group->shortcut : 0, wname);
- mi->ctx = cc;
- TAILQ_INSERT_TAIL(&menuq, mi, entry);
}
if (TAILQ_EMPTY(&menuq))
@@ -267,12 +264,8 @@ mousefunc_menu_cmd(struct client_ctx *cc, union arg *arg)
TAILQ_INIT(&menuq);
- TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
- mi = xcalloc(1, sizeof(*mi));
- (void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
- mi->ctx = cmd;
- TAILQ_INSERT_TAIL(&menuq, mi, entry);
- }
+ TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
+ menuq_add(&menuq, cmd, "%s", cmd->label);
if (TAILQ_EMPTY(&menuq))
return;