I don't know if there's a reason why strncmp() is used on window titles when
trying to determine if a number should be append to the title (eg, xterm - [2]).
Maybe there's some special case you are trying to catch, or a general
"<application name>: something" match?
If I have a program, 'yadda', source is yadda.c... When editing yadda.c with
vim, the xterm title is changed to "yadda.c (~) - VIM". If you then run 'yadda',
the window is titled 'yadda - [2]'. Looks strange, was hunting around to see if
there was another copy running.
Perhaps it would be better to use strcmp() instead?
This is a feature I don't mind, but have very little interest in. Seems like
alotta work for something so trivial. Check the old title, check against every
window in the client list, then g_strdup_printf(), etc, etc...
If i didn't use strncmp then i'd be comparing window titles including the numbers :)
I guess to do it right youd have to store the title without the number and use strcmp
on it. but then apply the number when setting the text properties. Feel free if it
bothers ya :)
ah duh heh.. that hadn't even occurred to me.
Well, how about something like..
/* 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 (0 == strncmp(c->title, data, strlen(c->title) - 7 /* - [32] */))
nums |= 1 << c->title_count;
Compare the other client title strings against the current window, minus (at
most) ' - [32]'. This isn't that great, but it would be better...
Also, setting the dupe window and icon titles are done a bit differently...
if (self->title_count > 1) {
gchar *ndata;
ndata = g_strdup_printf("%s - [%u]", data, self->title_count);
g_free(data);
data = ndata;
}
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);
g_free(data);
data = vdata;
}
Could probably just set the icon title the same way as the window title, without
the extra g_strconcat() call.
Created attachment 133[details]
patch v1
Without changing too much, you could do a g_strrstr(title, " - ["), truncate
the string, then strcmp(). The length of the remainder is checked to make sure
it's either 6 ( - [2]) or 7 ( - [32]) characters in length... Trying to be
somewhat smart about which window titles to fiddle with, in case one would have
such a string in the window title but it's not actually openbox assigned.
Dunno if you had other ideas, but it's really starting to bother me now. Not
because I'm seeing the problem as explained before, but just b/c I know it's
there and it can be improved. :)
Thoughts?
Hm, dunno..
Inside client_update_title() I tried setting self->title = <title_with_number>
before calling frame_adjust_title(), then back to <title_without_number>, but
when the window loses focus framerender_label() must be called again, as it
loses the numbered title. Guess I don't understand what you are saying...
You could store the unchanged window title in self->title_orig or such, strcmp()
that, or perhaps adjust the title string inside framerender_label()?
Could store them both, or could possibly provide
char* client_get_title (ObClient *c);
which would take the title in the struct and add any numbers etc to it and
return a new string, then make the frame and the property stuff use it (and
g_free it after its done).
Also, storing 2 strings in the struct is an option. As you can see I tried to
avoid that one but its a little hacky now.
Created attachment 133 [details] patch v1 Without changing too much, you could do a g_strrstr(title, " - ["), truncate the string, then strcmp(). The length of the remainder is checked to make sure it's either 6 ( - [2]) or 7 ( - [32]) characters in length... Trying to be somewhat smart about which window titles to fiddle with, in case one would have such a string in the window title but it's not actually openbox assigned. Dunno if you had other ideas, but it's really starting to bother me now. Not because I'm seeing the problem as explained before, but just b/c I know it's there and it can be improved. :) Thoughts?