[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: x-create-frame is sluggish
From: |
Lőrentey Károly |
Subject: |
Re: x-create-frame is sluggish |
Date: |
Mon, 11 Oct 2004 00:45:01 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Lőrentey Károly <address@hidden> writes:
> Kenichi Handa <address@hidden> writes:
>> I think the change is straight forward and not that big.
>> But, for the moment, I'm too heavily overloaded to work on
>> it. :-(
>
> I have set aside some time for hacking on this weekend. I'll see if I
> can do this, then.
Well, I got delayed a bit. Below is my patch for speeding up frame
creation by sharing fontsets between frames. It works fine on my
system; frame creation feels almost instantaneous again. I think
applying it should not mess things up too badly.
(An Arch changeset for this patch is available as
address@hidden/emacs--fontset-cache--0--patch-3.)
2004-10-11 Károly Lőrentey <address@hidden>
* src/xterm.h (x_output): New member `xic_base_fontname'.
(FRAME_XIC_BASE_FONTNAME): New macro.
(xic_delete_xfontset): Declare.
* src/xfns.c (xic_create_xfontset): Share fontsets between frames
based on base_fontname.
(create_frame_xic): Set the frame's base_fontname.
(xic_delete_xfontset): New function.
(free_frame_xic): Use it. Free base_fontname.
(xic_set_xfontset): Ditto.
* src/xterm.c (xim_destroy_callback): Use xic_delete_fontset.
*** diff-old/src/xfns.c 2004-10-11 00:24:05.000000000 +0200
--- diff-new/src/xfns.c 2004-10-11 00:18:09.000000000 +0200
***************
*** 1953,1959 ****
--- 1953,1970 ----
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)
+ && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
+ return FRAME_XIC_FONTSET (cf);
+ }
+
+ /* New fontset. */
xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
base_fontname, &missing_list,
&missing_count, &def_string);
***************
*** 1964,1969 ****
--- 1975,2003 ----
return xfs;
}
+ /* Free the X fontset of frame F if it is the last frame using it. */
+
+ void
+ xic_delete_xfontset (f)
+ struct frame *f;
+ {
+ Lisp_Object rest, frame;
+
+ 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_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f))
+ return;
+ }
+ /* The fontset is not used anymore. It is safe to free it. */
+ XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
+ }
+
/* Value is the best input style, given user preferences USER (already
checked to be supported by Emacs), and styles supported by the
***************
*** 2101,2106 ****
--- 2135,2141 ----
FRAME_XIC (f) = xic;
FRAME_XIC_STYLE (f) = xic_style;
FRAME_XIC_FONTSET (f) = xfs;
+ FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
}
***************
*** 2114,2124 ****
return;
XDestroyIC (FRAME_XIC (f));
! if (FRAME_XIC_FONTSET (f))
! XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
FRAME_XIC (f) = NULL;
FRAME_XIC_FONTSET (f) = NULL;
}
--- 2149,2161 ----
return;
XDestroyIC (FRAME_XIC (f));
! xic_delete_xfontset (f);
! if (FRAME_XIC_BASE_FONTNAME (f))
! xfree (FRAME_XIC_BASE_FONTNAME (f));
FRAME_XIC (f) = NULL;
FRAME_XIC_FONTSET (f) = NULL;
+ FRAME_XIC_BASE_FONTNAME (f) = NULL;
}
***************
*** 2207,2214 ****
XFree (attr);
if (FRAME_XIC_FONTSET (f))
! XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
FRAME_XIC_FONTSET (f) = xfs;
}
#endif /* HAVE_X_I18N */
--- 2244,2256 ----
XFree (attr);
if (FRAME_XIC_FONTSET (f))
! xic_delete_xfontset (f);
!
! if (FRAME_XIC_BASE_FONTNAME (f))
! xfree (FRAME_XIC_BASE_FONTNAME (f));
!
FRAME_XIC_FONTSET (f) = xfs;
+ FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
}
#endif /* HAVE_X_I18N */
--
Károly
pgpaHc_kiYdrz.pgp
Description: PGP signature