summaryrefslogtreecommitdiff
path: root/pango/pangoxft-fontmap.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2012-12-05 13:29:48 +0100
committerAlexander Larsson <alexl@redhat.com>2012-12-06 16:36:19 +0100
commit3f3a095a1809375ef600dc3a947b3ff2df08f22c (patch)
tree5d7d2cb3ada7f3fe92fb4525eea7907f185165e1 /pango/pangoxft-fontmap.c
parentb359bb484bc7d27a835cfd6d9ffcaed582ebf2ae (diff)
downloadpango-3f3a095a1809375ef600dc3a947b3ff2df08f22c.tar.gz
Track changes in FontMaps using a serial
This adds the pango_font_map_get_serial method that lets you see if a fontmap has changes since the last check. It adds implementations to all current fontmaps. https://bugzilla.gnome.org/show_bug.cgi?id=340066
Diffstat (limited to 'pango/pangoxft-fontmap.c')
-rw-r--r--pango/pangoxft-fontmap.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c
index 9d210b50..aa891c54 100644
--- a/pango/pangoxft-fontmap.c
+++ b/pango/pangoxft-fontmap.c
@@ -41,6 +41,8 @@ struct _PangoXftFontMap
{
PangoFcFontMap parent_instance;
+ guint serial;
+
Display *display;
int screen;
@@ -59,6 +61,7 @@ struct _PangoXftFontMapClass
PangoFcFontMapClass parent_class;
};
+static guint pango_xft_font_map_get_serial (PangoFontMap *fontmap);
static void pango_xft_font_map_default_substitute (PangoFcFontMap *fcfontmap,
FcPattern *pattern);
static PangoFcFont * pango_xft_font_map_new_font (PangoFcFontMap *fcfontmap,
@@ -74,16 +77,21 @@ static void
pango_xft_font_map_class_init (PangoXftFontMapClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class);
PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class);
gobject_class->finalize = pango_xft_font_map_finalize;
+
+ fontmap_class->get_serial = pango_xft_font_map_get_serial;
+
fcfontmap_class->default_substitute = pango_xft_font_map_default_substitute;
fcfontmap_class->new_font = pango_xft_font_map_new_font;
}
static void
-pango_xft_font_map_init (PangoXftFontMap *xftfontmap G_GNUC_UNUSED)
+pango_xft_font_map_init (PangoXftFontMap *xftfontmap)
{
+ xftfontmap->serial = 1;
}
static void
@@ -105,6 +113,14 @@ pango_xft_font_map_finalize (GObject *object)
}
+static guint
+pango_xft_font_map_get_serial (PangoFontMap *fontmap)
+{
+ PangoXftFontMap *xftfontmap = PANGO_XFT_FONT_MAP (fontmap);
+
+ return xftfontmap->serial;
+}
+
static PangoFontMap *
pango_xft_find_font_map (Display *display,
int screen)
@@ -283,6 +299,10 @@ pango_xft_set_default_substitute (Display *display,
{
PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen);
+ xftfontmap->serial++;
+ if (xftfontmap->serial == 0)
+ xftfontmap->serial++;
+
if (xftfontmap->substitute_destroy)
xftfontmap->substitute_destroy (xftfontmap->substitute_data);
@@ -312,6 +332,9 @@ pango_xft_substitute_changed (Display *display,
{
PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen);
+ xftfontmap->serial++;
+ if (xftfontmap->serial == 0)
+ xftfontmap->serial++;
pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (xftfontmap));
}