aboutsummaryrefslogtreecommitdiffstats
path: root/group.c
diff options
context:
space:
mode:
authorokan2014-09-06 16:08:58 +0000
committerokan2014-09-06 16:08:58 +0000
commite829ebdfb7b6c439829f9be1473e94d9e0724294 (patch)
tree18ab6acfa2ee70ed2b0bd67c13f31b1e2f2c4d54 /group.c
parentf8d684d6fbeb9cd2b4af04ce87ac3b5b9b8f9da8 (diff)
downloadcwm-e829ebdfb7b6c439829f9be1473e94d9e0724294.tar.gz
Rework group names: stash the group name inside the group_ctx as opposed
to having to manage an array outside in screen_ctx for group names and shortcuts. Simplifies (and moves bits for) reading, and constructing data for, EWMH's _NET_DESKTOP_NAMES.
Diffstat (limited to '')
-rw-r--r--group.c56
1 files changed, 3 insertions, 53 deletions
diff --git a/group.c b/group.c
index 5282f18..6377d79 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.97 2014/09/01 18:04:58 okan Exp $
+ * $OpenBSD: group.c,v 1.98 2014/09/06 16:08:58 okan Exp $
*/
#include <sys/param.h>
@@ -120,18 +120,15 @@ group_init(struct screen_ctx *sc)
TAILQ_INIT(&sc->groupq);
sc->group_hideall = 0;
- /*
- * See if any group names have already been set and update the
- * property with ours if they'll have changed.
- */
- group_update_names(sc);
for (i = 0; i < CALMWM_NGROUPS; i++) {
TAILQ_INIT(&sc->groups[i].clients);
+ sc->groups[i].name = xstrdup(num_to_name[i]);
sc->groups[i].num = i;
TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], 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);
@@ -350,50 +347,3 @@ group_autogroup(struct client_ctx *cc)
else
group_assign(NULL, cc);
}
-
-void
-group_update_names(struct screen_ctx *sc)
-{
- char **strings, *p;
- unsigned char *prop_ret;
- int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0;
-
- if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
- cwmh[UTF8_STRING], 0xffffff, (unsigned char **)&prop_ret)) > 0) {
- prop_ret[j - 1] = '\0'; /* paranoia */
- while (i < j) {
- if (prop_ret[i++] == '\0')
- nstrings++;
- }
- }
-
- strings = xcalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
- nstrings), sizeof(*strings));
-
- p = (char *)prop_ret;
- while (n < nstrings) {
- strings[n++] = xstrdup(p);
- p += strlen(p) + 1;
- }
- /*
- * make sure we always set our defaults if nothing is there to
- * replace them.
- */
- if (n < CALMWM_NGROUPS) {
- setnames = 1;
- i = 0;
- while (n < CALMWM_NGROUPS)
- strings[n++] = xstrdup(num_to_name[i++]);
- }
-
- if (prop_ret != NULL)
- XFree(prop_ret);
- if (sc->group_nonames != 0)
- free(sc->group_names);
-
- sc->group_names = strings;
- sc->group_nonames = n;
-
- if (setnames)
- xu_ewmh_net_desktop_names(sc);
-}