Tie group number and name together during config.

This commit is contained in:
okan 2019-03-01 14:32:01 +00:00
parent ef3d45ea45
commit a15d877277
4 changed files with 36 additions and 17 deletions

View File

@ -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.365 2019/02/28 13:11:53 okan Exp $
* $OpenBSD: calmwm.h,v 1.366 2019/03/01 14:32:01 okan Exp $
*/
#ifndef _CALMWM_H_
@ -447,7 +447,7 @@ void group_hide(struct group_ctx *);
void group_hidetoggle(struct screen_ctx *, int);
int group_holds_only_hidden(struct group_ctx *);
int group_holds_only_sticky(struct group_ctx *);
void group_init(struct screen_ctx *, int);
void group_init(struct screen_ctx *, int, const char *);
void group_movetogroup(struct client_ctx *, int);
void group_only(struct screen_ctx *, int);
void group_close(struct screen_ctx *, int);
@ -555,6 +555,7 @@ void conf_grab_mouse(Window);
void conf_init(struct conf *);
void conf_ignore(struct conf *, const char *);
void conf_screen(struct screen_ctx *);
void conf_group(struct screen_ctx *);
void xev_process(void);

View File

@ -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: conf.c,v 1.245 2019/02/25 16:40:49 okan Exp $
* $OpenBSD: conf.c,v 1.246 2019/03/01 14:32:01 okan Exp $
*/
#include <sys/types.h>
@ -36,6 +36,21 @@ static const char *conf_bind_getmask(const char *, unsigned int *);
static void conf_unbind_key(struct conf *, struct bind_ctx *);
static void conf_unbind_mouse(struct conf *, struct bind_ctx *);
static const struct {
int num;
const char *name;
} group_binds[] = {
{ 0, "nogroup" },
{ 1, "one" },
{ 2, "two" },
{ 3, "three" },
{ 4, "four" },
{ 5, "five" },
{ 6, "six" },
{ 7, "seven" },
{ 8, "eight" },
{ 9, "nine" },
};
static int cursor_binds[] = {
XC_left_ptr, /* CF_NORMAL */
XC_fleur, /* CF_MOVE */
@ -266,7 +281,7 @@ conf_init(struct conf *c)
c->bwidth = 1;
c->mamount = 1;
c->snapdist = 0;
c->ngroups = 10;
c->ngroups = 0;
c->nameqlen = 5;
TAILQ_INIT(&c->ignoreq);
@ -502,6 +517,17 @@ conf_screen(struct screen_ctx *sc)
conf_grab_kbd(sc->rootwin);
}
void
conf_group(struct screen_ctx *sc)
{
unsigned int i;
for (i = 0; i < nitems(group_binds); i++) {
group_init(sc, group_binds[i].num, group_binds[i].name);
Conf.ngroups++;
}
}
static const char *
conf_bind_getmask(const char *name, unsigned int *mask)
{

View File

@ -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.132 2019/02/28 23:26:12 okan Exp $
* $OpenBSD: group.c,v 1.133 2019/03/01 14:32:01 okan Exp $
*/
#include <sys/types.h>
@ -37,11 +37,6 @@ static struct group_ctx *group_prev(struct group_ctx *);
static void group_restack(struct group_ctx *);
static void group_setactive(struct group_ctx *);
const char *num_to_name[] = {
"nogroup", "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine"
};
void
group_assign(struct group_ctx *gc, struct client_ctx *cc)
{
@ -124,13 +119,13 @@ group_restack(struct group_ctx *gc)
}
void
group_init(struct screen_ctx *sc, int num)
group_init(struct screen_ctx *sc, int num, const char *name)
{
struct group_ctx *gc;
gc = xmalloc(sizeof(*gc));
gc->sc = sc;
gc->name = xstrdup(num_to_name[num]);
gc->name = xstrdup(name);
gc->num = num;
TAILQ_INIT(&gc->clientq);

View File

@ -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.88 2018/02/13 15:43:16 okan Exp $
* $OpenBSD: screen.c,v 1.89 2019/03/01 14:32:01 okan Exp $
*/
#include <sys/types.h>
@ -40,7 +40,6 @@ screen_init(int which)
Window *wins, w0, w1, active = None;
XSetWindowAttributes rootattr;
unsigned int nwins, w;
int i;
sc = xmalloc(sizeof(*sc));
@ -61,9 +60,7 @@ screen_init(int which)
xu_ewmh_net_supported_wm_check(sc);
screen_update_geometry(sc);
for (i = 0; i < Conf.ngroups; i++)
group_init(sc, i);
conf_group(sc);
xu_ewmh_net_desktop_names(sc);
xu_ewmh_net_wm_desktop_viewport(sc);