Hello all,
I've decided to resurrect an old patch of mine which I've had floating
around for a while. I can't remember why I originally wrote this, although
certainly it has a newer usefulness now.
I'm forever seeing questions on IRC and sometimes on the FVWM mailing lists
about how to move specific instances of windows which themselves do not
allow changing of the WM_NAME of WM_CLASS at runtime, hence styling these
windows is often a pain -- especially to differentiate them from one
another.
So, enter TitleFormat, which allows to shove anything as the visible name
for a window, expanding various placeholders along the way -- hence why this
deprecates IndexedWindowName/ExactWindowName and their icon equivalents.
Obviously this isn't a direct solution to the problem, but it means
something like this can happen:
Style SomeUnchangingClassName InitialMapCommand Foo
DestroyFunc Foo
AddToFunc Foo
+ I CountWindows $[w.class]
+ I PipeRead `[[ $[WinNum] -gt 1 ]] && echo DoSomething`
DestroyFunc CountWindows
AddToFunc CountWindows
+ I SetEnv WinNum 0
+ I All (CurrentDesk, !Transient, $0) \
PipeRead `echo SetEnv WinNum $$$$(($$$$WinNum + 1))`
DestroyFunc DoSomething
AddToFunc DoSomething
+ I WindowStyle TitleFormat %n (%c) SPECIAL
+ I MoveToPage foo bar
Feedback on this welcome. It's not really a bug fix per-se, hence why I've
not committed it to CVS.
See patch attached, or if you're using Git, see:
https://github.com/ThomasAdam/fvwm/tree/ta/titleformat
-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.3134
diff -u -p -r1.3134 ChangeLog
--- ChangeLog 12 Nov 2010 13:44:47 -0000 1.3134
+++ ChangeLog 18 Nov 2010 18:52:41 -0000
@@ -1,3 +1,32 @@
+2010-11-18 Thomas Adam <[email protected]>
+ * 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 (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.
+
+ * fvwm/move_resize.c (__resize_step):
+ Call setup_visible_name() to dynamically update the window
+ title when the window is resized -- useful if the window's
+ height and width is ever used as display options for the
+ window's visible name.
+
2010-11-12 Dominik Vogt <dominik(dot)vogt(at)gmx(dot)de>
* fvwm/placement.c (__place_get_placement_flags):
fix reporting of placement reason with nousposition style.
Index: NEWS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/NEWS,v
retrieving revision 1.820
diff -u -p -r1.820 NEWS
--- NEWS 12 Nov 2010 13:44:47 -0000 1.820
+++ NEWS 18 Nov 2010 18:52:41 -0000
@@ -7,6 +7,19 @@ Changes in beta release 2.5.32 (not rele
* 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
+
* Bug fixes:
- Fix width of FvwmTaskBar to fit on screen properly by using
Index: doc/commands/Style.xml
===================================================================
RCS file: /home/cvs/fvwm/fvwm/doc/commands/Style.xml,v
retrieving revision 1.15
diff -u -p -r1.15 Style.xml
--- doc/commands/Style.xml 26 May 2010 07:57:44 -0000 1.15
+++ doc/commands/Style.xml 18 Nov 2010 18:52:42 -0000
@@ -63,7 +63,7 @@ slashes ('/'). The last style in these
<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 @@ without the name argument. These styles
<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 @@ is an integer which represents the
<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.401
diff -u -p -r1.401 add_window.c
--- fvwm/add_window.c 2 Aug 2009 15:04:08 -0000 1.401
+++ fvwm/add_window.c 18 Nov 2010 18:52:44 -0000
@@ -511,10 +511,10 @@ static void setup_name_count(FvwmWindow
titlename = (is_icon) ?
&(fw->icon_name) : &(fw->name);
-
+
title_counterpart = (is_icon) ?
&(fw->name) : &(fw->icon_name);
-
+
if (!titlename->name)
{
done = True;
@@ -540,18 +540,18 @@ static void setup_name_count(FvwmWindow
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,
+ strcmp(titlename->name,
t_titlename->name) == 0 &&
win_count == count) ||
(t_title_counterpart->name &&
- strcmp(t_title_counterpart->name,
+ strcmp(t_title_counterpart->name,
titlename->name) == 0 &&
win_count_counterpart == count))
@@ -561,7 +561,7 @@ static void setup_name_count(FvwmWindow
}
}
}
-
+
if (is_icon)
{
fw->icon_name_count = count;
@@ -572,6 +572,129 @@ static void setup_name_count(FvwmWindow
return;
}
+static char *interpolate_titleformat_name(FvwmWindow *fw, window_style *style,
+ Bool is_icon)
+{
+ char stringbuf[MAX_VISIBLE_NAME_LEN] = "";
+
+ /* 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;
+
+ if (is_icon)
+ {
+ 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;
+ }
+ 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)
{
/* removing NoClass change for now... */
@@ -1575,9 +1698,7 @@ static void __add_window_handle_x_resour
void setup_visible_name(FvwmWindow *fw, Bool is_icon)
{
char *ext_name;
- char *name;
- int count;
- int len;
+ window_style style;
if (fw == NULL)
{
@@ -1585,67 +1706,20 @@ void setup_visible_name(FvwmWindow *fw,
return;
}
- setup_name_count(fw, is_icon);
+ /* 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 &&
- fw->visible_icon_name != fw->icon_name.name &&
- fw->visible_icon_name != fw->name.name &&
- fw->visible_icon_name != NoName)
- {
- free(fw->visible_icon_name);
- fw->visible_icon_name = NULL;
- }
- name = fw->icon_name.name;
- count = fw->icon_name_count;
- }
- else
- {
- if (fw->visible_name != NULL &&
- fw->visible_name != fw->name.name &&
- fw->visible_name != NoName)
- {
- free(fw->visible_name);
- fw->visible_name = NULL;
- }
- name = fw->name.name;
- 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);
+ fw->visible_icon_name = strdup(ext_name);
}
else
{
- ext_name = name;
+ fw->visible_name = strdup(ext_name);
}
- if (is_icon)
- {
- fw->visible_icon_name = ext_name;
- }
- else
- {
- fw->visible_name = ext_name;
- }
+ free(ext_name);
return;
}
Index: fvwm/fvwm.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.h,v
retrieving revision 1.261
diff -u -p -r1.261 fvwm.h
--- fvwm/fvwm.h 2 Aug 2009 15:04:08 -0000 1.261
+++ fvwm/fvwm.h 18 Nov 2010 18:52:44 -0000
@@ -595,6 +595,8 @@ typedef struct style_flags
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
@@ -697,11 +699,15 @@ typedef struct window_style
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/move_resize.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/move_resize.c,v
retrieving revision 1.310
diff -u -p -r1.310 move_resize.c
--- fvwm/move_resize.c 16 Sep 2010 14:19:52 -0000 1.310
+++ fvwm/move_resize.c 18 Nov 2010 18:52:44 -0000
@@ -68,6 +68,7 @@
#include "move_resize.h"
#include "functions.h"
#include "style.h"
+#include "add_window.h"
/* ----- move globals ----- */
@@ -3408,6 +3409,7 @@ static void __resize_step(
}
}
DisplaySize(exc->w.fw, exc->x.elast, drag->width, drag->height, False, False);
+ setup_visible_name((FvwmWindow *)exc->w.fw, FALSE);
return;
}
@@ -3628,6 +3630,7 @@ static Bool __resize_window(F_CMD_ARGS)
XMapRaised(dpy, Scr.SizeWindow);
}
DisplaySize(fw, exc->x.elast, orig->width, orig->height, True, True);
+ setup_visible_name((FvwmWindow *)exc->w.fw, FALSE);
if (dir != DIR_NONE)
{
Index: fvwm/style.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.c,v
retrieving revision 1.264
diff -u -p -r1.264 style.c
--- fvwm/style.c 6 Feb 2010 20:41:06 -0000 1.264
+++ fvwm/style.c 18 Nov 2010 18:52:46 -0000
@@ -71,6 +71,35 @@ static window_style *last_style_in_list
/* ---------------------------- 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 @@ static void merge_styles(
*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 @@ static void free_style(window_style *sty
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 @@ static Bool style_parse_one_style_option
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 @@ static Bool style_parse_one_style_option
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 = NULL;
+ (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 @@ static Bool style_parse_one_style_option
}
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"))
{
@@ -4173,6 +4284,30 @@ static Bool style_parse_one_style_option
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 = NULL;
+ (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_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);
@@ -5075,15 +5210,15 @@ void check_window_style_change(
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.91
diff -u -p -r1.91 style.h
--- fvwm/style.h 2 Aug 2009 15:04:08 -0000 1.91
+++ fvwm/style.h 18 Nov 2010 18:52:46 -0000
@@ -3,6 +3,9 @@
#ifndef _STYLE_
#define _STYLE_
+/* 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) \
@@ -655,6 +658,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.83
diff -u -p -r1.83 defaults.h
--- libs/defaults.h 2 Aug 2009 15:04:08 -0000 1.83
+++ libs/defaults.h 18 Nov 2010 18:52:46 -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 */