aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2004-10-21 18:38:58 +0000
committerJan Djärv2004-10-21 18:38:58 +0000
commitc27ed90af576892cae147bfe6be1a8b43126102a (patch)
treef4160cfb96b7cb46e98ae9a865c086b6c782a411 /src
parent6e237e7298748ebb5fe7baa4d56a5cf7cbac224b (diff)
downloademacs-c27ed90af576892cae147bfe6be1a8b43126102a.tar.gz
emacs-c27ed90af576892cae147bfe6be1a8b43126102a.zip
* xterm.h (x_output): New member `xic_base_fontname'.
(FRAME_XIC_BASE_FONTNAME): New macro. (xic_free_xfontset): Declare. * xfns.c (xic_create_xfontset): Share fontsets between frames based on base_fontname. (xic_free_xfontset): New function. (free_frame_xic): Use it. (xic_set_xfontset): Ditto. * xterm.c (xim_destroy_callback): Ditto.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog15
-rw-r--r--src/xfns.c76
-rw-r--r--src/xterm.c6
-rw-r--r--src/xterm.h3
4 files changed, 83 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c5e12b4edb0..efb792df4d6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
12004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu>
2
3 * xterm.h (x_output): New member `xic_base_fontname'.
4 (FRAME_XIC_BASE_FONTNAME): New macro.
5 (xic_free_xfontset): Declare.
6
7 * xfns.c (xic_create_xfontset): Share fontsets between frames
8 based on base_fontname.
9 (xic_free_xfontset): New function.
10 (free_frame_xic): Use it.
11 (xic_set_xfontset): Ditto.
12
13 * xterm.c (xim_destroy_callback): Ditto.
14
15
12004-10-20 B. Anyos <banyos@freemail.hu> (tiny change) 162004-10-20 B. Anyos <banyos@freemail.hu> (tiny change)
2 17
3 * w32term.c (x_draw_glyph_string): Use overline_color for overlines. 18 * w32term.c (x_draw_glyph_string): Use overline_color for overlines.
diff --git a/src/xfns.c b/src/xfns.c
index de95a59112a..8d539472d11 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1941,29 +1941,83 @@ static XIMStyle supported_xim_styles[] =
1941}; 1941};
1942 1942
1943 1943
1944/* Create an X fontset on frame F with base font name 1944/* Create an X fontset on frame F with base font name BASE_FONTNAME. */
1945 BASE_FONTNAME.. */
1946 1945
1947static XFontSet 1946static XFontSet
1948xic_create_xfontset (f, base_fontname) 1947xic_create_xfontset (f, base_fontname)
1949 struct frame *f; 1948 struct frame *f;
1950 char *base_fontname; 1949 char *base_fontname;
1951{ 1950{
1952 XFontSet xfs; 1951 XFontSet xfs = NULL;
1953 char **missing_list; 1952 char **missing_list;
1954 int missing_count; 1953 int missing_count;
1955 char *def_string; 1954 char *def_string;
1955 Lisp_Object rest, frame;
1956
1957 /* See if there is another frame already using same fontset. */
1958 FOR_EACH_FRAME (rest, frame)
1959 {
1960 struct frame *cf = XFRAME (frame);
1961 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
1962 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
1963 && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
1964 {
1965 xfs = FRAME_XIC_FONTSET (cf);
1966 break;
1967 }
1968 }
1956 1969
1957 xfs = XCreateFontSet (FRAME_X_DISPLAY (f), 1970 if (!xfs)
1958 base_fontname, &missing_list, 1971 /* New fontset. */
1959 &missing_count, &def_string); 1972 xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
1973 base_fontname, &missing_list,
1974 &missing_count, &def_string);
1960 if (missing_list) 1975 if (missing_list)
1961 XFreeStringList (missing_list); 1976 XFreeStringList (missing_list);
1962 1977
1963 /* No need to free def_string. */ 1978 if (FRAME_XIC_BASE_FONTNAME (f))
1979 xfree (FRAME_XIC_BASE_FONTNAME (f));
1980 FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
1981
1982 /* No need to free def_string. */
1964 return xfs; 1983 return xfs;
1965} 1984}
1966 1985
1986/* Free the X fontset of frame F if it is the last frame using it. */
1987
1988void
1989xic_free_xfontset (f)
1990 struct frame *f;
1991{
1992 Lisp_Object rest, frame;
1993 int shared_p = 0;
1994
1995 if (!FRAME_XIC_FONTSET (f))
1996 return;
1997
1998 /* See if there is another frame sharing the same fontset. */
1999 FOR_EACH_FRAME (rest, frame)
2000 {
2001 struct frame *cf = XFRAME (frame);
2002 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
2003 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
2004 && FRAME_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f))
2005 {
2006 shared_p = 1;
2007 break;
2008 }
2009 }
2010
2011 if (!shared_p)
2012 /* The fontset is not used anymore. It is safe to free it. */
2013 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2014
2015 if (FRAME_XIC_BASE_FONTNAME (f))
2016 xfree (FRAME_XIC_BASE_FONTNAME (f));
2017 FRAME_XIC_BASE_FONTNAME (f) = NULL;
2018 FRAME_XIC_FONTSET (f) = NULL;
2019}
2020
1967 2021
1968/* Value is the best input style, given user preferences USER (already 2022/* Value is the best input style, given user preferences USER (already
1969 checked to be supported by Emacs), and styles supported by the 2023 checked to be supported by Emacs), and styles supported by the
@@ -2114,11 +2168,9 @@ free_frame_xic (f)
2114 return; 2168 return;
2115 2169
2116 XDestroyIC (FRAME_XIC (f)); 2170 XDestroyIC (FRAME_XIC (f));
2117 if (FRAME_XIC_FONTSET (f)) 2171 xic_free_xfontset (f);
2118 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2119 2172
2120 FRAME_XIC (f) = NULL; 2173 FRAME_XIC (f) = NULL;
2121 FRAME_XIC_FONTSET (f) = NULL;
2122} 2174}
2123 2175
2124 2176
@@ -2197,6 +2249,8 @@ xic_set_xfontset (f, base_fontname)
2197 XVaNestedList attr; 2249 XVaNestedList attr;
2198 XFontSet xfs; 2250 XFontSet xfs;
2199 2251
2252 xic_free_xfontset (f);
2253
2200 xfs = xic_create_xfontset (f, base_fontname); 2254 xfs = xic_create_xfontset (f, base_fontname);
2201 2255
2202 attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL); 2256 attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);
@@ -2206,8 +2260,6 @@ xic_set_xfontset (f, base_fontname)
2206 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL); 2260 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
2207 XFree (attr); 2261 XFree (attr);
2208 2262
2209 if (FRAME_XIC_FONTSET (f))
2210 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2211 FRAME_XIC_FONTSET (f) = xfs; 2263 FRAME_XIC_FONTSET (f) = xfs;
2212} 2264}
2213 2265
diff --git a/src/xterm.c b/src/xterm.c
index 41b7c18e820..54ee4014e8c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8012,11 +8012,7 @@ xim_destroy_callback (xim, client_data, call_data)
8012 if (FRAME_X_DISPLAY_INFO (f) == dpyinfo) 8012 if (FRAME_X_DISPLAY_INFO (f) == dpyinfo)
8013 { 8013 {
8014 FRAME_XIC (f) = NULL; 8014 FRAME_XIC (f) = NULL;
8015 if (FRAME_XIC_FONTSET (f)) 8015 xic_free_xfontset (f);
8016 {
8017 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
8018 FRAME_XIC_FONTSET (f) = NULL;
8019 }
8020 } 8016 }
8021 } 8017 }
8022 8018
diff --git a/src/xterm.h b/src/xterm.h
index f0e2f3521bb..7ec690d2e24 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -600,6 +600,7 @@ struct x_output
600 XIC xic; 600 XIC xic;
601 XIMStyle xic_style; 601 XIMStyle xic_style;
602 XFontSet xic_xfs; 602 XFontSet xic_xfs;
603 char *xic_base_fontname;
603#endif 604#endif
604 605
605 /* Relief GCs, colors etc. */ 606 /* Relief GCs, colors etc. */
@@ -734,6 +735,7 @@ enum
734#define FRAME_X_XIM_STYLES(f) (FRAME_X_DISPLAY_INFO (f)->xim_styles) 735#define FRAME_X_XIM_STYLES(f) (FRAME_X_DISPLAY_INFO (f)->xim_styles)
735#define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style) 736#define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
736#define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs) 737#define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
738#define FRAME_XIC_BASE_FONTNAME(f) ((f)->output_data.x->xic_base_fontname)
737 739
738/* Value is the smallest width of any character in any font on frame F. */ 740/* Value is the smallest width of any character in any font on frame F. */
739 741
@@ -1043,6 +1045,7 @@ extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object))
1043extern unsigned char * x_encode_text P_ ((Lisp_Object, Lisp_Object, int, 1045extern unsigned char * x_encode_text P_ ((Lisp_Object, Lisp_Object, int,
1044 int *, int *)); 1046 int *, int *));
1045extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); 1047extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
1048extern void xic_free_xfontset P_ ((struct frame *));
1046extern void create_frame_xic P_ ((struct frame *)); 1049extern void create_frame_xic P_ ((struct frame *));
1047extern void destroy_frame_xic P_ ((struct frame *)); 1050extern void destroy_frame_xic P_ ((struct frame *));
1048extern void xic_set_preeditarea P_ ((struct window *, int, int)); 1051extern void xic_set_preeditarea P_ ((struct window *, int, int));