aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-07-16 12:21:02 +0000
committerGerd Moellmann2001-07-16 12:21:02 +0000
commitd5641fc560ce6e663975e2a8c98bb00845e2332a (patch)
treeb76317296fba28a1d4088eef084357c8d3e83cde
parentbb24c64f41c55b8d3944f5abcc1c4a7d1ab220c6 (diff)
downloademacs-d5641fc560ce6e663975e2a8c98bb00845e2332a.tar.gz
emacs-d5641fc560ce6e663975e2a8c98bb00845e2332a.zip
(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.
-rw-r--r--src/xfaces.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 7e1eb33521c..0734cd169fa 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -597,7 +597,7 @@ static void sort_fonts P_ ((struct frame *, struct font_name *, int,
597 int (*cmpfn) P_ ((const void *, const void *)))); 597 int (*cmpfn) P_ ((const void *, const void *))));
598static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *)); 598static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *));
599static void x_free_gc P_ ((struct frame *, GC)); 599static void x_free_gc P_ ((struct frame *, GC));
600static void clear_font_table P_ ((struct frame *)); 600static void clear_font_table P_ ((struct x_display_info *));
601 601
602#ifdef WINDOWSNT 602#ifdef WINDOWSNT
603extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int)); 603extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
@@ -979,6 +979,14 @@ clear_face_cache (clear_fonts_p)
979 if (clear_fonts_p 979 if (clear_fonts_p
980 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) 980 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT)
981 { 981 {
982 struct x_display_info *dpyinfo;
983
984 /* Fonts are common for frames on one display, i.e. on
985 one X screen. */
986 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
987 if (dpyinfo->n_fonts > CLEAR_FONT_TABLE_NFONTS)
988 clear_font_table (dpyinfo);
989
982 /* From time to time see if we can unload some fonts. This also 990 /* From time to time see if we can unload some fonts. This also
983 frees all realized faces on all frames. Fonts needed by 991 frees all realized faces on all frames. Fonts needed by
984 faces will be loaded again when faces are realized again. */ 992 faces will be loaded again when faces are realized again. */
@@ -986,13 +994,10 @@ clear_face_cache (clear_fonts_p)
986 994
987 FOR_EACH_FRAME (tail, frame) 995 FOR_EACH_FRAME (tail, frame)
988 { 996 {
989 f = XFRAME (frame); 997 struct frame *f = XFRAME (frame);
990 if (FRAME_WINDOW_P (f) 998 if (FRAME_WINDOW_P (f)
991 && FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS) 999 && FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS)
992 { 1000 free_all_realized_faces (frame);
993 free_all_realized_faces (frame);
994 clear_font_table (f);
995 }
996 } 1001 }
997 } 1002 }
998 else 1003 else
@@ -1034,21 +1039,32 @@ Optional THOROUGHLY non-nil means try to free unused fonts, too.")
1034 from time to time. */ 1039 from time to time. */
1035 1040
1036static void 1041static void
1037clear_font_table (f) 1042clear_font_table (dpyinfo)
1038 struct frame *f; 1043 struct x_display_info *dpyinfo;
1039{ 1044{
1040 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
1041 int i; 1045 int i;
1042 1046
1043 xassert (FRAME_WINDOW_P (f)); 1047 /* Free those fonts that are not used by frames on DPYINFO. */
1044
1045 /* Free those fonts that are not used by the frame F as the default. */
1046 for (i = 0; i < dpyinfo->n_fonts; ++i) 1048 for (i = 0; i < dpyinfo->n_fonts; ++i)
1047 { 1049 {
1048 struct font_info *font_info = dpyinfo->font_table + i; 1050 struct font_info *font_info = dpyinfo->font_table + i;
1051 Lisp_Object tail, frame;
1049 1052
1050 if (!font_info->name 1053 /* Check if slot is already free. */
1051 || font_info->font == FRAME_FONT (f)) 1054 if (font_info->name == NULL)
1055 continue;
1056
1057 /* Don't free a default font of some frame on this display. */
1058 FOR_EACH_FRAME (tail, frame)
1059 {
1060 struct frame *f = XFRAME (frame);
1061 if (FRAME_WINDOW_P (f)
1062 && FRAME_X_DISPLAY_INFO (f) == dpyinfo
1063 && font_info->font == FRAME_FONT (f))
1064 break;
1065 }
1066
1067 if (!NILP (tail))
1052 continue; 1068 continue;
1053 1069
1054 /* Free names. */ 1070 /* Free names. */