Use the focus history as a fallback

This commit is contained in:
Bastien Dejean 2018-07-17 11:48:21 +02:00
parent 4be63b6485
commit 0c16c1ca65
2 changed files with 20 additions and 5 deletions

View file

@ -61,7 +61,10 @@ bool activate_desktop(monitor_t *m, desktop_t *d)
}
if (d == NULL) {
d = history_last_desktop(m, NULL);
d = m->desk;
if (d == NULL) {
d = history_last_desktop(m, NULL);
}
if (d == NULL) {
d = m->desk_head;
}

View file

@ -441,7 +441,10 @@ void insert_receptacle(monitor_t *m, desktop_t *d, node_t *n)
bool activate_node(monitor_t *m, desktop_t *d, node_t *n)
{
if (n == NULL && d->root != NULL) {
n = history_last_node(d, NULL);
n = d->focus;
if (n == NULL) {
n = history_last_node(d, NULL);
}
if (n == NULL) {
n = first_focusable_leaf(d->root);
}
@ -501,7 +504,10 @@ void transfer_sticky_nodes(monitor_t *m, desktop_t *ds, desktop_t *dd, node_t *n
bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
{
if (m == NULL) {
m = history_last_monitor(NULL);
m = mon;
if (m == NULL) {
m = history_last_monitor(NULL);
}
if (m == NULL) {
m = mon_head;
}
@ -512,7 +518,10 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
}
if (d == NULL) {
d = history_last_desktop(m, NULL);
d = m->desk;
if (d == NULL) {
d = history_last_desktop(m, NULL);
}
if (d == NULL) {
d = m->desk_head;
}
@ -525,7 +534,10 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
bool guess = (n == NULL);
if (n == NULL && d->root != NULL) {
n = history_last_node(d, NULL);
n = d->focus;
if (n == NULL) {
n = history_last_node(d, NULL);
}
if (n == NULL) {
n = first_focusable_leaf(d->root);
}