From: Dana Jansens Date: Sun, 4 Mar 2007 07:54:21 +0000 (+0000) Subject: better string matching for duplicate title numbering. this will check against the... X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=c07095acb79d715caf86ac6af3c3cc6414d38b81;p=chaz%2Fopenbox better string matching for duplicate title numbering. this will check against the whole window's title. it used to check less than the full length sometimes. thanks to logan for patches and ideas! --- diff --git a/openbox/client.c b/openbox/client.c index bb0772d7..797d5b85 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1577,8 +1577,21 @@ void client_update_title(ObClient *self) for (it = client_list; it; it = g_list_next(it)) if (it->data != self) { ObClient *c = it->data; - if (0 == strncmp(c->title, data, strlen(data))) - nums |= 1 << c->title_count; + + if (c->title_count == 1) { + if (!strcmp(c->title, data)) + nums |= 1 << c->title_count; + } else { + size_t len; + gchar *end; + + /* find the beginning of our " - [%u]", this relies on + that syntax being used */ + end = strrchr(c->title, '-') - 1; + len = end - c->title; + if (!strncmp(c->title, data, len)) + nums |= 1 << c->title_count; + } } /* find first free number */ for (i = 1; i <= 32; ++i) @@ -1624,12 +1637,10 @@ no_number: * We don't need to check for config_title_number here since title_count * is not set above 1 then. */ if (read_title && self->title_count > 1) { - gchar *vdata, *ndata; - ndata = g_strdup_printf(" - [%u]", self->title_count); - vdata = g_strconcat(data, ndata, NULL); - g_free(ndata); + gchar *newdata; + newdata = g_strdup_printf("%s - [%u]", data, self->title_count); g_free(data); - data = vdata; + data = newdata; } PROP_SETS(self->window, net_wm_visible_icon_name, data);