unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* x-create-frame is sluggish
@ 2004-09-23 14:15 Lőrentey Károly
  2004-09-24 12:08 ` Richard Stallman
  2004-09-25  2:39 ` Kenichi Handa
  0 siblings, 2 replies; 14+ messages in thread
From: Lőrentey Károly @ 2004-09-23 14:15 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 424 bytes --]

Creating a new X frame takes about two seconds on my system, which is
long enough a delay to be distracting.  My little profiling session
determined that most of this time is spent in xic_create_fontset,
calling XCreateFontSet.  Is it really necessary to create a new
fontset for each new frame?  Can I do something to speed this up?

(`xlsfonts | wc -l' reports that I have 6205 fonts on my system.)

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  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
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2004-09-24 12:08 UTC (permalink / raw)
  Cc: emacs-devel

      My little profiling session
    determined that most of this time is spent in xic_create_fontset,
    calling XCreateFontSet.  Is it really necessary to create a new
    fontset for each new frame?  Can I do something to speed this up?

It must be possible to make frames share fontsets when those are the
same.  If someone wants to work on it.

At the moment our priority is to aim for a release, not for redesigns
like this.  But if you implement this change, we will surely want to
install it sooner or later.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  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
  1 sibling, 1 reply; 14+ messages in thread
From: Kenichi Handa @ 2004-09-25  2:39 UTC (permalink / raw)
  Cc: emacs-devel

In article <lorentey.g.e.devel.871xgt6ph5.elte@eris.elte.hu>, Karoly.Lorentey@cern.ch (Lőrentey Károly) writes:
> Creating a new X frame takes about two seconds on my system, which is
> long enough a delay to be distracting.  My little profiling session
> determined that most of this time is spent in xic_create_fontset,
> calling XCreateFontSet.  Is it really necessary to create a new
> fontset for each new frame?  Can I do something to speed this up?

> (`xlsfonts | wc -l' reports that I have 6205 fonts on my system.)

I think we can cache XFontSet in struct x_display_info per
each base_fontname.  Then we can avoid calling of
XCreateFontSet when we create a new frame on the same
display with the same font.

---
Ken'ichi HANDA
handa@m17n.org

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-09-25  2:39 ` Kenichi Handa
@ 2004-09-25 15:36   ` Richard Stallman
  2004-10-01  1:26     ` Kenichi Handa
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2004-09-25 15:36 UTC (permalink / raw)
  Cc: Karoly.Lorentey, emacs-devel

    I think we can cache XFontSet in struct x_display_info per
    each base_fontname.  Then we can avoid calling of
    XCreateFontSet when we create a new frame on the same
    display with the same font.

Do you want to implement this?

Would it be a big or unreliable change,
that we would not want to install now?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  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-03 14:32       ` Richard Stallman
  0 siblings, 2 replies; 14+ messages in thread
From: Kenichi Handa @ 2004-10-01  1:26 UTC (permalink / raw)
  Cc: Karoly.Lorentey, emacs-devel

In article <E1CBEal-0007jA-DH@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:

>     I think we can cache XFontSet in struct x_display_info per
>     each base_fontname.  Then we can avoid calling of
>     XCreateFontSet when we create a new frame on the same
>     display with the same font.

> Do you want to implement this?

> Would it be a big or unreliable change,
> that we would not want to install now?

I think the change is straight forward and not that big.
But, for the moment, I'm too heavily overloaded to work on
it. :-(

---
Ken'ichi HANDA
handa@m17n.org

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  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
  2004-10-03 14:32       ` Richard Stallman
  1 sibling, 1 reply; 14+ messages in thread
From: Károly Lőrentey @ 2004-10-01  8:51 UTC (permalink / raw)
  Cc: rms, emacs-devel

Kenichi Handa <handa@m17n.org> writes:
> In article <E1CBEal-0007jA-DH@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:
>>     I think we can cache XFontSet in struct x_display_info per
>>     each base_fontname.  Then we can avoid calling of
>>     XCreateFontSet when we create a new frame on the same
>>     display with the same font.
>
>> Do you want to implement this?
>
>> Would it be a big or unreliable change,
>> that we would not want to install now?
>
> 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.

-- 
Károly

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-10-01  1:26     ` Kenichi Handa
  2004-10-01  8:51       ` Károly Lőrentey
@ 2004-10-03 14:32       ` Richard Stallman
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2004-10-03 14:32 UTC (permalink / raw)
  Cc: Karoly.Lorentey, emacs-devel

    I think the change is straight forward and not that big.
    But, for the moment, I'm too heavily overloaded to work on
    it. :-(

Can you suggest briefly where this change would be made?
That would help someone else to do it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-10-01  8:51       ` Károly Lőrentey
@ 2004-10-10 22:45         ` Lőrentey Károly
  2004-10-11  7:54           ` Jan D.
  0 siblings, 1 reply; 14+ messages in thread
From: Lőrentey Károly @ 2004-10-10 22:45 UTC (permalink / raw)
  Cc: emacs-devel


[-- 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-10-10 22:45         ` Lőrentey Károly
@ 2004-10-11  7:54           ` Jan D.
  2004-10-11 14:53             ` Károly Lőrentey
  0 siblings, 1 reply; 14+ messages in thread
From: Jan D. @ 2004-10-11  7:54 UTC (permalink / raw)
  Cc: rms, emacs-devel

>
> *** 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);
> +     }

You must check that the frames sharing the fontset is on the same 
display.


>
> + /* 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));
> + }

And here also.

You did not include diffs for xterm.c and xterm.h.

	Jan D.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  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-25 13:07               ` Lőrentey Károly
  0 siblings, 2 replies; 14+ messages in thread
From: Károly Lőrentey @ 2004-10-11 14:53 UTC (permalink / raw)
  Cc: rms, emacs-devel


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

Jan Djärv <jan.h.d@swipnet.se> writes:
>> +       if (cf != 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 
> display.

>> +       if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
>> +           && FRAME_XIC_FONTSET (cf) == 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á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 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.


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

*** 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));

[-- 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  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
  1 sibling, 1 reply; 14+ messages in thread
From: Jan D. @ 2004-10-11 19:51 UTC (permalink / raw)
  Cc: rms, emacs-devel


> +   /* 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);

You should use FRAME_X_DISPLAY, not FRAME_X_DISPLAY_INFO everywhere.
A frame can be opened on display ":0", "unix:0", "hostname:0" and so on,
but it is still the same display.  However, they will have different 
display
info.

	Jan D.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-10-11 19:51               ` Jan D.
@ 2004-10-11 20:03                 ` Jan D.
  0 siblings, 0 replies; 14+ messages in thread
From: Jan D. @ 2004-10-11 20:03 UTC (permalink / raw)
  Cc: rms, Károly Lőrentey, emacs-devel

>
>> +   /* 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);
>
> You should use FRAME_X_DISPLAY, not FRAME_X_DISPLAY_INFO everywhere.
> A frame can be opened on display ":0", "unix:0", "hostname:0" and so 
> on,
> but it is still the same display.  However, they will have different 
> display info.

To correct myself,  FRAME_X_DISPLAY_INFO is fine, don't know what I was
thinking.

	Jan D.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-10-11 14:53             ` Károly Lőrentey
  2004-10-11 19:51               ` Jan D.
@ 2004-10-25 13:07               ` Lőrentey Károly
  2004-10-25 13:16                 ` Jan D.
  1 sibling, 1 reply; 14+ messages in thread
From: Lőrentey Károly @ 2004-10-25 13:07 UTC (permalink / raw)
  Cc: Jan D., Richard Stallman, Kenichi Handa


[-- Attachment #1.1: Type: text/plain, Size: 6507 bytes --]

Does the new patch look all right to you?  If there are no objections,
I will proceed with installing it.  I've been using it for a few weeks
without problems.

Lőrentey Károly <Karoly.Lorentey@cern.ch> writes:
> 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 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.
>
> *** 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));

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: x-create-frame is sluggish
  2004-10-25 13:07               ` Lőrentey Károly
@ 2004-10-25 13:16                 ` Jan D.
  0 siblings, 0 replies; 14+ messages in thread
From: Jan D. @ 2004-10-25 13:16 UTC (permalink / raw)
  Cc: Kenichi Handa, Richard Stallman, emacs-devel

> Does the new patch look all right to you?  If there are no objections,
> I will proceed with installing it.  I've been using it for a few weeks
> without problems.

I already installed it.

	Jan D.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-10-25 13:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).