Commit d5641fc5 authored by Gerd Moellmann's avatar Gerd Moellmann
Browse files

(clear_face_cache): Clear fonts on a display basis.

Clear faces afterwards.
(clear_font_table): Take a x_display_info parameter.  Don't free
fonts being the default font of any frame on the given display.
parent bb24c64f
...@@ -597,7 +597,7 @@ static void sort_fonts P_ ((struct frame *, struct font_name *, int, ...@@ -597,7 +597,7 @@ static void sort_fonts P_ ((struct frame *, struct font_name *, int,
int (*cmpfn) P_ ((const void *, const void *)))); int (*cmpfn) P_ ((const void *, const void *))));
static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *)); static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *));
static void x_free_gc P_ ((struct frame *, GC)); static void x_free_gc P_ ((struct frame *, GC));
static void clear_font_table P_ ((struct frame *)); static void clear_font_table P_ ((struct x_display_info *));
#ifdef WINDOWSNT #ifdef WINDOWSNT
extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int)); extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
...@@ -979,6 +979,14 @@ clear_face_cache (clear_fonts_p) ...@@ -979,6 +979,14 @@ clear_face_cache (clear_fonts_p)
if (clear_fonts_p if (clear_fonts_p
|| ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT)
{ {
struct x_display_info *dpyinfo;
/* Fonts are common for frames on one display, i.e. on
one X screen. */
for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
if (dpyinfo->n_fonts > CLEAR_FONT_TABLE_NFONTS)
clear_font_table (dpyinfo);
/* From time to time see if we can unload some fonts. This also /* From time to time see if we can unload some fonts. This also
frees all realized faces on all frames. Fonts needed by frees all realized faces on all frames. Fonts needed by
faces will be loaded again when faces are realized again. */ faces will be loaded again when faces are realized again. */
...@@ -986,13 +994,10 @@ clear_face_cache (clear_fonts_p) ...@@ -986,13 +994,10 @@ clear_face_cache (clear_fonts_p)
FOR_EACH_FRAME (tail, frame) FOR_EACH_FRAME (tail, frame)
{ {
f = XFRAME (frame); struct frame *f = XFRAME (frame);
if (FRAME_WINDOW_P (f) if (FRAME_WINDOW_P (f)
&& FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS) && FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS)
{ free_all_realized_faces (frame);
free_all_realized_faces (frame);
clear_font_table (f);
}
} }
} }
else else
...@@ -1034,21 +1039,32 @@ Optional THOROUGHLY non-nil means try to free unused fonts, too.") ...@@ -1034,21 +1039,32 @@ Optional THOROUGHLY non-nil means try to free unused fonts, too.")
from time to time. */ from time to time. */
static void static void
clear_font_table (f) clear_font_table (dpyinfo)
struct frame *f; struct x_display_info *dpyinfo;
{ {
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
int i; int i;
xassert (FRAME_WINDOW_P (f)); /* Free those fonts that are not used by frames on DPYINFO. */
/* Free those fonts that are not used by the frame F as the default. */
for (i = 0; i < dpyinfo->n_fonts; ++i) for (i = 0; i < dpyinfo->n_fonts; ++i)
{ {
struct font_info *font_info = dpyinfo->font_table + i; struct font_info *font_info = dpyinfo->font_table + i;
Lisp_Object tail, frame;
if (!font_info->name /* Check if slot is already free. */
|| font_info->font == FRAME_FONT (f)) if (font_info->name == NULL)
continue;
/* Don't free a default font of some frame on this display. */
FOR_EACH_FRAME (tail, frame)
{
struct frame *f = XFRAME (frame);
if (FRAME_WINDOW_P (f)
&& FRAME_X_DISPLAY_INFO (f) == dpyinfo
&& font_info->font == FRAME_FONT (f))
break;
}
if (!NILP (tail))
continue; continue;
/* Free names. */ /* Free names. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment