summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-08-09 03:54:26 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-08-09 03:54:26 +0000
commit50d73d06b9fe6c3c1affd79c6bb88712bc83ed3d (patch)
treed6f980715820986eb7ee833aba9e451d81bf2b40 /pango
parentceb74567faa000289bae9f4110ae7752d762f597 (diff)
downloadpango-50d73d06b9fe6c3c1affd79c6bb88712bc83ed3d.tar.gz
use XAddExtension() magic to automatically clean up our information when
Thu Aug 8 23:14:27 2002 Owen Taylor <otaylor@redhat.com> * pango/pangox-fontmap.c pango/pangoxft-fontmap.c: use XAddExtension() magic to automatically clean up our information when XCloseDisplay() is called. * NEWS: Some updates for 1.1.x features. * README: Update a bit. * configure.in: Print Xft for the Xft backend, not Xft2 when printing summary.
Diffstat (limited to 'pango')
-rw-r--r--pango/pangox-fontmap.c38
-rw-r--r--pango/pangoxft-fontmap.c49
2 files changed, 87 insertions, 0 deletions
diff --git a/pango/pangox-fontmap.c b/pango/pangox-fontmap.c
index 52db3e77..9ff8ee93 100644
--- a/pango/pangox-fontmap.c
+++ b/pango/pangox-fontmap.c
@@ -27,6 +27,9 @@
#include <X11/Xatom.h>
+/* For XExtSetCloseDisplay */
+#include <X11/Xlibint.h>
+
#include "pango-fontmap.h"
#include "pango-utils.h"
#include "pangox-private.h"
@@ -215,6 +218,39 @@ pango_x_font_map_class_init (PangoFontMapClass *class)
class->list_families = pango_x_font_map_list_families;
}
+/*
+ * Hackery to set up notification when a Display is closed
+ */
+static GSList *registered_displays;
+
+static int
+close_display_cb (Display *display,
+ XExtCodes *extcodes)
+{
+ pango_x_shutdown_display (display);
+ registered_displays = g_slist_remove (registered_displays, display);
+
+ return 0;
+}
+
+static void
+register_display (Display *display)
+{
+ XExtCodes *extcodes;
+ GSList *tmp_list;
+
+ for (tmp_list = registered_displays; tmp_list; tmp_list = tmp_list->next)
+ {
+ if (tmp_list->data == display)
+ return;
+ }
+
+ registered_displays = g_slist_prepend (registered_displays, display);
+
+ extcodes = XAddExtension (display);
+ XESetCloseDisplay (display, extcodes->extension, close_display_cb);
+}
+
static GList *fontmaps = NULL;
/**
@@ -285,6 +321,8 @@ pango_x_font_map_for_display (Display *display)
xfontmap->resolution = (PANGO_SCALE * 72.27 / 25.4) * ((double) DisplayWidthMM (xfontmap->display, screen) /
DisplayWidth (xfontmap->display, screen));
+ register_display (xfontmap->display);
+
return PANGO_FONT_MAP (xfontmap);
}
diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c
index 84249f0e..5fe720f0 100644
--- a/pango/pangoxft-fontmap.c
+++ b/pango/pangoxft-fontmap.c
@@ -26,6 +26,9 @@
#include "pangoxft-private.h"
#include "modules.h"
+/* For XExtSetCloseDisplay */
+#include <X11/Xlibint.h>
+
/* Number of freed fonts */
#define MAX_FREED_FONTS 128
@@ -260,6 +263,50 @@ pango_xft_find_font_map (Display *display,
return NULL;
}
+/*
+ * Hackery to set up notification when a Display is closed
+ */
+static GSList *registered_displays;
+
+static int
+close_display_cb (Display *display,
+ XExtCodes *extcodes)
+{
+ GSList *tmp_list;
+
+ tmp_list = fontmaps;
+ while (tmp_list)
+ {
+ PangoXftFontMap *xfontmap = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ if (xfontmap->display == display)
+ pango_xft_shutdown_display (display, xfontmap->screen);
+ }
+
+ registered_displays = g_slist_remove (registered_displays, display);
+
+ return 0;
+}
+
+static void
+register_display (Display *display)
+{
+ XExtCodes *extcodes;
+ GSList *tmp_list;
+
+ for (tmp_list = registered_displays; tmp_list; tmp_list = tmp_list->next)
+ {
+ if (tmp_list->data == display)
+ return;
+ }
+
+ registered_displays = g_slist_prepend (registered_displays, display);
+
+ extcodes = XAddExtension (display);
+ XESetCloseDisplay (display, extcodes->extension, close_display_cb);
+}
+
/**
* pango_xft_get_font_map:
* @display: an X display
@@ -313,6 +360,8 @@ pango_xft_get_font_map (Display *display,
(GDestroyNotify)pango_coverage_unref);
xfontmap->freed_fonts = g_queue_new ();
+ register_display (display);
+
fontmaps = g_slist_prepend (fontmaps, xfontmap);
return PANGO_FONT_MAP (xfontmap);