when unfocusing a window (e.g. unmanaging) try fallback to transient relations, if that fails, try group relations, then fallback to other window.
This commit is contained in:
parent
9d16ced24e
commit
06663c245a
1 changed files with 39 additions and 23 deletions
|
@ -122,7 +122,8 @@ static gboolean focus_under_pointer()
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finds the first transient that isn't 'skip' */
|
/* finds the first transient that isn't 'skip' and ensure's that client_normal
|
||||||
|
is true for it */
|
||||||
static Client *find_transient_recursive(Client *c, Client *top, Client *skip)
|
static Client *find_transient_recursive(Client *c, Client *top, Client *skip)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
|
@ -132,13 +133,25 @@ static Client *find_transient_recursive(Client *c, Client *top, Client *skip)
|
||||||
g_message("looking");
|
g_message("looking");
|
||||||
if (it->data == top) return NULL;
|
if (it->data == top) return NULL;
|
||||||
ret = find_transient_recursive(it->data, top, skip);
|
ret = find_transient_recursive(it->data, top, skip);
|
||||||
if (ret && ret != skip) return ret;
|
if (ret && ret != skip && client_normal(ret)) return ret;
|
||||||
if (it->data != skip) return it->data;
|
if (it->data != skip && client_normal(it->data)) return it->data;
|
||||||
g_message("not found");
|
g_message("not found");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean focus_fallback_transient(Client *top, Client *old)
|
||||||
|
{
|
||||||
|
Client *target = find_transient_recursive(top, top, old);
|
||||||
|
if (!target) {
|
||||||
|
/* make sure client_normal is true always */
|
||||||
|
if (!client_normal(top))
|
||||||
|
return FALSE;
|
||||||
|
target = top; /* no transient, keep the top */
|
||||||
|
}
|
||||||
|
return client_focus(target);
|
||||||
|
}
|
||||||
|
|
||||||
void focus_fallback(FallbackType type)
|
void focus_fallback(FallbackType type)
|
||||||
{
|
{
|
||||||
GList *it;
|
GList *it;
|
||||||
|
@ -158,29 +171,32 @@ void focus_fallback(FallbackType type)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == Fallback_Unfocusing && old && old->transient_for) {
|
if (type == Fallback_Unfocusing && old) {
|
||||||
Client *c = NULL;
|
/* try for transient relations */
|
||||||
|
if (old->transient_for) {
|
||||||
if (old->transient_for == TRAN_GROUP) {
|
if (old->transient_for == TRAN_GROUP) {
|
||||||
for (it = focus_order[screen_desktop]; it != NULL; it = it->next) {
|
for (it = focus_order[screen_desktop]; it; it = it->next) {
|
||||||
GSList *sit;
|
GSList *sit;
|
||||||
|
|
||||||
for (sit = old->group->members; sit; sit = sit->next)
|
for (sit = old->group->members; sit; sit = sit->next)
|
||||||
if (sit->data == it->data && client_normal(sit->data) &&
|
if (sit->data == it->data)
|
||||||
client_focusable(sit->data)) {
|
if (focus_fallback_transient(sit->data, old))
|
||||||
c = sit->data;
|
return;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (client_normal(old->transient_for))
|
if (focus_fallback_transient(old->transient_for, old))
|
||||||
c = old->transient_for;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c) {
|
/* try for group relations */
|
||||||
Client *t = find_transient_recursive(c, c, old);
|
if (old->group) {
|
||||||
if (!t) t = c; /* no transient, keep the top */
|
GSList *sit;
|
||||||
if (client_focus(t))
|
|
||||||
|
for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
|
||||||
|
for (sit = old->group->members; sit; sit = sit->next)
|
||||||
|
if (sit->data == it->data)
|
||||||
|
if (sit->data != old && client_focus(sit->data))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue