mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Split out sticky mode checks and the restoring of a client's group and
_NET_WM_DESKTOP from the config-based auto-grouping; no (intentional) behavior changes. Needed for further work in cleaning up this area.
This commit is contained in:
parent
dcfbc9e809
commit
96262a6b0c
4
calmwm.h
4
calmwm.h
@ -426,7 +426,8 @@ void client_warp(struct client_ctx *);
|
|||||||
void client_wm_hints(struct client_ctx *);
|
void client_wm_hints(struct client_ctx *);
|
||||||
|
|
||||||
void group_alltoggle(struct screen_ctx *);
|
void group_alltoggle(struct screen_ctx *);
|
||||||
void group_autogroup(struct client_ctx *);
|
void group_assign(struct group_ctx *, struct client_ctx *);
|
||||||
|
int group_autogroup(struct client_ctx *);
|
||||||
void group_cycle(struct screen_ctx *, int);
|
void group_cycle(struct screen_ctx *, int);
|
||||||
void group_hide(struct group_ctx *);
|
void group_hide(struct group_ctx *);
|
||||||
void group_hidetoggle(struct screen_ctx *, int);
|
void group_hidetoggle(struct screen_ctx *, int);
|
||||||
@ -435,6 +436,7 @@ int group_holds_only_sticky(struct group_ctx *);
|
|||||||
void group_init(struct screen_ctx *, int);
|
void group_init(struct screen_ctx *, int);
|
||||||
void group_movetogroup(struct client_ctx *, int);
|
void group_movetogroup(struct client_ctx *, int);
|
||||||
void group_only(struct screen_ctx *, int);
|
void group_only(struct screen_ctx *, int);
|
||||||
|
int group_restore(struct client_ctx *);
|
||||||
void group_show(struct group_ctx *);
|
void group_show(struct group_ctx *);
|
||||||
void group_toggle_membership_enter(struct client_ctx *);
|
void group_toggle_membership_enter(struct client_ctx *);
|
||||||
void group_toggle_membership_leave(struct client_ctx *);
|
void group_toggle_membership_leave(struct client_ctx *);
|
||||||
|
14
client.c
14
client.c
@ -120,9 +120,17 @@ client_init(Window win, struct screen_ctx *sc)
|
|||||||
else
|
else
|
||||||
client_unhide(cc);
|
client_unhide(cc);
|
||||||
|
|
||||||
if (mapped)
|
if (mapped) {
|
||||||
group_autogroup(cc);
|
if (group_restore(cc))
|
||||||
|
goto out;
|
||||||
|
if (group_autogroup(cc))
|
||||||
|
goto out;
|
||||||
|
if (Conf.flags & CONF_STICKY_GROUPS)
|
||||||
|
group_assign(sc->group_active, cc);
|
||||||
|
else
|
||||||
|
group_assign(NULL, cc);
|
||||||
|
}
|
||||||
|
out:
|
||||||
XSync(X_Dpy, False);
|
XSync(X_Dpy, False);
|
||||||
XUngrabServer(X_Dpy);
|
XUngrabServer(X_Dpy);
|
||||||
|
|
||||||
|
75
group.c
75
group.c
@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
static struct group_ctx *group_next(struct group_ctx *);
|
static struct group_ctx *group_next(struct group_ctx *);
|
||||||
static struct group_ctx *group_prev(struct group_ctx *);
|
static struct group_ctx *group_prev(struct group_ctx *);
|
||||||
static void group_assign(struct group_ctx *, struct client_ctx *);
|
|
||||||
static void group_restack(struct group_ctx *);
|
static void group_restack(struct group_ctx *);
|
||||||
static void group_setactive(struct group_ctx *);
|
static void group_setactive(struct group_ctx *);
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ const char *num_to_name[] = {
|
|||||||
"seven", "eight", "nine"
|
"seven", "eight", "nine"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
void
|
||||||
group_assign(struct group_ctx *gc, struct client_ctx *cc)
|
group_assign(struct group_ctx *gc, struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
if (cc->group != NULL)
|
if (cc->group != NULL)
|
||||||
@ -324,51 +323,65 @@ group_alltoggle(struct screen_ctx *sc)
|
|||||||
sc->hideall = !sc->hideall;
|
sc->hideall = !sc->hideall;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
|
group_restore(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = cc->sc;
|
||||||
|
struct group_ctx *gc;
|
||||||
|
int num = -1;
|
||||||
|
long *grpnum;
|
||||||
|
|
||||||
|
if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP], XA_CARDINAL, 1L,
|
||||||
|
(unsigned char **)&grpnum) <= 0)
|
||||||
|
return(0);
|
||||||
|
|
||||||
|
num = MIN(*grpnum, (CALMWM_NGROUPS - 1));
|
||||||
|
XFree(grpnum);
|
||||||
|
|
||||||
|
if ((num == -1) || (num == 0)) {
|
||||||
|
group_assign(NULL, cc);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||||
|
if (gc->num == num) {
|
||||||
|
group_assign(gc, cc);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
group_autogroup(struct client_ctx *cc)
|
group_autogroup(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct autogroupwin *aw;
|
struct autogroupwin *aw;
|
||||||
struct group_ctx *gc;
|
struct group_ctx *gc;
|
||||||
int num = -2, both_match = 0;
|
int num = -1, both_match = 0;
|
||||||
long *grpnum;
|
|
||||||
|
|
||||||
if (cc->ch.res_class == NULL || cc->ch.res_name == NULL)
|
if (cc->ch.res_class == NULL || cc->ch.res_name == NULL)
|
||||||
return;
|
return(0);
|
||||||
|
|
||||||
if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP],
|
TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
|
||||||
XA_CARDINAL, 1, (unsigned char **)&grpnum) > 0) {
|
if (strcmp(aw->class, cc->ch.res_class) == 0) {
|
||||||
num = *grpnum;
|
if ((aw->name != NULL) &&
|
||||||
if (num > CALMWM_NGROUPS || num < -1)
|
(strcmp(aw->name, cc->ch.res_name) == 0)) {
|
||||||
num = CALMWM_NGROUPS - 1;
|
num = aw->num;
|
||||||
XFree(grpnum);
|
both_match = 1;
|
||||||
} else {
|
} else if (aw->name == NULL && !both_match)
|
||||||
TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
|
num = aw->num;
|
||||||
if (strcmp(aw->class, cc->ch.res_class) == 0) {
|
|
||||||
if ((aw->name != NULL) &&
|
|
||||||
(strcmp(aw->name, cc->ch.res_name) == 0)) {
|
|
||||||
num = aw->num;
|
|
||||||
both_match = 1;
|
|
||||||
} else if (aw->name == NULL && !both_match)
|
|
||||||
num = aw->num;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((num == -1) || (num == 0)) {
|
if (num == 0) {
|
||||||
group_assign(NULL, cc);
|
group_assign(NULL, cc);
|
||||||
return;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||||
if (gc->num == num) {
|
if (gc->num == num) {
|
||||||
group_assign(gc, cc);
|
group_assign(gc, cc);
|
||||||
return;
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return(0);
|
||||||
if (Conf.flags & CONF_STICKY_GROUPS)
|
|
||||||
group_assign(sc->group_active, cc);
|
|
||||||
else
|
|
||||||
group_assign(NULL, cc);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user