all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Karoly.Lorentey@cern.ch (Lőrentey Károly)
Cc: emacs-devel@gnu.org
Subject: Re: x-create-frame is sluggish
Date: Mon, 11 Oct 2004 00:45:01 +0200	[thread overview]
Message-ID: <lorentey.g.e.devel.87is9iw5ua.elte@eris.elte.hu> (raw)
In-Reply-To: <lorentey.m.other.87mzz63jo3.elte@eris.elte.hu> (Károly	Lőrentey's message of "Fri, 01 Oct 2004 10:51:56 +0200")


[-- Attachment #1.1.1: Type: text/plain, Size: 1220 bytes --]

Lőrentey Károly <Karoly.Lorentey@cern.ch> writes:
> Kenichi Handa <handa@m17n.org> 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
lorentey@elte.hu--2004/emacs--fontset-cache--0--patch-3.)

2004-10-11  Károly Lőrentey  <lorentey@elte.hu>

	* 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: fontset.context.patch --]
[-- Type: text/x-patch, Size: 2915 bytes --]

*** 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 */

[-- Attachment #1.1.3: Type: text/plain, Size: 16 bytes --]


-- 
Károly

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2004-10-10 22:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-23 14:15 x-create-frame is sluggish Lőrentey Károly
2004-09-24 12:08 ` Richard Stallman
2004-09-25  2:39 ` Kenichi Handa
2004-09-25 15:36   ` Richard Stallman
2004-10-01  1:26     ` Kenichi Handa
2004-10-01  8:51       ` Károly Lőrentey
2004-10-10 22:45         ` Lőrentey Károly [this message]
2004-10-11  7:54           ` Jan D.
2004-10-11 14:53             ` Károly Lőrentey
2004-10-11 19:51               ` Jan D.
2004-10-11 20:03                 ` Jan D.
2004-10-25 13:07               ` Lőrentey Károly
2004-10-25 13:16                 ` Jan D.
2004-10-03 14:32       ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lorentey.g.e.devel.87is9iw5ua.elte@eris.elte.hu \
    --to=karoly.lorentey@cern.ch \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.