On Fri, 7 Mar 2008 00:44:09 +0100
Jesús Guerrero <[EMAIL PROTECTED]> wrote:
Attached: Style InactiveFont patch
--
Jesús Guerrero <[EMAIL PROTECTED]>
diff -r -U3 fvwm/ChangeLog fvwm/ChangeLog
--- fvwm/ChangeLog 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/ChangeLog 2008-03-07 06:07:12.000000000 +0100
@@ -27,6 +27,17 @@
*fvwm/builtins.c
patched for ButtonWidth
+ *fvwm/doc/commands/Style.xml
+ added documentation for Style InactiveFont
+
+ *fvwm/style.c
+ *fvwm/style.h
+ *fvwm/fvwm.h
+ *fvwm/add_window.c
+ *fvwm/window_flags.h
+ *fvwm/borders.c
+ patched to add new Style: InactiveFont
+
2008-02-29 Viktor Griph <griph(at)dd(dot)chalmers(dot)se>
* fvwm/add_window.c (setup_frame_window):
diff -r -U3 fvwm/doc/commands/Style.xml fvwm/doc/commands/Style.xml
--- fvwm/doc/commands/Style.xml 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/doc/commands/Style.xml 2008-03-07 06:04:49.000000000 +0100
@@ -84,6 +84,7 @@
<emphasis remap='I'>IconBackgroundColorset</emphasis>,
<emphasis remap='I'>IconTitleRelief</emphasis>, <emphasis remap='I'>IconBackgroundRelief</emphasis>, <emphasis remap='I'>IconBackgroundPadding</emphasis>,
<emphasis remap='I'>Font</emphasis>,
+<emphasis remap='I'>InactiveFont</emphasis>,
<emphasis remap='I'>IconFont</emphasis>,
<emphasis remap='I'>StartsOnDesk</emphasis> / <emphasis remap='I'>StartsOnPage</emphasis> / <emphasis remap='I'>StartsAnyWhere</emphasis>,
<emphasis remap='I'>StartsOnScreen</emphasis>,
@@ -606,13 +607,14 @@
and it is restored if the argument is omitted.</para>
<para>The
-<fvwmopt cmd="Style" opt="Font"/> and <fvwmopt cmd="Style" opt="IconFont"/>
+<fvwmopt cmd="Style" opt="Font"/>, <fvwmopt cmd="Style" opt="InactiveFont"/>
+and <fvwmopt cmd="Style" opt="IconFont"/>
options take the name of a font as their sole argument. This font
-is used in the window or icon title. By default the font given in
-the
+is used in the active window, inactive window or icon title respectively.
+By default the font given in the
<fvwmref cmd="DefaultFont"/>
command is used. To revert back to the default, use the style
-without the name argument. These styles replace the older
+without the name argument. The first two styles replace the older
<fvwmref cmd="WindowFont"/> and <fvwmopt cmd="Style" opt="IconFont"/>
commands.</para>
diff -r -U3 fvwm/fvwm/add_window.c fvwm/fvwm/add_window.c
--- fvwm/fvwm/add_window.c 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/fvwm/add_window.c 2008-03-07 05:58:46.000000000 +0100
@@ -638,6 +638,18 @@
fw->title_font = Scr.DefaultFont;
SET_USING_DEFAULT_WINDOW_FONT(fw, 1);
+ if (IS_INACTIVE_WINDOW_FONT_LOADED(fw) && !USING_DEFAULT_INACTIVE_WINDOW_FONT(fw) &&
+ fw->title_font != Scr.DefaultFont)
+ {
+ FlocaleUnloadFont(dpy, fw->title_font);
+ }
+ SET_INACTIVE_WINDOW_FONT_LOADED(fw, 0);
+ /* Fall back to default font. There are some race conditions when a
+ * window is destroyed and recaptured where an invalid font might be
+ * accessed otherwise. */
+ fw->title_font = Scr.DefaultFont;
+ SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw, 1);
+
return;
}
@@ -1735,6 +1747,25 @@
}
SET_WINDOW_FONT_LOADED(fw, 1);
}
+ /* load inactive font */
+ if (!IS_INACTIVE_WINDOW_FONT_LOADED(fw))
+ {
+ if (S_HAS_INACTIVE_WINDOW_FONT(SCF(*pstyle)) &&
+ SGET_INACTIVE_WINDOW_FONT(*pstyle) &&
+ (fw->inactive_title_font =
+ FlocaleLoadFont(dpy, SGET_INACTIVE_WINDOW_FONT(*pstyle), "FVWM")))
+ {
+ SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw, 0);
+ }
+ else
+ {
+ /* no explicit font or failed to load, use active title font
+ * instead */
+ fw->inactive_title_font = fw->title_font;
+ SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw, 1);
+ }
+ SET_INACTIVE_WINDOW_FONT_LOADED(fw, 1);
+ }
setup_title_geometry(fw, pstyle);
return;
diff -r -U3 fvwm/fvwm/borders.c fvwm/fvwm/borders.c
--- fvwm/fvwm/borders.c 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/fvwm/borders.c 2008-03-07 05:58:46.000000000 +0100
@@ -3525,7 +3525,7 @@
static void border_draw_title_mono(
FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd,
- FlocaleWinString *fstr, Pixmap dest_pix)
+ FlocaleWinString *fstr, Pixmap dest_pix, Bool do_hilight)
{
int has_vt;
@@ -3535,7 +3535,8 @@
td->offset - 2, 0, td->length+4, fw->title_thickness);
if (fw->visible_name != (char *)NULL)
{
- FlocaleDrawString(dpy, fw->title_font, fstr, 0);
+ FlocaleDrawString(dpy, do_hilight ? fw->title_font :
+ fw->inactive_title_font, fstr, 0);
}
/* for mono, we clear an area in the title bar where the window
* title goes, so that its more legible. For color, no need */
@@ -3599,7 +3600,7 @@
static void border_draw_title_deep(
FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd,
- FlocaleWinString *fstr, Pixmap dest_pix, Window w)
+ FlocaleWinString *fstr, Pixmap dest_pix, Window w, Bool do_hilight)
{
DecorFace *df;
pixmap_background_type bg;
@@ -3621,14 +3622,15 @@
1);
}
}
- FlocaleDrawString(dpy, fw->title_font, &tdd->fstr, 0);
+ FlocaleDrawString(dpy, do_hilight ? fw->title_font :
+ fw->inactive_title_font, &tdd->fstr, 0);
return;
}
static void border_get_titlebar_draw_descr(
FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd,
- Pixmap dest_pix)
+ Pixmap dest_pix, Bool do_hilight)
{
rectangle *title_g;
@@ -3644,7 +3646,8 @@
tdd->rgc = td->cd->relief_gc;
tdd->sgc = td->cd->shadow_gc;
}
- NewFontAndColor(fw->title_font, td->cd->fore_color, td->cd->back_color);
+ NewFontAndColor(do_hilight ? fw->title_font : fw->inactive_title_font,
+ td->cd->fore_color, td->cd->back_color);
title_g = &td->layout.title_g;
tdd->tstyle = &TB_STATE(
GetDecor(fw, titlebar))[td->tbstate.tstate].style;
@@ -3682,7 +3685,7 @@
}
static void border_set_title_pixmap(
- FvwmWindow *fw, titlebar_descr *td, Pixmap *dest_pix, Window w)
+ FvwmWindow *fw, titlebar_descr *td, Pixmap *dest_pix, Window w, Bool do_hilight)
{
pixmap_background_type bg;
title_draw_descr tdd;
@@ -3690,7 +3693,7 @@
Bool free_bg_pixmap = False;
rectangle pix_g;
- border_get_titlebar_draw_descr(fw, td, &tdd, *dest_pix);
+ border_get_titlebar_draw_descr(fw, td, &tdd, *dest_pix, do_hilight);
/* prepare background, either from the window colour or from the
* border style */
if (!DFS_USE_BORDER_STYLE(*tdd.tstyle))
@@ -3758,11 +3761,11 @@
if (Pdepth < 2)
{
- border_draw_title_mono(fw, td, &tdd, &fstr, *dest_pix);
+ border_draw_title_mono(fw, td, &tdd, &fstr, *dest_pix, do_hilight);
}
else
{
- border_draw_title_deep(fw, td, &tdd, &fstr, *dest_pix, w);
+ border_draw_title_deep(fw, td, &tdd, &fstr, *dest_pix, w, do_hilight);
}
border_draw_title_relief(fw, td, &tdd, *dest_pix);
border_draw_title_stick_lines(fw, td, &tdd, *dest_pix);
@@ -3771,7 +3774,7 @@
}
static void border_draw_title(
- FvwmWindow *fw, titlebar_descr *td)
+ FvwmWindow *fw, titlebar_descr *td, Bool do_hilight)
{
Pixmap p;
@@ -3789,7 +3792,7 @@
#if 0
fprintf(stderr,"drawing title\n");
#endif
- border_set_title_pixmap(fw, td, &p, FW_W_TITLE(fw));
+ border_set_title_pixmap(fw, td, &p, FW_W_TITLE(fw), do_hilight);
if (td->draw_rotation != ROTATION_0)
{
Pixmap tmp;
@@ -4278,9 +4281,9 @@
if (fw->visible_name != (char *)NULL)
{
ret_td->length = FlocaleTextWidth(
- fw->title_font, fw->visible_name,
- (ret_td->has_vt) ? -strlen(fw->visible_name) :
- strlen(fw->visible_name));
+ do_hilight ? fw->title_font : fw->inactive_title_font,
+ fw->visible_name, (ret_td->has_vt) ?
+ -strlen(fw->visible_name) : strlen(fw->visible_name));
if (ret_td->length > fw->title_length -
2*MIN_WINDOW_TITLE_TEXT_OFFSET)
{
@@ -4386,7 +4389,7 @@
}
if ((draw_parts & PART_TITLE) != PART_NONE)
{
- border_draw_title(fw, &td);
+ border_draw_title(fw, &td, do_hilight);
}
if ((draw_parts & PART_BUTTONS) != PART_NONE)
{
diff -r -U3 fvwm/fvwm/fvwm.h fvwm/fvwm/fvwm.h
--- fvwm/fvwm/fvwm.h 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/fvwm/fvwm.h 2008-03-07 05:58:46.000000000 +0100
@@ -198,6 +198,7 @@
unsigned has_icon_font : 1;
unsigned has_no_border : 1;
unsigned has_window_font : 1;
+ unsigned has_inactive_window_font : 1;
unsigned title_dir : 2;
unsigned user_states : 32;
/* static flags that do not change dynamically after the window has
@@ -359,11 +360,13 @@
unsigned is_viewport_moved : 1;
unsigned is_window_being_moved_opaque : 1;
unsigned is_window_font_loaded : 1;
+ unsigned is_inactive_window_font_loaded : 1;
unsigned is_window_shaded : 1;
unsigned used_title_dir_for_shading : 1;
unsigned shaded_dir : 3;
unsigned using_default_icon_font : 1;
unsigned using_default_window_font : 1;
+ unsigned using_default_inactive_window_font : 1;
#define ICON_HINT_NEVER 0
#define ICON_HINT_ONCE 1
#define ICON_HINT_MULTIPLE 2
@@ -637,6 +640,7 @@
signed char icon_title_relief;
char *icon_font;
char *window_font;
+ char *inactive_window_font;
char *fore_color_name;
char *back_color_name;
char *fore_color_name_hi;
@@ -780,6 +784,7 @@
/* title font */
FlocaleFont *title_font;
+ FlocaleFont *inactive_title_font;
/* /Y coordinate to draw the title name */
short title_text_offset;
short title_length;
diff -r -U3 fvwm/fvwm/style.c fvwm/fvwm/style.c
--- fvwm/fvwm/style.c 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/fvwm/style.c 2008-03-07 05:58:46.000000000 +0100
@@ -415,6 +415,22 @@
*merged_style, SGET_WINDOW_FONT(*add_style));
}
}
+ if (S_HAS_INACTIVE_WINDOW_FONT(SCF(*add_style)))
+ {
+ if (do_free_src_and_alloc_copy)
+ {
+ SAFEFREE(SGET_INACTIVE_WINDOW_FONT(*merged_style));
+ SSET_INACTIVE_WINDOW_FONT(
+ *merged_style, (SGET_INACTIVE_WINDOW_FONT(*add_style)) ?
+ safestrdup(SGET_INACTIVE_WINDOW_FONT(*add_style)) :
+ NULL);
+ }
+ else
+ {
+ SSET_INACTIVE_WINDOW_FONT(
+ *merged_style, SGET_INACTIVE_WINDOW_FONT(*add_style));
+ }
+ }
if (add_style->flags.use_start_on_desk)
{
SSET_START_DESK(*merged_style, SGET_START_DESK(*add_style));
@@ -802,6 +818,10 @@
{
SAFEFREE(SGET_WINDOW_FONT(*style));
}
+ if (pmask->common.has_inactive_window_font)
+ {
+ SAFEFREE(SGET_INACTIVE_WINDOW_FONT(*style));
+ }
if (pmask->has_icon)
{
SAFEFREE(SGET_ICON_NAME(*style));
@@ -2966,6 +2986,15 @@
S_SET_IS_UNICONIFIABLE(SCM(*ps), 1);
S_SET_IS_UNICONIFIABLE(SCC(*ps), 1);
}
+ else if (StrEquals(token, "InactiveFont"))
+ {
+ SAFEFREE(SGET_INACTIVE_WINDOW_FONT(*ps));
+ rest = GetNextToken(rest, &token);
+ SSET_INACTIVE_WINDOW_FONT(*ps, token);
+ S_SET_HAS_INACTIVE_WINDOW_FONT(SCF(*ps), (token != NULL));
+ S_SET_HAS_INACTIVE_WINDOW_FONT(SCM(*ps), 1);
+ S_SET_HAS_INACTIVE_WINDOW_FONT(SCC(*ps), 1);
+ }
else if (StrEquals(token, "IndexedWindowName"))
{
S_SET_USE_INDEXED_WINDOW_NAME(SCF(*ps), on);
@@ -4762,6 +4791,12 @@
flags->do_update_window_font = 1;
}
+ /* has_inactive_window_font */
+ if (S_HAS_INACTIVE_WINDOW_FONT(SCC(*ret_style)))
+ {
+ flags->do_update_window_font = True;
+ }
+
/* has_stippled_title */
if (S_HAS_STIPPLED_TITLE(SCC(*ret_style)) ||
S_HAS_NO_STICKY_STIPPLED_TITLE(SCC(*ret_style)) ||
diff -r -U3 fvwm/fvwm/style.h fvwm/fvwm/style.h
--- fvwm/fvwm/style.h 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/fvwm/style.h 2008-03-07 05:58:46.000000000 +0100
@@ -267,6 +267,10 @@
((c).has_window_font)
#define S_SET_HAS_WINDOW_FONT(c,x) \
((c).has_window_font = !!(x))
+#define S_HAS_INACTIVE_WINDOW_FONT(c) \
+ ((c).has_inactive_window_font)
+#define S_SET_HAS_INACTIVE_WINDOW_FONT(c,x) \
+ ((c).has_inactive_window_font = !!(x))
#define S_ICON_OVERRIDE(c) \
((c).s.icon_override)
#define S_SET_ICON_OVERRIDE(c,x) \
@@ -459,6 +463,10 @@
((s).window_font)
#define SSET_WINDOW_FONT(s,x) \
((s).window_font = (x))
+#define SGET_INACTIVE_WINDOW_FONT(s) \
+ ((s).inactive_window_font)
+#define SSET_INACTIVE_WINDOW_FONT(s,x) \
+ ((s).inactive_window_font = (x))
#define SGET_COLORSET(s) \
((s).colorset)
#define SSET_COLORSET(s,x) \
Sólo en fvwm/fvwm: style.h.orig
diff -r -U3 fvwm/fvwm/window_flags.h fvwm/fvwm/window_flags.h
--- fvwm/fvwm/window_flags.h 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/fvwm/window_flags.h 2008-03-07 05:58:46.000000000 +0100
@@ -572,6 +572,12 @@
(fw)->flags.is_window_font_loaded = !!(x)
#define SETM_WINDOW_FONT_LOADED(fw,x) \
(fw)->flag_mask.is_window_font_loaded = !!(x)
+#define IS_INACTIVE_WINDOW_FONT_LOADED(fw) \
+ ((fw)->flags.is_inactive_window_font_loaded)
+#define SET_INACTIVE_WINDOW_FONT_LOADED(fw,x) \
+ (fw)->flags.is_inactive_window_font_loaded = !!(x)
+#define SETM_INACTIVE_WINDOW_FONT_LOADED(fw,x) \
+ (fw)->flag_mask.is_inactive_window_font_loaded = !!(x)
#define CR_MOTION_METHOD(fw) \
((fw)->flags.cr_motion_method)
#define SET_CR_MOTION_METHOD(fw,x) \
@@ -614,6 +620,12 @@
(fw)->flags.using_default_window_font = !!(x)
#define SETM_USING_DEFAULT_WINDOW_FONT(fw,x) \
(fw)->flag_mask.using_default_window_font = !!(x)
+#define USING_DEFAULT_INACTIVE_WINDOW_FONT(fw) \
+ ((fw)->flags.using_default_inactive_window_font)
+#define SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw,x) \
+ (fw)->flags.using_default_inactive_window_font = !!(x)
+#define SETM_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw,x) \
+ (fw)->flag_mask.using_default_inactive_window_font = !!(x)
#define USING_DEFAULT_ICON_FONT(fw) \
((fw)->flags.using_default_icon_font)
#define SET_USING_DEFAULT_ICON_FONT(fw,x) \
--- fvwm-/NEWS 2008-03-07 06:37:28.000000000 +0100
+++ fvwm/NEWS 2008-03-07 06:36:01.000000000 +0100
@@ -11,6 +11,7 @@
TitleAtBottom, TitleAtTop, TitleAtLeft, TitleAtRight
- Added new menu separator menustyle: FlatSeparator
- Added new titlestyle: ButtonWidth
+ - Added new style: InactiveFont
* Bug fixes:
diff -r -U3 fvwm/tests/purify/purify.fvwm2rc fvwm/tests/purify/purify.fvwm2rc
--- fvwm/tests/purify/purify.fvwm2rc 2008-03-07 05:53:47.000000000 +0100
+++ fvwm/tests/purify/purify.fvwm2rc 2008-03-07 06:19:29.000000000 +0100
@@ -1528,13 +1528,23 @@
AddTest "Test StyleIconFont" StyleIconFont-Func
AddToFunc StyleIconFont-Func
+ I StyleAndUpdate * IconFont
- + I StyleAndUpdate * IconFont 9x15
- + I StyleAndUpdate * IconFont 9x15
+ + I StyleAndUpdate * IconFont 9x15
+ + I StyleAndUpdate * IconFont 9x15
+ I StyleAndUpdate * IconFont /nonexistent/foo/bar
+ I StyleAndUpdate * IconFont -adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*
+ I StyleAndUpdate * IconFont -adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*
+ I StyleAndUpdate * IconFont
+AddTest "Test StyleInactiveFont" StyleInactiveFont-Func
+AddToFunc StyleInactiveFont-Func
+ + I StyleAndUpdate * InactiveFont
+ + I StyleAndUpdate * InactiveFont 9x15
+ + I StyleAndUpdate * InactiveFont 9x15
+ + I StyleAndUpdate * InactiveFont /nonexistent/foo/bar
+ + I StyleAndUpdate * InactiveFont -adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*
+ + I StyleAndUpdate * InactiveFont -adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*
+ + I StyleAndUpdate * InactiveFont
+
# Just arbitrary break in style tests:
AddTest "Test Style2" Style2-Func
AddToFunc Style2-Func
@@ -3463,6 +3473,7 @@
# EchoDo GotoPage
# EchoDo HilightColor
# EchoDo IconFont
+# EchoDo InactiveFont
# EchoDo Iconify
# EchoDo IconPath
# EchoDo Key