summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2014-09-27 19:04:32 +0000
committerokan <okan>2014-09-27 19:04:32 +0000
commitc700f7e19a1af8f488da3657c8c25d1eb8accd0a (patch)
tree74c10c8ca27413c9328e37a85e114383b1200f80
parent2540b3f4fe34c6bc6ed0593e9c6d713d84b2c301 (diff)
parente9dbd150eaf14d230e7aa6191e5762b69e6b1241 (diff)
downloadcwm-c700f7e19a1af8f488da3657c8c25d1eb8accd0a.tar.gz
cwm-c700f7e19a1af8f488da3657c8c25d1eb8accd0a.tar.xz
cwm-c700f7e19a1af8f488da3657c8c25d1eb8accd0a.zip
cvsimport
-rw-r--r--calmwm.h14
-rw-r--r--client.c2
-rw-r--r--group.c42
-rw-r--r--kbfunc.c2
-rw-r--r--mousefunc.c2
-rw-r--r--screen.c9
-rw-r--r--xevents.c2
-rw-r--r--xutil.c6
8 files changed, 37 insertions, 42 deletions
diff --git a/calmwm.h b/calmwm.h
index 5fe8c78..f6779a5 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -248,19 +248,19 @@ struct screen_ctx {
 	Window			 rootwin;
 	Window			 menuwin;
 	int			 cycling;
+	int			 hideall;
 	int			 snapdist;
 	struct geom		 view; /* viewable area */
 	struct geom		 work; /* workable area, gap-applied */
 	struct gap		 gap;
 	struct client_ctx_q	 clientq;
 	struct region_ctx_q	 regionq;
-	XftColor		 xftcolor[CWM_COLOR_NITEMS];
-	XftDraw			*xftdraw;
-	XftFont			*xftfont;
 #define CALMWM_NGROUPS		 10
 	struct group_ctx_q	 groupq;
-	int			 group_hideall;
 	struct group_ctx	*group_active;
+	XftColor		 xftcolor[CWM_COLOR_NITEMS];
+	XftDraw			*xftdraw;
+	XftFont			*xftfont;
 };
 TAILQ_HEAD(screen_ctx_q, screen_ctx);
 
@@ -433,8 +433,8 @@ void			 group_init(struct screen_ctx *);
 void			 group_movetogroup(struct client_ctx *, int);
 void			 group_only(struct screen_ctx *, int);
 void			 group_show(struct group_ctx *);
-void			 group_sticky_toggle_enter(struct client_ctx *);
-void			 group_sticky_toggle_exit(struct client_ctx *);
+void			 group_toggle_membership_enter(struct client_ctx *);
+void			 group_toggle_membership_leave(struct client_ctx *);
 void			 group_update_names(struct screen_ctx *);
 
 void			 search_match_client(struct menu_q *, struct menu_q *,
@@ -563,7 +563,7 @@ void			 xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *);
 void			 xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *);
 void			 xu_ewmh_net_showing_desktop(struct screen_ctx *);
 void			 xu_ewmh_net_virtual_roots(struct screen_ctx *);
-void			 xu_ewmh_net_current_desktop(struct screen_ctx *, long);
+void			 xu_ewmh_net_current_desktop(struct screen_ctx *);
 void			 xu_ewmh_net_desktop_names(struct screen_ctx *);
 
 void			 xu_ewmh_net_wm_desktop(struct client_ctx *);
diff --git a/client.c b/client.c
index be51067..4697df5 100644
--- a/client.c
+++ b/client.c
@@ -696,7 +696,7 @@ client_cycle_leave(struct screen_ctx *sc)
 
 	if ((cc = client_current())) {
 		client_mtf(cc);
-		group_sticky_toggle_exit(cc);
+		group_toggle_membership_leave(cc);
 		XUngrabKeyboard(X_Dpy, CurrentTime);
 	}
 }
diff --git a/group.c b/group.c
index 1cae681..e70acbb 100644
--- a/group.c
+++ b/group.c
@@ -34,7 +34,7 @@
 
 static void		 group_assign(struct group_ctx *, struct client_ctx *);
 static void		 group_restack(struct group_ctx *);
-static void		 group_setactive(struct screen_ctx *, long);
+static void		 group_setactive(struct group_ctx *);
 
 const char *num_to_name[] = {
 	"nogroup", "one", "two", "three", "four", "five", "six",
@@ -75,7 +75,7 @@ group_show(struct group_ctx *gc)
 		client_unhide(cc);
 
 	group_restack(gc);
-	group_setactive(gc->sc, gc->num);
+	group_setactive(gc);
 }
 
 static void
@@ -119,9 +119,6 @@ group_init(struct screen_ctx *sc)
 	struct group_ctx	*gc;
 	int			 i;
 
-	TAILQ_INIT(&sc->groupq);
-	sc->group_hideall = 0;
-
 	for (i = 0; i < CALMWM_NGROUPS; i++) {
 		gc = xcalloc(1, sizeof(*gc));
 		gc->sc = sc;
@@ -129,29 +126,19 @@ group_init(struct screen_ctx *sc)
 		gc->name = xstrdup(num_to_name[i]);
 		gc->num = i;
 		TAILQ_INSERT_TAIL(&sc->groupq, gc, entry);
+		if (i == 1)
+			group_setactive(gc);
 	}
-
-	xu_ewmh_net_desktop_names(sc);
-	xu_ewmh_net_wm_desktop_viewport(sc);
-	xu_ewmh_net_wm_number_of_desktops(sc);
-	xu_ewmh_net_showing_desktop(sc);
-	xu_ewmh_net_virtual_roots(sc);
-
-	group_setactive(sc, 1);
 }
 
 static void
-group_setactive(struct screen_ctx *sc, long idx)
+group_setactive(struct group_ctx *gc)
 {
-	struct group_ctx	*gc;
+	struct screen_ctx	*sc = gc->sc;
 
-	TAILQ_FOREACH(gc, &sc->groupq, entry) {
-		if (gc->num == idx)
-			break;
-	}
 	sc->group_active = gc;
 
-	xu_ewmh_net_current_desktop(sc, idx);
+	xu_ewmh_net_current_desktop(sc);
 }
 
 void
@@ -175,11 +162,8 @@ group_movetogroup(struct client_ctx *cc, int idx)
 	group_assign(gc, cc);
 }
 
-/*
- * Colouring for groups upon add/remove.
- */
 void
-group_sticky_toggle_enter(struct client_ctx *cc)
+group_toggle_membership_enter(struct client_ctx *cc)
 {
 	struct screen_ctx	*sc = cc->sc;
 	struct group_ctx	*gc = sc->group_active;
@@ -196,7 +180,7 @@ group_sticky_toggle_enter(struct client_ctx *cc)
 }
 
 void
-group_sticky_toggle_exit(struct client_ctx *cc)
+group_toggle_membership_leave(struct client_ctx *cc)
 {
 	cc->flags &= ~CLIENT_HIGHLIGHT;
 	client_draw_border(cc);
@@ -252,7 +236,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
 		group_hide(gc);
 		/* make clients stick to empty group */
 		if (TAILQ_EMPTY(&gc->clientq))
-			group_setactive(sc, idx);
+			group_setactive(gc);
 	}
 }
 
@@ -306,7 +290,7 @@ group_cycle(struct screen_ctx *sc, int flags)
 	if (group_holds_only_hidden(showgroup))
 		group_show(showgroup);
 	else
-		group_setactive(sc, showgroup->num);
+		group_setactive(showgroup);
 }
 
 void
@@ -315,12 +299,12 @@ group_alltoggle(struct screen_ctx *sc)
 	struct group_ctx	*gc;
 
 	TAILQ_FOREACH(gc, &sc->groupq, entry) {
-		if (sc->group_hideall)
+		if (sc->hideall)
 			group_show(gc);
 		else
 			group_hide(gc);
 	}
-	sc->group_hideall = !sc->group_hideall;
+	sc->hideall = !sc->hideall;
 }
 
 void
diff --git a/kbfunc.c b/kbfunc.c
index 84164ab..afb0314 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -438,7 +438,7 @@ kbfunc_client_grouptoggle(struct client_ctx *cc, union arg *arg)
 	XGrabKeyboard(X_Dpy, cc->win, True,
 	    GrabModeAsync, GrabModeAsync, CurrentTime);
 
-	group_sticky_toggle_enter(cc);
+	group_toggle_membership_enter(cc);
 }
 
 void
diff --git a/mousefunc.c b/mousefunc.c
index a3d9c6a..00348f3 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -174,7 +174,7 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
 void
 mousefunc_client_grouptoggle(struct client_ctx *cc, union arg *arg)
 {
-	group_sticky_toggle_enter(cc);
+	group_toggle_membership_enter(cc);
 }
 
 void
diff --git a/screen.c b/screen.c
index 2eefa0c..a7da3e9 100644
--- a/screen.c
+++ b/screen.c
@@ -42,9 +42,12 @@ screen_init(int which)
 
 	TAILQ_INIT(&sc->clientq);
 	TAILQ_INIT(&sc->regionq);
+	TAILQ_INIT(&sc->groupq);
 
 	sc->which = which;
 	sc->rootwin = RootWindow(X_Dpy, sc->which);
+	sc->cycling = 0;
+	sc->hideall = 0;
 	conf_screen(sc);
 
 	xu_ewmh_net_supported(sc);
@@ -53,6 +56,12 @@ screen_init(int which)
 	screen_update_geometry(sc);
 	group_init(sc);
 
+	xu_ewmh_net_desktop_names(sc);
+	xu_ewmh_net_wm_desktop_viewport(sc);
+	xu_ewmh_net_wm_number_of_desktops(sc);
+	xu_ewmh_net_showing_desktop(sc);
+	xu_ewmh_net_virtual_roots(sc);
+
 	rootattr.cursor = Conf.cursor[CF_NORMAL];
 	rootattr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|
 	    PropertyChangeMask|EnterWindowMask|LeaveWindowMask|
diff --git a/xevents.c b/xevents.c
index de6d41b..8facee1 100644
--- a/xevents.c
+++ b/xevents.c
@@ -251,7 +251,7 @@ xev_handle_buttonrelease(XEvent *ee)
 	struct client_ctx *cc;
 
 	if ((cc = client_current()))
-		group_sticky_toggle_exit(cc);
+		group_toggle_membership_leave(cc);
 }
 
 static void
diff --git a/xutil.c b/xutil.c
index 7765413..460f902 100644
--- a/xutil.c
+++ b/xutil.c
@@ -274,10 +274,12 @@ xu_ewmh_net_virtual_roots(struct screen_ctx *sc)
 }
 
 void
-xu_ewmh_net_current_desktop(struct screen_ctx *sc, long idx)
+xu_ewmh_net_current_desktop(struct screen_ctx *sc)
 {
+	long	 num = sc->group_active->num;
+
 	XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CURRENT_DESKTOP],
-	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&idx, 1);
+	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&num, 1);
 }
 
 void