From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Karoly.Lorentey@cern.ch (=?utf-8?Q?K=C3=A1roly_L=C5=91rentey?=) Newsgroups: gmane.emacs.devel Subject: Re: x-create-frame is sluggish Date: Mon, 11 Oct 2004 16:53:32 +0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: <200409250239.LAA15347@etlken.m17n.org> <200410010126.KAA01376@etlken.m17n.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0496582814==" X-Trace: sea.gmane.org 1097506479 27906 80.91.229.6 (11 Oct 2004 14:54:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 11 Oct 2004 14:54:39 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 11 16:54:27 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CH1ZC-0004iX-00 for ; Mon, 11 Oct 2004 16:54:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CH1g9-0003Gq-14 for ged-emacs-devel@m.gmane.org; Mon, 11 Oct 2004 11:01:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CH1fd-0003A8-VA for emacs-devel@gnu.org; Mon, 11 Oct 2004 11:01:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CH1fb-00038y-SQ for emacs-devel@gnu.org; Mon, 11 Oct 2004 11:01:04 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CH1fb-00038u-Ny for emacs-devel@gnu.org; Mon, 11 Oct 2004 11:01:03 -0400 Original-Received: from [157.181.1.137] (helo=mx1.elte.hu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CH1Ya-0008Ke-AB; Mon, 11 Oct 2004 10:53:49 -0400 Original-Received: from mailbox1.caesar.elte.hu (mailbox1.caesar.elte.hu [157.181.151.157]) by mx1.elte.hu (Postfix) with ESMTP id B2AAD2427FF; Mon, 11 Oct 2004 16:51:36 +0200 (CEST) Original-Received: from eris.fnord.hu (pcitislory.cern.ch [137.138.41.46]) by mailbox1.caesar.elte.hu (Postfix) with ESMTP id 53D6BA079701; Mon, 11 Oct 2004 16:53:33 +0200 (CEST) Original-Received: by eris.fnord.hu (Postfix, from userid 1000) id 732CA313; Mon, 11 Oct 2004 16:53:32 +0200 (CEST) Original-To: "Jan D." In-Reply-To: (Jan D.'s message of "Mon, 11 Oct 2004 09:54:00 +0200") User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) X-ELTE-SpamVersion: MailScanner 4.31.6-itk1 (ELTE 1.2) SpamAssassin 2.63 ClamAV 0.73 X-ELTE-VirusStatus: clean X-ELTE-SpamCheck: no X-ELTE-SpamCheck-Details: score=-4.9, required 5.9, autolearn=not spam, BAYES_00 -4.90 X-ELTE-SpamLevel: X-ELTE-SpamScore: -4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:28233 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:28233 --===============0496582814== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jan Dj=C3=A4rv writes: >> + if (cf !=3D f && FRAME_LIVE_P (f) && FRAME_X_P (cf) >> + && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname)) >> + return FRAME_XIC_FONTSET (cf); >> + } > > You must check that the frames sharing the fontset is on the same=20 > display. >> + if (cf !=3D f && FRAME_LIVE_P (f) && FRAME_X_P (cf) >> + && FRAME_XIC_FONTSET (cf) =3D=3D FRAME_XIC_FONTSET (f)) >> + return; > > And here also. > > You did not include diffs for xterm.c and xterm.h. It looks like I messed up something while preparing my email. How embarassing! Here is a revised patch that incorporates your points, adds the missing patches and fixes a syntax error that somehow crept into create_frame_xic. 2004-10-11 K=C3=A1roly L=C5=91rentey * 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 xic_base_fontname. (xic_delete_xfontset): New function. (free_frame_xic): Use it. Free xic_base_fontname. (xic_set_xfontset): Ditto. * src/xterm.c (xim_destroy_callback): Ditto. --=-=-= Content-Type: text/x-patch Content-Disposition: inline *** orig/src/xfns.c --- mod/src/xfns.c *************** *** 1953,1959 **** --- 1953,1971 ---- 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)) + return FRAME_XIC_FONTSET (cf); + } + + /* New fontset. */ xfs = XCreateFontSet (FRAME_X_DISPLAY (f), base_fontname, &missing_list, &missing_count, &def_string); *************** *** 1964,1969 **** --- 1976,2005 ---- 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_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f) + && 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 *************** *** 1996,2001 **** --- 2032,2038 ---- XIM xim; XIC xic = NULL; XFontSet xfs = NULL; + char *base_fontname = NULL; if (FRAME_XIC (f)) return; *************** *** 2007,2013 **** XPoint spot; XVaNestedList preedit_attr; XVaNestedList status_attr; - char *base_fontname; int fontset; s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1; --- 2044,2049 ---- *************** *** 2101,2106 **** --- 2137,2143 ---- 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; } --- 2151,2163 ---- 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 */ --- 2246,2258 ---- 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 */ *** orig/src/xterm.c --- mod/src/xterm.c *************** *** 8024,8031 **** FRAME_XIC (f) = NULL; if (FRAME_XIC_FONTSET (f)) { ! XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f)); FRAME_XIC_FONTSET (f) = NULL; } } } --- 8024,8033 ---- FRAME_XIC (f) = NULL; if (FRAME_XIC_FONTSET (f)) { ! xic_delete_xfontset (f); ! xfree (FRAME_XIC_BASE_FONTNAME (f)); FRAME_XIC_FONTSET (f) = NULL; + FRAME_XIC_BASE_FONTNAME (f) = NULL; } } } *** orig/src/xterm.h --- mod/src/xterm.h *************** *** 593,598 **** --- 593,599 ---- XIC xic; XIMStyle xic_style; XFontSet xic_xfs; + char *xic_base_fontname; #endif /* Relief GCs, colors etc. */ *************** *** 727,732 **** --- 728,734 ---- #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. */ *************** *** 1036,1041 **** --- 1038,1044 ---- 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_delete_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)); --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =2D-=20 K=C3=A1roly --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBBap5s6eoyqA+yej8RAmbXAKCwDOLxdlkVHtXZk2POUlNY6cSbNACfQDtO eM05WGAoxGxhPWRH/mlkDj8= =3i5b -----END PGP SIGNATURE----- --==-=-=-- --===============0496582814== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0496582814==--