Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.3074
diff -u -r1.3074 ChangeLog
--- ChangeLog	17 Mar 2009 17:09:15 -0000	1.3074
+++ ChangeLog	11 Jun 2009 19:34:06 -0000
@@ -1,3 +1,43 @@
+Thu Jun 11 00:32:02 BST 2009  Thomas Adam <thomas.adam22@gmail.com>
+	* fvwm/style.c (__validate_titleformat_string):
+	New helper function for validating TitleFormat and IconTitleFormat
+	commands.
+	
+	* fvwm/style.c:
+	* fvwm/style.h:
+	Introduce TitleFormat and IconTitleFormat style commands.  These
+	effectively deprecate:
+
+	IndexedWindowName
+	IndexedIconName
+	ExactWindowName
+	ExactIconName
+
+	* fvwm/add_window.c (setup_name_count):
+	* fvwm/add_window.h:
+	Clean up and amalgamate some common functionality into a single
+	function -- namely the merger of:
+
+	setup_window_name_count
+	setup_icon_name_count
+
+	To the new function:
+
+	setup_name_count
+
+	Since this makes the codepath much cleaner when performing window
+	counting for TitleFormat %t.
+
+	* fvwm/add_window.c (interpolate_titleformat_name):
+	Helper function to interpolate and parse the TitleFormat and
+	IconTitleFormat string.
+
+	* fvwm/add_window.c (setup_visible_name):
+	Make use of:
+
+	interpolate_titleformat_name() for setting the visible name of an icon
+	or window title.
+
 2009-03-17  Mikhael Goikhman  <migo@homemail.com>
 
 	* fvwm/externs.h:
Index: NEWS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/NEWS,v
retrieving revision 1.775
diff -u -r1.775 NEWS
--- NEWS	23 Feb 2009 21:55:14 -0000	1.775
+++ NEWS	11 Jun 2009 19:34:10 -0000
@@ -5,6 +5,21 @@
 
 Changes in beta release 2.5.28 (not released yet)
 
+* New features:
+
+  - New Style commands:
+
+        TitleFormat
+        IconTitleFormat
+
+        Used to specify a window's visible name.  These new options
+        deprecate the older styles:
+
+        IndexedWindowName
+        IndexedIconName
+        ExactWindowName
+        ExactIconName
+        
 -------------------------------------------------------------------
 
 Changes in beta release 2.5.27 (23-Feb-2009)
Index: doc/commands/Style.xml
===================================================================
RCS file: /home/cvs/fvwm/fvwm/doc/commands/Style.xml,v
retrieving revision 1.11
diff -u -r1.11 Style.xml
--- doc/commands/Style.xml	19 Feb 2009 21:06:02 -0000	1.11
+++ doc/commands/Style.xml	11 Jun 2009 19:34:17 -0000
@@ -63,7 +63,7 @@
 <emphasis remap='I'>StippledIconTitle</emphasis> / <emphasis remap='I'>!StippledIconTitle</emphasis>,
 <emphasis remap='I'>IndexedWindowName</emphasis> / <emphasis remap='I'>ExactWindowName</emphasis>,
 <emphasis remap='I'>IndexedIconName</emphasis> / <emphasis remap='I'>ExactIconName</emphasis>,
-<emphasis remap='I'>!Borders</emphasis> / <emphasis remap='I'>Borders</emphasis>,
+<emphasis remap='I'>TitleFormat</emphasis> / <emphasis remap='I'>!Borders</emphasis> / <emphasis remap='I'>Borders</emphasis>,
 <emphasis remap='I'>!Handles</emphasis> / <emphasis remap='I'>Handles</emphasis>,
 <emphasis remap='I'>WindowListSkip</emphasis> / <emphasis remap='I'>WindowListHit</emphasis>,
 <emphasis remap='I'>CirculateSkip</emphasis> / <emphasis remap='I'>CirculateHit</emphasis>,
@@ -617,7 +617,7 @@
 <fvwmref cmd="WindowFont"/> and <fvwmopt cmd="Style" opt="IconFont"/>
 commands.</para>
 
-<para>The
+<para>The deprecated
 <fvwmopt cmd="Style" opt="IndexedWindowName"/>
 style causes fvwm to use window titles in the form</para>
 
@@ -633,17 +633,78 @@
 <emphasis remap='I'>i th</emphasis>
 window with
 <emphasis remap='I'>name</emphasis>
-as window name.
-<fvwmopt cmd="Style" opt="ExactWindowName"/>
-restores the default which is to use the exact window name.
-<fvwmopt cmd="Style" opt="IndexedIconName"/>
+as window name.  This has been replaced with:</para>
+
+<programlisting>
+TitleFormat %n (%t)
+</programlisting>
+
+<para><fvwmopt cmd="Style" opt="ExactWindowName"/>
+restores the default which is to use the exact window name.  Deprecated in
+favour of:</para>
+
+<programlisting>
+    TitleFormat %n
+</programlisting>
+
+<para><fvwmopt cmd="Style" opt="IndexedIconName"/>
 and
 <fvwmopt cmd="Style" opt="ExactIconName"/>
 work the same as
 <emphasis remap='I'>IndexedWindowName</emphasis>
 and
 <emphasis remap='I'>ExactWindowName</emphasis>
-styles but for the icon titles.</para>
+styles but for the icon titles.  Both are deprecated in favour of:</para>
+
+<programlisting>
+IconTitleFormat %n (%t)
+IconTitleFormat %n
+</programlisting>
+
+<para><fvwmopt cmd="Style" opt="TitleFormat"/> describes what the visible
+name of a window should look like, with the following placeholders being
+valid:</para>
+
+<variablelist>
+<varlistentry>
+        <term><emphasis remap='B'>%n</emphasis></term>
+        <listitem><para>Insert the window's name.</para></listitem>
+</varlistentry>
+<varlistentry>
+        <term><emphasis remap='B'>%c</emphasis></term>
+        <listitem><para>Insert the window's class name.</para></listitem>
+</varlistentry>
+<varlistentry>
+        <term><emphasis remap='B'>%r</emphasis></term>
+        <listitem><para>Insert the window's resource name.</para></listitem>
+</varlistentry>
+<varlistentry>
+        <term><emphasis remap='B'>%t</emphasis></term>
+        <listitem><para>Insert the window count.</para></listitem>
+</varlistentry>
+<varlistentry>
+        <term><emphasis remap='B'>%w</emphasis></term>
+        <listitem><para>Insert the window width.</para></listitem>
+</varlistentry>
+<varlistentry>
+        <term><emphasis remap='B'>%h</emphasis></term>
+        <listitem><para>Insert the window height.</para></listitem>
+</varlistentry>
+<varlistentry>
+        <term><emphasis remap='B'>%I</emphasis></term>
+        <listitem><para>Insert the window ID.</para></listitem>
+</varlistentry>
+</variablelist>
+
+<para>Any amount of whitespace may be used, along with other characters to
+    make up the string -- but a valid <fvwmopt cmd="Style" opt="TitleFormat"/>
+    string must contain at least one of the placeholders mentioned.  No
+    quote stripping is performed on the string, so for example the following
+    is printed verbatim:</para>
+
+<programlisting>
+    TitleFormat " %n " -> [%t] ->      [%c]
+</programlisting>
 
 </section>
 
Index: fvwm/add_window.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/add_window.c,v
retrieving revision 1.399
diff -u -r1.399 add_window.c
--- fvwm/add_window.c	8 Feb 2009 11:01:45 -0000	1.399
+++ fvwm/add_window.c	11 Jun 2009 19:34:23 -0000
@@ -499,21 +499,31 @@
 	return;
 }
 
-static void setup_window_name_count(FvwmWindow *fw)
+static void setup_name_count(FvwmWindow *fw, Bool is_icon)
 {
 	FvwmWindow *t;
 	int count = 0;
+	int win_count, win_count_counterpart;
 	Bool done = False;
+	FlocaleNameString *titlename, *title_counterpart, 
+			  *t_titlename, *t_title_counterpart;
 
-	if (!fw->name.name)
+	/* Used for updating. */
+	titlename = (is_icon) ?
+		&(fw->icon_name) : &(fw->name);
+	title_counterpart = (is_icon) ?
+		&(fw->name) : &(fw->icon_name);
+
+	if (!titlename->name)
 	{
 		done = True;
 	}
 
-	if (fw->icon_name.name &&
-	    strcmp(fw->name.name, fw->icon_name.name) == 0)
+	if (titlename->name && title_counterpart->name &&
+	    strcmp(titlename->name, title_counterpart->name) == 0)
 	{
-		count = fw->icon_name_count;
+		count = is_icon ? fw->icon_name_count :
+			fw->name_count;
 	}
 
 	while (!done)
@@ -525,64 +535,164 @@
 			{
 				continue;
 			}
-			if ((t->name.name &&
-			     strcmp(t->name.name, fw->name.name) == 0 &&
-			     t->name_count == count) ||
-			    (t->icon_name.name &&
-			     strcmp(t->icon_name.name, fw->name.name) == 0 &&
-			     t->icon_name_count == count))
+
+			win_count = is_icon ? t->icon_name_count :
+				t->name_count;
+			win_count_counterpart = is_icon ?
+				t->name_count : t->icon_name_count;
+			t_titlename = is_icon ? &(t->icon_name) :
+				&(t->name);
+			t_title_counterpart = is_icon ? &(t->name) :
+				&(t->icon_name);
+
+			if ((t_titlename->name &&
+			     strcmp(titlename->name, 
+				     t_titlename->name) == 0 &&
+			     win_count == count) ||
+			    (t_title_counterpart->name &&
+			     strcmp(t_title_counterpart->name, 
+				     titlename->name) == 0 &&
+			     win_count_counterpart == count))
 			{
 				count++;
 				done = False;
 			}
 		}
 	}
-	fw->name_count = count;
+
+	if (is_icon)
+	{
+		fw->icon_name_count = count;
+	} else {
+		fw->name_count = count;
+	}
 
 	return;
 }
 
-static void setup_icon_name_count(FvwmWindow *fw)
+static char *interpolate_titleformat_name(FvwmWindow *fw, window_style *style, 
+		Bool is_icon)
 {
-	FvwmWindow *t;
-	int count = 0;
-	Bool done = False;
+	char stringbuf[MAX_VISIBLE_NAME_LEN] = "";
 
-	if (!fw->icon_name.name)
-	{
-		done = True;
-	}
-	if (fw->name.name &&
-	    strcmp(fw->name.name, fw->icon_name.name) == 0)
-	{
-		count = fw->name_count;
-	}
+	/* Get the title format string.  This check should be redundant thanks
+	 * to the checking done in style.c
+	 */
+	const char *format;
+	int count;
+	
+	/* MAX_WINDOW_NAME_NUMBER is defined as "999" -- that's three
+	 * characters maximum.
+	 */
+	char win_name_len[MAX_WINDOW_NAME_NUMBER_DIGITS];
+	char width[10], height[10], w_id[12];
+	rectangle g;
 
-	while (!done)
+	if (is_icon)
 	{
-		done = True;
-		for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
-		{
-			if (t == fw)
-			{
-				continue;
-			}
-			if ((t->icon_name.name &&
-			     strcmp(t->icon_name.name,
-				    fw->icon_name.name) == 0 &&
-			     t->icon_name_count == count) ||
-			    (t->name.name &&
-			     strcmp(t->name.name, fw->icon_name.name) == 0 &&
-			     t->name_count == count))
-			{
-				count++;
-				done = False;
-			}
+		format = (style->flags.has_icon_title_format_string) ?
+			SGET_ICON_TITLE_FORMAT_STRING(*style) : 
+			DEFAULT_TITLE_FORMAT;
+	} else {
+		format = (style->flags.has_title_format_string) ?
+			SGET_TITLE_FORMAT_STRING(*style) : 
+			DEFAULT_TITLE_FORMAT;
+	}
+
+	
+	while (*format)
+	{
+		int pos;
+		for (pos = 0; format[pos] && format[pos] != '%'; pos++);
+
+		strncat(stringbuf, format, pos);
+		format += pos;
+
+		if (*format != '%')
+			continue;
+
+		format++;
+		switch (*format)
+		{
+			case 'n':
+				if (strlen(stringbuf) + 
+					strlen(fw->name.name) >
+					MAX_VISIBLE_NAME_LEN)
+				{
+					fvwm_msg(WARN, 
+					"interpolate_titleformat_name",
+					"Visible name is too long based on "
+					"TitleFormat.  Not expanding further.");
+
+					break;
+				}
+
+				strcat(stringbuf, fw->name.name); 
+				break;
+			case 'c':
+				if (strlen(stringbuf) + 
+					strlen(fw->class.res_class) >
+					MAX_VISIBLE_NAME_LEN)
+				{
+					fvwm_msg(WARN, 
+					"interpolate_titleformat_name",
+					"Visible name is too long based on "
+					"TitleFormat.  Not expanding further.");
+					
+					break;
+				}
+				strcat(stringbuf, fw->class.res_class);
+				break;
+			case 'r':
+				if (strlen(stringbuf) + 
+					strlen(fw->class.res_name) >
+					MAX_VISIBLE_NAME_LEN)
+				{
+					fvwm_msg(WARN, 
+					"interpolate_titleformat_name",
+					"Visible name is too long based on "
+					"TitleFormat.  Not expanding further.");
+					
+					break;
+				}
+				strcat(stringbuf, fw->class.res_name);
+				break;
+			case 't':
+				setup_name_count(fw, is_icon);
+				count = is_icon ? fw->icon_name_count :
+					fw->name_count;
+
+				if (count > (MAX_WINDOW_NAME_NUMBER - 1))
+					count = MAX_WINDOW_NAME_NUMBER - 1;
+
+				sprintf(win_name_len, "%d", ++count);
+				strcat(stringbuf, win_name_len);
+				break;
+			case 'w':
+				get_unshaded_geometry(fw, &g);
+				sprintf(width, "%d", g.width);
+				strcat(stringbuf, width);
+				break;
+			case 'h':
+				get_unshaded_geometry(fw, &g);
+				sprintf(height, "%d", g.height);
+				strcat(stringbuf, height);
+				break;
+			case 'I':
+				sprintf(w_id, "0x%x", (int)FW_W(fw));
+				strcat(stringbuf, w_id);
+				break;
+			default:
+				break;
 		}
-	}
-	fw->icon_name_count = count;
 
-	return;
+		if (*format)
+			format++;
+	}
+	/* Now allocate our string. */
+	char *visname = safemalloc(strlen(stringbuf) + 1);
+	strcpy(visname, stringbuf);
+	return visname;
 }
 
 static void setup_class_and_resource(FvwmWindow *fw)
@@ -1588,9 +1698,7 @@
 void setup_visible_name(FvwmWindow *fw, Bool is_icon)
 {
 	char *ext_name;
-	char *name;
-	int count;
-	int len;
+	window_style style;
 
 	if (fw == NULL)
 	{
@@ -1598,6 +1706,11 @@
 		return;
 	}
 
+	/* TA:  Get the window style. */
+	lookup_style(fw, &style);
+	ext_name = interpolate_titleformat_name(fw, &style, is_icon);
+	
+	
 	if (is_icon)
 	{
 		if (fw->visible_icon_name != NULL &&
@@ -1608,9 +1721,7 @@
 			free(fw->visible_icon_name);
 			fw->visible_icon_name = NULL;
 		}
-		name = fw->icon_name.name;
-		setup_icon_name_count(fw);
-		count = fw->icon_name_count;
+		fw->visible_icon_name = ext_name;
 	}
 	else
 	{
@@ -1621,42 +1732,6 @@
 			free(fw->visible_name);
 			fw->visible_name = NULL;
 		}
-		name = fw->name.name;
-		setup_window_name_count(fw);
-		count = fw->name_count;
-	}
-
-	if (name == NULL)
-	{
-		return; /* should never happen */
-	}
-
-	if (count > MAX_WINDOW_NAME_NUMBER - 1)
-	{
-		count = MAX_WINDOW_NAME_NUMBER - 1;
-	}
-
-	if (count != 0 &&
-	    ((is_icon && USE_INDEXED_ICON_NAME(fw)) ||
-	     (!is_icon && USE_INDEXED_WINDOW_NAME(fw))))
-	{
-		len = strlen(name);
-		count++;
-		ext_name = (char *)safemalloc(
-			len + MAX_WINDOW_NAME_NUMBER_DIGITS + 4);
-		sprintf(ext_name,"%s (%d)", name, count);
-	}
-	else
-	{
-		ext_name = name;
-	}
-
-	if (is_icon)
-	{
-		fw->visible_icon_name = ext_name;
-	}
-	else
-	{
 		fw->visible_name = ext_name;
 	}
 
Index: fvwm/fvwm.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.h,v
retrieving revision 1.260
diff -u -r1.260 fvwm.h
--- fvwm/fvwm.h	8 Feb 2009 11:01:45 -0000	1.260
+++ fvwm/fvwm.h	11 Jun 2009 19:34:25 -0000
@@ -595,6 +595,8 @@
 	unsigned has_placement_percentage_penalty : 1;
 	unsigned has_placement_position_string : 1;
 	unsigned has_initial_map_command_string : 1;
+	unsigned has_title_format_string : 1;
+	unsigned has_icon_title_format_string : 1;
 } style_flags;
 
 typedef struct style_id_t
@@ -681,11 +683,15 @@
 	pl_percent_penalty_struct pl_percent_penalty;
 	char *pl_position_string;
 	char *initial_map_command_string;
+	char *title_format_string;
+	char *icon_title_format_string;
 	style_flags flags;
 	style_flags flag_default;
 	style_flags flag_mask;
 	style_flags change_mask;
 	unsigned has_style_changed : 1;
+	unsigned has_title_format_string : 1;
+	unsigned has_icon_title_format_string : 1;
 } window_style;
 
 typedef struct window_g
Index: fvwm/style.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.c,v
retrieving revision 1.261
diff -u -r1.261 style.c
--- fvwm/style.c	8 Feb 2009 11:01:45 -0000	1.261
+++ fvwm/style.c	11 Jun 2009 19:34:33 -0000
@@ -71,6 +71,35 @@
 
 /* ---------------------------- local functions ---------------------------- */
 
+static Bool __validate_titleformat_string(const char *formatstr)
+{
+	const char *fmt;
+	Bool ret_condition = False;
+	
+	for (fmt = formatstr; *fmt; fmt++)
+	{
+		if (*fmt != '%')
+			continue;
+
+		switch (*++fmt)
+		{
+			case 'n':
+			case 'r':
+			case 'c':
+			case 't':
+			case 'h':
+			case 'w':
+			case 'I':
+				ret_condition = True;
+				break;
+			default:
+				ret_condition = False;
+				break;
+		}
+	}
+	return ret_condition;
+}
+
 static int blockor(char *dest, char *blk1, char *blk2, int length)
 {
 	int i;
@@ -713,6 +742,20 @@
 			*merged_style,
 			strdup(SGET_INITIAL_MAP_COMMAND_STRING(*add_style)));
 	}
+
+	if (add_style->flags.has_title_format_string)
+	{
+		SAFEFREE(SGET_TITLE_FORMAT_STRING(*merged_style));
+		SSET_TITLE_FORMAT_STRING(*merged_style,
+				strdup(SGET_TITLE_FORMAT_STRING(*add_style)));
+	}
+
+	if (add_style->flags.has_icon_title_format_string)
+	{
+		SAFEFREE(SGET_ICON_TITLE_FORMAT_STRING(*merged_style));
+		SSET_ICON_TITLE_FORMAT_STRING(*merged_style,
+				strdup(SGET_ICON_TITLE_FORMAT_STRING(*add_style)));
+	}
 	/* merge the style flags */
 
 	/*** ATTENTION:
@@ -769,6 +812,8 @@
 	remove_icon_boxes_from_style(style);
 	SAFEFREE(SGET_PLACEMENT_POSITION_STRING(*style));
 	SAFEFREE(SGET_INITIAL_MAP_COMMAND_STRING(*style));
+	SAFEFREE(SGET_TITLE_FORMAT_STRING(*style));
+	SAFEFREE(SGET_ICON_TITLE_FORMAT_STRING(*style));
 
 	return;
 }
@@ -2479,15 +2524,35 @@
 	case 'e':
 		if (StrEquals(token, "ExactWindowName"))
 		{
-			S_SET_USE_INDEXED_WINDOW_NAME(SCF(*ps), !on);
-			S_SET_USE_INDEXED_WINDOW_NAME(SCM(*ps), 1);
-			S_SET_USE_INDEXED_WINDOW_NAME(SCC(*ps), 1);
+			/* TA:  This is being deprecated in favour of the more
+			 * generic:
+			 *
+			 * TitleFormat %n
+			 */
+			fvwm_msg(WARN, "style_parse_one_style_option",
+				"ExactWindowName is deprecated -- using"
+				" TitleFormat %%n");
+			char *format = strdup(DEFAULT_TITLE_FORMAT);
+			SSET_TITLE_FORMAT_STRING(*ps, format);
+			ps->flags.has_title_format_string = 1;
+			ps->flag_mask.has_title_format_string = 1;
+			ps->change_mask.has_title_format_string = 1;
 		}
 		else if (StrEquals(token, "ExactIconName"))
 		{
-			S_SET_USE_INDEXED_ICON_NAME(SCF(*ps), !on);
-			S_SET_USE_INDEXED_ICON_NAME(SCM(*ps), 1);
-			S_SET_USE_INDEXED_ICON_NAME(SCC(*ps), 1);
+			/* TA:  This is being deprecated in favour of the more
+			 * generic:
+			 *
+			 * IconTitleFormat %n
+			 */
+			fvwm_msg(WARN, "style_parse_one_style_option",
+				"ExactIconName is deprecated -- using"
+				" IconTitleFormat %%n");
+			char *format = strdup(DEFAULT_TITLE_FORMAT);
+			SSET_ICON_TITLE_FORMAT_STRING(*ps, format);
+			ps->flags.has_icon_title_format_string = 1;
+			ps->flag_mask.has_icon_title_format_string = 1;
+			ps->change_mask.has_icon_title_format_string = 1;
 		}
 		else if (StrEquals(token, "EdgeMoveResistance"))
 		{
@@ -2914,6 +2979,30 @@
 			S_SET_HAS_NO_ICON_TITLE(SCM(*ps), 1);
 			S_SET_HAS_NO_ICON_TITLE(SCC(*ps), 1);
 		}
+		else if (StrEquals(token, "IconTitleFormat"))
+		{
+			char *fmt_string;
+			(rest != NULL) ? fmt_string = strdup(rest) : NULL;
+			rest = NULL; /* Consume the string. */
+
+			if (fmt_string == NULL)
+			{
+				fmt_string = DEFAULT_TITLE_FORMAT;
+			}
+
+			if (!__validate_titleformat_string(fmt_string))
+			{
+				fvwm_msg(ERR, "style_parse_one_style_option",
+					"TitleFormat string invalid:  %s",
+					fmt_string);
+			}
+
+			SSET_ICON_TITLE_FORMAT_STRING(*ps, fmt_string);
+			ps->flags.has_icon_title_format_string = 1;
+			ps->flag_mask.has_icon_title_format_string = 1;
+			ps->change_mask.has_icon_title_format_string = 1;
+
+		}
 		else if (StrEquals(token, "IconTitleColorset"))
 		{
 			*val = -1;
@@ -2980,15 +3069,37 @@
 		}
 		else if (StrEquals(token, "IndexedWindowName"))
 		{
-			S_SET_USE_INDEXED_WINDOW_NAME(SCF(*ps), on);
-			S_SET_USE_INDEXED_WINDOW_NAME(SCM(*ps), 1);
-			S_SET_USE_INDEXED_WINDOW_NAME(SCC(*ps), 1);
+			/* TA:  This is being deprecated in favour of the more
+			 * generic:
+			 *
+			 * TitleFormat %n
+			 */
+			fvwm_msg(WARN, "style_parse_one_style_option",
+				"IndexedWindowName is deprecated.  "
+				"Converting to use:  TitleFormat %%n (%%t)");
+			char *format = strdup( "%n (%t)" );
+
+			SSET_TITLE_FORMAT_STRING(*ps, format);
+			ps->flags.has_title_format_string = 1;
+			ps->flag_mask.has_title_format_string = 1;
+			ps->change_mask.has_title_format_string = 1;
 		}
 		else if (StrEquals(token, "IndexedIconName"))
 		{
-			S_SET_USE_INDEXED_ICON_NAME(SCF(*ps), on);
-			S_SET_USE_INDEXED_ICON_NAME(SCM(*ps), 1);
-			S_SET_USE_INDEXED_ICON_NAME(SCC(*ps), 1);
+			/* TA:  This is being deprecated in favour of the more
+			 * generic:
+			 *
+			 * TitleFormat %n
+			 */
+			fvwm_msg(WARN, "style_parse_one_style_option",
+				"IndexedIconName is deprecated.  "
+				"Converting to use:  IconTitleFormat %%n (%%t)");
+			char *format = strdup( "%n (%t)" );
+
+			SSET_ICON_TITLE_FORMAT_STRING(*ps, format);
+			ps->flags.has_icon_title_format_string = 1;
+			ps->flag_mask.has_icon_title_format_string = 1;
+			ps->change_mask.has_icon_title_format_string = 1;
 		}
 		else if (StrEquals(token, "InitialMapCommand"))
 		{
@@ -4156,6 +4267,33 @@
 			S_SET_TITLE_DIR(SCM(*ps), DIR_MAJOR_MASK);
 			S_SET_TITLE_DIR(SCC(*ps), DIR_MAJOR_MASK);
 		}
+		else if (StrEquals(token, "TitleFormat"))
+		{
+			char *fmt_string;
+			(rest != NULL) ? fmt_string = strdup(rest) : NULL;
+			rest = NULL; /* Consume the string. */
+
+			fvwm_msg(INFO, "style_parse", "s is:  %s",
+					fmt_string);
+
+			if (fmt_string == NULL)
+			{
+				fmt_string = DEFAULT_TITLE_FORMAT;
+			}
+
+			if (!__validate_titleformat_string(fmt_string))
+			{
+				fvwm_msg(ERR, "style_parse_one_style_option",
+					"TitleFormat string invalid:  %s",
+					fmt_string);
+			}
+
+			SSET_TITLE_FORMAT_STRING(*ps, fmt_string);
+			ps->flags.has_title_format_string = 1;
+			ps->flag_mask.has_title_format_string = 1;
+			ps->change_mask.has_title_format_string = 1;
+
+		}
 		else if (StrEquals(token, "TopTitleRotated"))
 		{
 			S_SET_IS_TOP_TITLE_ROTATED(SCF(*ps), on);
@@ -5053,15 +5191,15 @@
 		flags->do_update_ewmh_stacking_hints = 1;
 	}
 
-	/*  use_indexed_window_name */
-	if (S_USE_INDEXED_WINDOW_NAME(SCC(*ret_style)))
+	/* has_title_format_string */
+	if (ret_style->change_mask.has_title_format_string)
 	{
 		flags->do_update_visible_window_name = 1;
 		flags->do_redecorate = 1;
 	}
-
-	/*  use_indexed_icon_name */
-	if (S_USE_INDEXED_ICON_NAME(SCC(*ret_style)))
+	
+	/* has_icon_title_format_string */
+	if (ret_style->change_mask.has_icon_title_format_string)
 	{
 		flags->do_update_visible_icon_name = 1;
 		flags->do_update_icon_title = 1;
Index: fvwm/style.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.h,v
retrieving revision 1.90
diff -u -r1.90 style.h
--- fvwm/style.h	8 Feb 2009 11:01:45 -0000	1.90
+++ fvwm/style.h	11 Jun 2009 19:34:33 -0000
@@ -9,6 +9,9 @@
 #define SNAP_SAME    0x04
 #define SNAP_SCREEN  0x08
 
+/* The default title in case the user doesn't supply one. */
+#define DEFAULT_TITLE_FORMAT "%n"
+
 /* access to the special flags of a style */
 /* call these with a pointer to a style_flags struct */
 #define SDO_DECORATE_TRANSIENT(sf) \
@@ -661,6 +664,14 @@
 	((s).initial_map_command_string)
 #define SSET_INITIAL_MAP_COMMAND_STRING(s,x)	\
 	((s).initial_map_command_string = (x))
+#define SGET_TITLE_FORMAT_STRING(s) \
+	((s).title_format_string)
+#define SSET_TITLE_FORMAT_STRING(s,x) \
+	((s).title_format_string = (x))
+#define SGET_ICON_TITLE_FORMAT_STRING(s) \
+	((s).icon_title_format_string)
+#define SSET_ICON_TITLE_FORMAT_STRING(s,x) \
+	((s).icon_title_format_string = (x))
 
 /* function prototypes */
 void lookup_style(FvwmWindow *fw, window_style *styles);
Index: libs/defaults.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/defaults.h,v
retrieving revision 1.82
diff -u -r1.82 defaults.h
--- libs/defaults.h	14 Mar 2008 17:22:42 -0000	1.82
+++ libs/defaults.h	11 Jun 2009 19:34:34 -0000
@@ -317,6 +317,9 @@
 #define MAX_RESOURCE_LEN                 200 /* characters */
 #define MAX_CLASS_LEN                    200 /* characters */
 
+/* Set the maximum size a visible name can be. */
+#define MAX_VISIBLE_NAME_LEN		4096
+
 /*** numbered window names ***/
 #define MAX_WINDOW_NAME_NUMBER           999
 #define MAX_WINDOW_NAME_NUMBER_DIGITS      3 /* number/digits of above number */
