Parse the title_format and display the customized window title if a format was set.

The format string set with "title_format" can contain the placeholder "%title" which will be replaced with the actual window title.

By not overwriting window->name itself, we make sure that assignment matching still works as expected.

fixes #1723
This commit is contained in:
Ingo Bürk
2015-06-10 19:01:05 +02:00
parent 55e8d06ee4
commit 5a8d66a1d5
6 changed files with 103 additions and 2 deletions

View File

@ -1904,7 +1904,25 @@ void cmd_scratchpad_show(I3_CMD) {
*
*/
void cmd_title_format(I3_CMD, char *format) {
DLOG("setting title_format to %s\n", format);
DLOG("setting title_format to \"%s\"\n", format);
HANDLE_EMPTY_MATCH;
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
if (current->con->window == NULL)
continue;
DLOG("setting title_format for %p / %s\n", current->con, current->con->name);
FREE(current->con->window->title_format);
/* If we only display the title without anything else, we can skip the parsing step,
* so we remove the title format altogether. */
if (strcasecmp(format, "%title") != 0)
current->con->window->title_format = sstrdup(format);
/* Make sure the window title is redrawn immediately. */
current->con->window->name_x_changed = true;
}
cmd_output->needs_tree_render = true;
ysuccess(true);