aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv <[email protected]>2004-10-21 18:38:58 +0000
committerJan Djärv <[email protected]>2004-10-21 18:38:58 +0000
commitc27ed90af576892cae147bfe6be1a8b43126102a (patch)
treef4160cfb96b7cb46e98ae9a865c086b6c782a411 /src
parent6e237e7298748ebb5fe7baa4d56a5cf7cbac224b (diff)
* 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 c5e12b4edb..efb792df4d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2004-10-21 K,Aa(Broly L$,1 q(Brentey <[email protected]>
+
+ * 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.
+
+
2004-10-20 B. Anyos <[email protected]> (tiny change)
* w32term.c (x_draw_glyph_string): Use overline_color for overlines.
diff --git a/src/xfns.c b/src/xfns.c
index de95a59112..8d539472d1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1941,29 +1941,83 @@ static XIMStyle supported_xim_styles[] =
};
-/* Create an X fontset on frame F with base font name
- BASE_FONTNAME.. */
+/* Create an X fontset on frame F with base font name BASE_FONTNAME. */
static XFontSet
xic_create_xfontset (f, base_fontname)
struct frame *f;
char *base_fontname;
{
- XFontSet xfs;
+ XFontSet xfs = NULL;
char **missing_list;
int missing_count;
char *def_string;
+ Lisp_Object rest, frame;
+
+ /* See if there is another frame already using same fontset. */
+ FOR_EACH_FRAME (rest, frame)
+ {
+ struct frame *cf = XFRAME (frame);
+ if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
+ && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
+ && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
+ {
+ xfs = FRAME_XIC_FONTSET (cf);
+ break;
+ }
+ }
- xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
- base_fontname, &missing_list,
- &missing_count, &def_string);
+ if (!xfs)
+ /* New fontset. */
+ xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
+ base_fontname, &missing_list,
+ &missing_count, &def_string);
if (missing_list)
XFreeStringList (missing_list);
- /* No need to free def_string. */
+ if (FRAME_XIC_BASE_FONTNAME (f))
+ xfree (FRAME_XIC_BASE_FONTNAME (f));
+ FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
+
+ /* No need to free def_string. */
return xfs;
}
+/* Free the X fontset of frame F if it is the last frame using it. */
+
+void
+xic_free_xfontset (f)
+ struct frame *f;
+{
+ Lisp_Object rest, frame;
+ int shared_p = 0;
+
+ if (!FRAME_XIC_FONTSET (f))
+ return;
+
+ /* See if there is another frame sharing the same fontset. */
+ FOR_EACH_FRAME (rest, frame)
+ {
+ struct frame *cf = XFRAME (frame);
+ if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
+ && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
+ && FRAME_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f))
+ {
+ shared_p = 1;
+ break;
+ }
+ }
+
+ if (!shared_p)
+ /* The fontset is not used anymore. It is safe to free it. */
+ XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
+
+ if (FRAME_XIC_BASE_FONTNAME (f))
+ xfree (FRAME_XIC_BASE_FONTNAME (f));
+ FRAME_XIC_BASE_FONTNAME (f) = NULL;
+ FRAME_XIC_FONTSET (f) = NULL;
+}
+
/* Value is the best input style, given user preferences USER (already
checked to be supported by Emacs), and styles supported by the
@@ -2114,11 +2168,9 @@ free_frame_xic (f)
return;
XDestroyIC (FRAME_XIC (f));
- if (FRAME_XIC_FONTSET (f))
- XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
+ xic_free_xfontset (f);
FRAME_XIC (f) = NULL;
- FRAME_XIC_FONTSET (f) = NULL;
}
@@ -2197,6 +2249,8 @@ xic_set_xfontset (f, base_fontname)
XVaNestedList attr;
XFontSet xfs;
+ xic_free_xfontset (f);
+
xfs = xic_create_xfontset (f, base_fontname);
attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);
@@ -2206,8 +2260,6 @@ xic_set_xfontset (f, base_fontname)
XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
XFree (attr);
- if (FRAME_XIC_FONTSET (f))
- XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
FRAME_XIC_FONTSET (f) = xfs;
}
diff --git a/src/xterm.c b/src/xterm.c
index 41b7c18e82..54ee4014e8 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8012,11 +8012,7 @@ xim_destroy_callback (xim, client_data, call_data)
if (FRAME_X_DISPLAY_INFO (f) == dpyinfo)
{
FRAME_XIC (f) = NULL;
- if (FRAME_XIC_FONTSET (f))
- {
- XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
- FRAME_XIC_FONTSET (f) = NULL;
- }
+ xic_free_xfontset (f);
}
}
diff --git a/src/xterm.h b/src/xterm.h
index f0e2f3521b..7ec690d2e2 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -600,6 +600,7 @@ struct x_output
XIC xic;
XIMStyle xic_style;
XFontSet xic_xfs;
+ char *xic_base_fontname;
#endif
/* Relief GCs, colors etc. */
@@ -734,6 +735,7 @@ enum
#define FRAME_X_XIM_STYLES(f) (FRAME_X_DISPLAY_INFO (f)->xim_styles)
#define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
#define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
+#define FRAME_XIC_BASE_FONTNAME(f) ((f)->output_data.x->xic_base_fontname)
/* Value is the smallest width of any character in any font on frame F. */
@@ -1043,6 +1045,7 @@ extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object))
extern unsigned char * x_encode_text P_ ((Lisp_Object, Lisp_Object, int,
int *, int *));
extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void xic_free_xfontset P_ ((struct frame *));
extern void create_frame_xic P_ ((struct frame *));
extern void destroy_frame_xic P_ ((struct frame *));
extern void xic_set_preeditarea P_ ((struct window *, int, int));