- if (config_title_number) {
-
- /* did the title change? then reset the title_count */
- if (old_title && 0 != strncmp(old_title, data, strlen(data)))
- self->title_count = 1;
-
- /* look for duplicates and append a number */
- nums = 0;
- for (it = client_list; it; it = g_list_next(it))
- if (it->data != self) {
- ObClient *c = it->data;
-
- 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)
- if (!(nums & (1 << i))) {
- if (self->title_count == 1 || i == 1)
- self->title_count = i;
- break;
- }
- /* dont display the number for the first window */
- if (self->title_count > 1) {
- gchar *ndata;
- ndata = g_strdup_printf("%s - [%u]", data, self->title_count);
- g_free(data);
- data = ndata;
- }
- } else
- self->title_count = 1;
-
-no_number: