From cb65869d7a01eb093e8a95caea5a6e21b6689f42 Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 23 Sep 2014 13:45:48 +0000 Subject: [PATCH 1/4] Move stuff that doesn't belong in group_init; while here, explicitly initialize hideall and cycling. --- calmwm.h | 8 ++++---- group.c | 13 ++----------- screen.c | 9 +++++++++ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/calmwm.h b/calmwm.h index dd8a782..03d7a85 100644 --- a/calmwm.h +++ b/calmwm.h @@ -229,19 +229,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; +#define CALMWM_NGROUPS 10 + struct group_ctx_q groupq; + struct group_ctx *group_active; 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; }; TAILQ_HEAD(screen_ctx_q, screen_ctx); diff --git a/group.c b/group.c index ce5a504..7d05861 100644 --- a/group.c +++ b/group.c @@ -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; @@ -131,12 +128,6 @@ group_init(struct screen_ctx *sc) TAILQ_INSERT_TAIL(&sc->groupq, gc, entry); } - 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); } @@ -315,12 +306,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/screen.c b/screen.c index 3c7c41b..9beabb2 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| From 845e82015ce9c1467f100a7f3d9c0310b00e353c Mon Sep 17 00:00:00 2001 From: okan Date: Tue, 23 Sep 2014 14:25:08 +0000 Subject: [PATCH 2/4] Update _NET_CURRENT_DESKTOP with the screen's group_active->num. --- calmwm.h | 2 +- group.c | 6 +++--- xutil.c | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/calmwm.h b/calmwm.h index 03d7a85..01242ee 100644 --- a/calmwm.h +++ b/calmwm.h @@ -544,7 +544,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/group.c b/group.c index 7d05861..cabf854 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 screen_ctx *, int); const char *num_to_name[] = { "nogroup", "one", "two", "three", "four", "five", "six", @@ -132,7 +132,7 @@ group_init(struct screen_ctx *sc) } static void -group_setactive(struct screen_ctx *sc, long idx) +group_setactive(struct screen_ctx *sc, int idx) { struct group_ctx *gc; @@ -142,7 +142,7 @@ group_setactive(struct screen_ctx *sc, long idx) } sc->group_active = gc; - xu_ewmh_net_current_desktop(sc, idx); + xu_ewmh_net_current_desktop(sc); } void diff --git a/xutil.c b/xutil.c index 91ef51b..70186f8 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 From 319d90099d96e5f9d2b9b3ef182baf17a051a357 Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 27 Sep 2014 18:57:11 +0000 Subject: [PATCH 3/4] Pass just the group to group_setactive instead of the screen and an index which then needed to be found in a queue. --- group.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/group.c b/group.c index cabf854..6194e58 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 *, int); +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 @@ -126,20 +126,16 @@ 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); } - - group_setactive(sc, 1); } static void -group_setactive(struct screen_ctx *sc, int 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); @@ -243,7 +239,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); } } @@ -297,7 +293,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 From e9dbd150eaf14d230e7aa6191e5762b69e6b1241 Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 27 Sep 2014 19:04:32 +0000 Subject: [PATCH 4/4] these have nothing to do with 'sticky', but rather group membership; rename. --- calmwm.h | 4 ++-- client.c | 2 +- group.c | 7 ++----- kbfunc.c | 2 +- mousefunc.c | 2 +- xevents.c | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/calmwm.h b/calmwm.h index 01242ee..00d09bb 100644 --- a/calmwm.h +++ b/calmwm.h @@ -414,8 +414,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 *, diff --git a/client.c b/client.c index d6700a1..1802206 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 6194e58..c7933f0 100644 --- a/group.c +++ b/group.c @@ -162,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; @@ -183,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); diff --git a/kbfunc.c b/kbfunc.c index f144ee0..c3be2f5 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 cc3047e..1f3cf34 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/xevents.c b/xevents.c index e294c61..e2b7178 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