From b31b09dfc26b4b17c025d7196b8b5a4a26f599df Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 20 Aug 2014 15:15:29 +0000 Subject: [PATCH] Purely mechanical; unify 'num', 'no' and 'shortcut'. --- calmwm.h | 2 +- client.c | 2 +- conf.c | 4 ++-- group.c | 38 +++++++++++++++++++------------------- mousefunc.c | 3 +-- screen.c | 6 +++--- search.c | 2 +- xutil.c | 4 ++-- 8 files changed, 30 insertions(+), 31 deletions(-) diff --git a/calmwm.h b/calmwm.h index f06a2fb..a2693aa 100644 --- a/calmwm.h +++ b/calmwm.h @@ -203,7 +203,7 @@ TAILQ_HEAD(cycle_entry_q, client_ctx); struct group_ctx { TAILQ_ENTRY(group_ctx) entry; struct client_ctx_q clients; - int shortcut; + int num; int hidden; }; TAILQ_HEAD(group_ctx_q, group_ctx); diff --git a/client.c b/client.c index 6fa7c1b..bacfb51 100644 --- a/client.c +++ b/client.c @@ -869,7 +869,7 @@ client_transient(struct client_ctx *cc) if (XGetTransientForHint(X_Dpy, cc->win, &trans)) { if ((tc = client_find(trans)) && tc->group) { - group_movetogroup(cc, tc->group->shortcut); + group_movetogroup(cc, tc->group->num); if (tc->flags & CLIENT_IGNORE) cc->flags |= CLIENT_IGNORE; } diff --git a/conf.c b/conf.c index 528cdf2..c6eb24f 100644 --- a/conf.c +++ b/conf.c @@ -78,7 +78,7 @@ conf_cmd_remove(struct conf *c, const char *name) } } void -conf_autogroup(struct conf *c, int no, const char *val) +conf_autogroup(struct conf *c, int num, const char *val) { struct autogroupwin *aw; char *p; @@ -93,7 +93,7 @@ conf_autogroup(struct conf *c, int no, const char *val) aw->name = xstrdup(val); aw->class = xstrdup(p); } - aw->num = no; + aw->num = num; TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry); } diff --git a/group.c b/group.c index 5eefea8..ef93de3 100644 --- a/group.c +++ b/group.c @@ -40,7 +40,7 @@ static void group_set_hidden_state(struct group_ctx *); static void group_setactive(struct screen_ctx *, long); static void group_set_names(struct screen_ctx *); -const char *shortcut_to_name[] = { +const char *num_to_name[] = { "nogroup", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; @@ -86,7 +86,7 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc) gc->hidden = 0; group_restack(sc, gc); - group_setactive(sc, gc->shortcut); + group_setactive(sc, gc->num); } static void @@ -140,7 +140,7 @@ group_init(struct screen_ctx *sc) for (i = 0; i < CALMWM_NGROUPS; i++) { TAILQ_INIT(&sc->groups[i].clients); sc->groups[i].hidden = 0; - sc->groups[i].shortcut = i; + sc->groups[i].num = i; TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry); } @@ -261,7 +261,7 @@ group_only(struct screen_ctx *sc, int idx) errx(1, "group_only: index out of range (%d)", idx); TAILQ_FOREACH(gc, &sc->groupq, entry) { - if (gc->shortcut == idx) + if (gc->num == idx) group_show(sc, gc); else group_hide(sc, gc); @@ -302,7 +302,7 @@ group_cycle(struct screen_ctx *sc, int flags) if (showgroup->hidden) group_show(sc, showgroup); else - group_setactive(sc, showgroup->shortcut); + group_setactive(sc, showgroup->num); } void @@ -319,7 +319,7 @@ group_menu(struct screen_ctx *sc) continue; menuq_add(&menuq, gc, gc->hidden ? "%d: [%s]" : "%d: %s", - gc->shortcut, sc->group_names[gc->shortcut]); + gc->num, sc->group_names[gc->num]); } if (TAILQ_EMPTY(&menuq)) @@ -354,36 +354,36 @@ group_autogroup(struct client_ctx *cc) struct screen_ctx *sc = cc->sc; struct autogroupwin *aw; struct group_ctx *gc; - int no = -1, both_match = 0; - long *grpno; + int num = -1, both_match = 0; + long *grpnum; if (cc->ch.res_class == NULL || cc->ch.res_name == NULL) return; if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP], - XA_CARDINAL, 1, (unsigned char **)&grpno) > 0) { - if (*grpno == -1) - no = 0; - else if (*grpno > CALMWM_NGROUPS || *grpno < 0) - no = CALMWM_NGROUPS - 1; + XA_CARDINAL, 1, (unsigned char **)&grpnum) > 0) { + if (*grpnum == -1) + num = 0; + else if (*grpnum > CALMWM_NGROUPS || *grpnum < 0) + num = CALMWM_NGROUPS - 1; else - no = *grpno; - XFree(grpno); + num = *grpnum; + XFree(grpnum); } else { TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { if (strcmp(aw->class, cc->ch.res_class) == 0) { if ((aw->name != NULL) && (strcmp(aw->name, cc->ch.res_name) == 0)) { - no = aw->num; + num = aw->num; both_match = 1; } else if (aw->name == NULL && !both_match) - no = aw->num; + num = aw->num; } } } TAILQ_FOREACH(gc, &sc->groupq, entry) { - if (gc->shortcut == no) { + if (gc->num == num) { group_assign(gc, cc); return; } @@ -427,7 +427,7 @@ group_update_names(struct screen_ctx *sc) setnames = 1; i = 0; while (n < CALMWM_NGROUPS) - strings[n++] = xstrdup(shortcut_to_name[i++]); + strings[n++] = xstrdup(num_to_name[i++]); } if (prop_ret != NULL) diff --git a/mousefunc.c b/mousefunc.c index e2b5766..d6373cb 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -202,8 +202,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, union arg *arg) if (wname == NULL) continue; - menuq_add(&menuq, cc, "(%d) %s", - cc->group->shortcut, wname); + menuq_add(&menuq, cc, "(%d) %s", cc->group->num, wname); } if (TAILQ_EMPTY(&menuq)) diff --git a/screen.c b/screen.c index 2a38831..0621065 100644 --- a/screen.c +++ b/screen.c @@ -142,7 +142,7 @@ screen_update_geometry(struct screen_ctx *sc) { XineramaScreenInfo *info = NULL; struct region_ctx *region; - int info_no = 0, i; + int info_num = 0, i; sc->view.x = 0; sc->view.y = 0; @@ -156,13 +156,13 @@ screen_update_geometry(struct screen_ctx *sc) /* RandR event may have a CTRC added or removed. */ if (XineramaIsActive(X_Dpy)) - info = XineramaQueryScreens(X_Dpy, &info_no); + info = XineramaQueryScreens(X_Dpy, &info_num); while ((region = TAILQ_FIRST(&sc->regionq)) != NULL) { TAILQ_REMOVE(&sc->regionq, region, entry); free(region); } - for (i = 0; i < info_no; i++) { + for (i = 0; i < info_num; i++) { region = xmalloc(sizeof(*region)); region->num = i; region->area.x = info[i].x_org; diff --git a/search.c b/search.c index 1e43d20..fd1210e 100644 --- a/search.c +++ b/search.c @@ -143,7 +143,7 @@ search_print_client(struct menu *mi, int list) cc->matchname = cc->name; (void)snprintf(mi->print, sizeof(mi->print), "(%d) %c%s", - cc->group->shortcut, flag, cc->matchname); + cc->group->num, flag, cc->matchname); if (!list && cc->matchname != cc->name && strlen(mi->print) < sizeof(mi->print) - 1) { diff --git a/xutil.c b/xutil.c index 8fdc3ad..3c4d004 100644 --- a/xutil.c +++ b/xutil.c @@ -291,10 +291,10 @@ xu_ewmh_net_desktop_names(struct screen_ctx *sc, char *data, int n) void xu_ewmh_net_wm_desktop(struct client_ctx *cc) { - long no = cc->group->shortcut; + long num = cc->group->num; XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP], - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1); + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&num, 1); } Atom *