aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calmwm.h4
-rw-r--r--group.c49
-rw-r--r--screen.c3
3 files changed, 21 insertions, 35 deletions
diff --git a/calmwm.h b/calmwm.h
index a3e63b3..aa23bca 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.262 2014/08/20 15:15:29 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.263 2014/08/24 15:37:45 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -204,7 +204,6 @@ struct group_ctx {
TAILQ_ENTRY(group_ctx) entry;
struct client_ctx_q clients;
int num;
- int hidden;
};
TAILQ_HEAD(group_ctx_q, group_ctx);
@@ -413,7 +412,6 @@ void group_init(struct screen_ctx *);
void group_menu(struct screen_ctx *);
void group_movetogroup(struct client_ctx *, int);
void group_only(struct screen_ctx *, int);
-void group_set_state(struct screen_ctx *);
void group_sticky(struct client_ctx *);
void group_sticky_toggle_enter(struct client_ctx *);
void group_sticky_toggle_exit(struct client_ctx *);
diff --git a/group.c b/group.c
index 36a2bb4..e341c8c 100644
--- a/group.c
+++ b/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.93 2014/08/22 19:04:00 okan Exp $
+ * $OpenBSD: group.c,v 1.94 2014/08/24 15:37:45 okan Exp $
*/
#include <sys/param.h>
@@ -36,7 +36,7 @@ static void group_assign(struct group_ctx *, struct client_ctx *);
static void group_hide(struct screen_ctx *, struct group_ctx *);
static void group_show(struct screen_ctx *, struct group_ctx *);
static void group_restack(struct screen_ctx *, struct group_ctx *);
-static void group_set_hidden_state(struct group_ctx *);
+static int group_hidden_state(struct group_ctx *);
static void group_setactive(struct screen_ctx *, long);
static void group_set_names(struct screen_ctx *);
@@ -68,8 +68,6 @@ group_hide(struct screen_ctx *sc, struct group_ctx *gc)
TAILQ_FOREACH(cc, &gc->clients, group_entry)
client_hide(cc);
-
- gc->hidden = 1;
}
static void
@@ -80,8 +78,6 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc)
TAILQ_FOREACH(cc, &gc->clients, group_entry)
client_unhide(cc);
- gc->hidden = 0;
-
group_restack(sc, gc);
group_setactive(sc, gc->num);
}
@@ -136,7 +132,6 @@ 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].num = i;
TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry);
}
@@ -149,15 +144,6 @@ group_init(struct screen_ctx *sc)
group_setactive(sc, 1);
}
-void
-group_set_state(struct screen_ctx *sc)
-{
- struct group_ctx *gc;
-
- TAILQ_FOREACH(gc, &sc->groupq, entry)
- group_set_hidden_state(gc);
-}
-
static void
group_setactive(struct screen_ctx *sc, long idx)
{
@@ -176,9 +162,10 @@ group_movetogroup(struct client_ctx *cc, int idx)
errx(1, "group_movetogroup: index out of range (%d)", idx);
gc = &sc->groups[idx];
+
if (cc->group == gc)
return;
- if (gc->hidden)
+ if (group_hidden_state(gc))
client_hide(cc);
group_assign(gc, cc);
}
@@ -211,21 +198,23 @@ group_sticky_toggle_exit(struct client_ctx *cc)
}
/*
- * If all clients in a group are hidden, then set the group state as hidden.
+ * If all clients in a group are hidden, then the group state is hidden.
*/
-static void
-group_set_hidden_state(struct group_ctx *gc)
+static int
+group_hidden_state(struct group_ctx *gc)
{
struct client_ctx *cc;
- int same = 0;
+ int hidden = 0, same = 0;
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
- if (gc->hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0))
+ if (hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0))
same++;
}
if (same == 0)
- gc->hidden = !gc->hidden;
+ hidden = !hidden;
+
+ return(hidden);
}
void
@@ -237,9 +226,8 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
errx(1, "group_hidetoggle: index out of range (%d)", idx);
gc = &sc->groups[idx];
- group_set_hidden_state(gc);
- if (gc->hidden)
+ if (group_hidden_state(gc))
group_show(sc, gc);
else {
group_hide(sc, gc);
@@ -287,7 +275,7 @@ group_cycle(struct screen_ctx *sc, int flags)
if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL)
showgroup = gc;
- else if (!gc->hidden)
+ else if (!group_hidden_state(gc))
group_hide(sc, gc);
}
@@ -296,7 +284,7 @@ group_cycle(struct screen_ctx *sc, int flags)
group_hide(sc, sc->group_active);
- if (showgroup->hidden)
+ if (group_hidden_state(showgroup))
group_show(sc, showgroup);
else
group_setactive(sc, showgroup->num);
@@ -314,8 +302,8 @@ group_menu(struct screen_ctx *sc)
TAILQ_FOREACH(gc, &sc->groupq, entry) {
if (TAILQ_EMPTY(&gc->clients))
continue;
-
- menuq_add(&menuq, gc, gc->hidden ? "%d: [%s]" : "%d: %s",
+ menuq_add(&menuq, gc,
+ group_hidden_state(gc) ? "%d: [%s]" : "%d: %s",
gc->num, sc->group_names[gc->num]);
}
@@ -325,7 +313,8 @@ group_menu(struct screen_ctx *sc)
mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL);
if (mi != NULL && mi->ctx != NULL) {
gc = (struct group_ctx *)mi->ctx;
- (gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc);
+ (group_hidden_state(gc)) ?
+ group_show(sc, gc) : group_hide(sc, gc);
}
menuq_clear(&menuq);
diff --git a/screen.c b/screen.c
index 53c33f6..9769fee 100644
--- a/screen.c
+++ b/screen.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: screen.c,v 1.63 2014/08/20 15:15:29 okan Exp $
+ * $OpenBSD: screen.c,v 1.64 2014/08/24 15:37:45 okan Exp $
*/
#include <sys/param.h>
@@ -69,7 +69,6 @@ screen_init(int which)
XFree(wins);
}
screen_updatestackingorder(sc);
- group_set_state(sc);
if (HasRandr)
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);