diff options
author | okan <okan> | 2014-01-20 18:58:03 +0000 |
---|---|---|
committer | okan <okan> | 2014-01-20 18:58:03 +0000 |
commit | 720b5452aa13bf27740a2b923617188fde8814ed (patch) | |
tree | 92a1a0020533747078662aea1050a906e0715398 /mousefunc.c | |
parent | 43ccf4eae0f0f5c50495834e29f93671468a7cfe (diff) | |
download | cwm-720b5452aa13bf27740a2b923617188fde8814ed.tar.gz cwm-720b5452aa13bf27740a2b923617188fde8814ed.tar.xz cwm-720b5452aa13bf27740a2b923617188fde8814ed.zip |
Add a function that adds an entry to a menuq, normalizing a common code
path; from Tiago Cunha.
Diffstat (limited to 'mousefunc.c')
-rw-r--r-- | mousefunc.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/mousefunc.c b/mousefunc.c index 3bc7f1d..c65daf3 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -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; |