Don't assume any key ordering when restoring state

Fixes #649.
This commit is contained in:
Bastien Dejean 2017-05-26 10:16:02 +02:00
parent e5cb04df18
commit ae76469130

View file

@ -114,6 +114,7 @@ bool restore_tree(const char *file_path)
jsmntok_t *t = tokens + 1;
uint32_t focused_monitor_id = 0, primary_monitor_id = 0;
jsmntok_t *focus_history_token = NULL, *stacking_list_token = NULL;
for (int i = 0; i < num; i++) {
if (keyeq("focusedMonitorId", t, json)) {
@ -139,10 +140,16 @@ bool restore_tree(const char *file_path)
continue;
} else if (keyeq("focusHistory", t, json)) {
t++;
if (mon == NULL) {
focus_history_token = t;
}
restore_history(&t, json);
continue;
} else if (keyeq("stackingList", t, json)) {
t++;
if (mon == NULL) {
stacking_list_token = t;
}
restore_stack(&t, json);
continue;
}
@ -163,6 +170,14 @@ bool restore_tree(const char *file_path)
}
}
if (focus_history_token != NULL) {
restore_history(&focus_history_token, json);
}
if (stacking_list_token != NULL) {
restore_stack(&stacking_list_token, json);
}
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
refresh_presel_feedbacks(m, d, d->root);