summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2014-02-08 02:40:44 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2014-02-08 02:40:44 +0000
commit9b2803779f9c08811d7bf7c89223ff56f629028f (patch)
tree9bebfddfcfe0a22f83ec31f5914c1c6ce43dcf7f /app
parentebb6563cc154b4efdbf8eec33714e245790d6853 (diff)
Replace a few hand rolled loops with like tailq loops.
Diffstat (limited to 'app')
-rw-r--r--app/cwm/group.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/app/cwm/group.c b/app/cwm/group.c
index 0617cdfba..5d8a044b0 100644
--- a/app/cwm/group.c
+++ b/app/cwm/group.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: group.c,v 1.85 2014/02/07 18:09:54 okan Exp $
+ * $OpenBSD: group.c,v 1.86 2014/02/08 02:40:43 okan Exp $
*/
#include <sys/param.h>
@@ -244,16 +244,16 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
void
group_only(struct screen_ctx *sc, int idx)
{
- int i;
+ struct group_ctx *gc;
if (idx < 0 || idx >= CALMWM_NGROUPS)
errx(1, "group_only: index out of range (%d)", idx);
- for (i = 0; i < CALMWM_NGROUPS; i++) {
- if (i == idx)
- group_show(sc, &sc->groups[i]);
+ TAILQ_FOREACH(gc, &sc->groupq, entry) {
+ if (gc->shortcut == idx)
+ group_show(sc, gc);
else
- group_hide(sc, &sc->groups[i]);
+ group_hide(sc, gc);
}
}
@@ -300,18 +300,15 @@ group_menu(struct screen_ctx *sc)
struct group_ctx *gc;
struct menu *mi;
struct menu_q menuq;
- int i;
TAILQ_INIT(&menuq);
- for (i = 0; i < CALMWM_NGROUPS; i++) {
- gc = &sc->groups[i];
-
+ TAILQ_FOREACH(gc, &sc->groupq, entry) {
if (TAILQ_EMPTY(&gc->clients))
continue;
menuq_add(&menuq, gc, gc->hidden ? "%d: [%s]" : "%d: %s",
- gc->shortcut, sc->group_names[i]);
+ gc->shortcut, sc->group_names[gc->shortcut]);
}
if (TAILQ_EMPTY(&menuq))
@@ -329,16 +326,15 @@ group_menu(struct screen_ctx *sc)
void
group_alltoggle(struct screen_ctx *sc)
{
- int i;
+ struct group_ctx *gc;
- for (i = 0; i < CALMWM_NGROUPS; i++) {
+ TAILQ_FOREACH(gc, &sc->groupq, entry) {
if (sc->group_hideall)
- group_show(sc, &sc->groups[i]);
+ group_show(sc, gc);
else
- group_hide(sc, &sc->groups[i]);
+ group_hide(sc, gc);
}
-
- sc->group_hideall = (!sc->group_hideall);
+ sc->group_hideall = !sc->group_hideall;
}
void