After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 536185 - monitor font configuration
monitor font configuration
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-06-02 08:36 UTC by Behdad Esfahbod
Modified: 2008-06-06 16:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch (4.04 KB, patch)
2008-06-02 08:37 UTC, Behdad Esfahbod
needs-work Details | Review
Updated patch (4.59 KB, patch)
2008-06-05 03:59 UTC, Behdad Esfahbod
committed Details | Review

Description Behdad Esfahbod 2008-06-02 08:36:06 UTC
Attaching patch to add a new xsettings Fontconfig/Timestamp, and use it to refresh fonts by invalidating Pango's caches and requesting redraw.  The counterpart to this is in bug 490374 that makes gnome-settings-daemon monitor all fontconfig configurations and set Fontconfig/Timestamp upon change.

I really just needed a signal, but didn't know how to add that to gtksettings, so added an integer timestamp instead.

This should also mean that installed fonts are picked up automagically.  Didn't test that part yet, but verified that with these changes (and the gsd part), changing ~/.fonts.conf takes effect on running applications in a couple seconds.

Any chance to get this into a release today?
Comment 1 Behdad Esfahbod 2008-06-02 08:37:06 UTC
Created attachment 111935 [details] [review]
The patch

The configure parts and #ifdef's can use some improvement.  Currently hooks on x11 being the gdk backend to enable this.
Comment 2 Behdad Esfahbod 2008-06-02 08:43:33 UTC
Tested online font installation and it works too.  W00t.
Comment 3 Matthias Clasen 2008-06-02 23:00:39 UTC
Hmm. Considering this is X specific, and you just need a signal, not a value,
and alternative would be to trigger this via a root window property change, and handle it in gdkevents-x11.c...
Comment 4 Behdad Esfahbod 2008-06-03 01:48:50 UTC
Ideally this should go over dbus, as it's kinda host specific.  But yeat, root window works better.  Working on it.
Comment 5 Behdad Esfahbod 2008-06-03 05:52:09 UTC
Did the gdk part, but need to notify gtk still to do gtk_rc_reset_styles() on the settings object, right?  I prolly can add a special xsettings event that causes just reset_styles().  Then make gdkevents-x11.c generate that for the PropertyNotify event I get.
Comment 6 Behdad Esfahbod 2008-06-03 06:45:24 UTC
Humm.. The clean way to do that is to add a new GdkEventType value.  But that sounds like an overkill.

The previous approach is broken too as it will only notify on the first screen and the other screens see that no configuration was changed so they will not notify.
Comment 7 Behdad Esfahbod 2008-06-05 03:09:11 UTC
I did the research now.  Seems like there's a reason for xsettings existing in the first place :) :  If we do a property on the root window, all GTK+ apps have to monitory for PropertyNotify on root window.  A much much higher traffic than xsettings.

So, I think we can safely go back to xsettings.  I'll just update the patch to handle multi-screen correctly.
Comment 8 Matthias Clasen 2008-06-05 03:11:00 UTC
Sorry for sending you on that detour...
Comment 9 Behdad Esfahbod 2008-06-05 03:12:58 UTC
(In reply to comment #8)
> Sorry for sending you on that detour...

That's fine.  Made me find a race condition in the current patch...
Comment 10 Behdad Esfahbod 2008-06-05 03:59:46 UTC
Created attachment 112183 [details] [review]
Updated patch

Updated patch that uses the timestamp value to correctly handle multi-screen scenarios.

Can go in AFAIC.  Going to commit the g-s-d part again.
Comment 11 Matthias Clasen 2008-06-06 01:34:36 UTC
Looks good to me. Do we want to move the clear_cache function into stable pango api, considering that it seems to be useful for something other than writing backends ?
Comment 12 Behdad Esfahbod 2008-06-06 16:37:11 UTC
Yep, already filed bug 536190 about making clear_cache public.
Comment 13 Behdad Esfahbod 2008-06-06 16:40:00 UTC
2008-06-06  Behdad Esfahbod  <behdad@gnome.org>

        Bug 536185 – monitor font configuration

        * configure.in:
        * gdk/x11/gdksettings.c:
        * gtk/gtksettings.c (gtk_settings_class_init),
        (gtk_settings_notify), (settings_update_fontconfig):
        Monitor xsettings key Fontconfig/Timestamp and upon change,
        reread fontconfig configuration, clear Pango's caches, and
        redraw all widgets.