X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fsession.c;h=969d2f00d8825c6dee58c9ef8e8d153adec9bfd3;hb=8262e1ba669cb8959734892d2657653766f5cc7e;hp=dcb3fcef2433a891d7b86021b47ba7d3033e1249;hpb=44be67844a5568e8b1ad87327b0815f8667151c0;p=chaz%2Fopenbox diff --git a/openbox/session.c b/openbox/session.c index dcb3fcef..969d2f00 100644 --- a/openbox/session.c +++ b/openbox/session.c @@ -625,6 +625,7 @@ static void session_load_file(const gchar *path) { xmlDocPtr doc; xmlNodePtr node, n; + GList *it, *inext; if (!parse_load(path, "openbox_session", &doc, &node)) return; @@ -702,6 +703,50 @@ static void session_load_file(const gchar *path) session_state_free(state); } + /* Remove any duplicates. This means that if two windows (or more) are + saved with the same session state, we won't restore a session for any + of them because we don't know what window to put what on. AHEM FIREFOX. + + This is going to be an O(2^n) kind of operation unfortunately. + */ + for (it = session_saved_state; it; it = inext) { + GList *jt, *jnext; + gboolean founddup = FALSE; + ObSessionState *s1 = it->data; + + inext = g_list_next(it); + + for (jt = g_list_next(it); jt; jt = jnext) { + ObSessionState *s2 = jt->data; + gboolean match; + + jnext = g_list_next(jt); + + if (s1->id && s2->id) + match = strcmp(s1->id, s2->id) == 0; + else if (s1->command && s2->command) + match = strcmp(s1->command, s2->command) == 0; + else + match = FALSE; + + if (match && + !strcmp(s1->name, s2->name) && + !strcmp(s1->class, s2->class) && + !strcmp(s1->role, s2->role)) + { + session_state_free(s2); + session_saved_state = + g_list_delete_link(session_saved_state, jt); + founddup = TRUE; + } + } + + if (founddup) { + session_state_free(s1); + session_saved_state = g_list_delete_link(session_saved_state, it); + } + } + xmlFreeDoc(doc); }