summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-03-04 07:54:21 +0000
committerDana Jansens <danakj@orodu.net>2007-03-04 07:54:21 +0000
commitc07095acb79d715caf86ac6af3c3cc6414d38b81 (patch)
treea3647af0267d401c9ff2207c72208acddb2afeb2
parent17b2d57717504e2018d3ba23e0deffe55fc6d084 (diff)
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!
-rw-r--r--openbox/client.c25
1 files changed, 18 insertions, 7 deletions
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);