]> git.eshelyaron.com Git - emacs.git/commitdiff
Further improve XIM init
authorDaniel Colascione <dancol@dancol.org>
Sun, 23 Mar 2014 11:45:17 +0000 (04:45 -0700)
committerDaniel Colascione <dancol@dancol.org>
Sun, 23 Mar 2014 11:45:17 +0000 (04:45 -0700)
1  2 
src/ChangeLog
src/xfns.c

diff --cc src/ChangeLog
index 509875d87ea5cc26342ad81122353f101bc29254,951c4b7887fd9dcbef5d9435d3bceddcf7da850a..dc07ba0b320339b70dc7c6c79b49f476ab1eb420
@@@ -2,7 -2,8 +2,12 @@@
  
        * xfns.c (create_frame_xic): Pass XNStatusAttributes to XCreateIC
        only if xic_style calls for it.  This change allows Emacs to work
-       with ibus.  Also, don't leak resources if create_frame_xic fails.
+       with ibus.  Also, don't leak resources if create_frame_xic fails,
+       and stop caching xic_style across different displays.
++      (supported_xim_styles): Make const.
++      (best_xim_style): Remove first parameter: it's always just
++      supported_xim_styles.  Change to look at supported_xim_styles
++      directly.
  
  2014-03-23  Daniel Colascione  <dancol@dancol.org>
  
diff --cc src/xfns.c
index 7f4fc365833beaa1989e4fc47f1fb2eb58a13eb2,c29a17138f319ea5214929f3454468ac6e7e5c3b..692504ef762891080ec1b53eea94ec66a98bb84d
@@@ -1641,12 -1641,12 +1641,12 @@@ hack_wm_protocols (struct frame *f, Wid
  #ifdef HAVE_X_I18N
  
  static XFontSet xic_create_xfontset (struct frame *);
--static XIMStyle best_xim_style (XIMStyles *, XIMStyles *);
++static XIMStyle best_xim_style (XIMStyles *);
  
  
  /* Supported XIM styles, ordered by preference.  */
  
--static XIMStyle supported_xim_styles[] =
++static const XIMStyle supported_xim_styles[] =
  {
    XIMPreeditPosition | XIMStatusArea,
    XIMPreeditPosition | XIMStatusNothing,
@@@ -1941,14 -1941,14 +1941,16 @@@ xic_free_xfontset (struct frame *f
     input method XIM.  */
  
  static XIMStyle
--best_xim_style (XIMStyles *user, XIMStyles *xim)
++best_xim_style (XIMStyles *xim)
  {
    int i, j;
++  int nr_supported =
++    sizeof (supported_xim_styles) / sizeof (supported_xim_styles[0]);
  
--  for (i = 0; i < user->count_styles; ++i)
++  for (i = 0; i < nr_supported; ++i)
      for (j = 0; j < xim->count_styles; ++j)
--      if (user->supported_styles[i] == xim->supported_styles[j])
--      return user->supported_styles[i];
++      if (supported_xim_styles[i] == xim->supported_styles[j])
++      return supported_xim_styles[i];
  
    /* Return the default style.  */
    return XIMPreeditNothing | XIMStatusNothing;
@@@ -1968,30 -1966,35 +1968,31 @@@ create_frame_xic (struct frame *f
    XVaNestedList preedit_attr = NULL;
    XRectangle s_area;
    XPoint spot;
--  XIMStyles supported_list;
+   XIMStyle xic_style;
  
    if (FRAME_XIC (f))
-     return;
-   /* Create X fontset. */
-   xfs = xic_create_xfontset (f);
-   FRAME_XIC_FONTSET (f) = xfs;
+     goto out;
  
    xim = FRAME_X_XIM (f);
-   if (xim)
+   if (!xim)
+     goto out;
+   /* Determine XIC style.  */
 -  supported_list.count_styles = (sizeof supported_xim_styles
 -                                 / sizeof supported_xim_styles[0]);
 -  supported_list.supported_styles = supported_xim_styles;
 -  xic_style = best_xim_style (&supported_list, FRAME_X_XIM_STYLES (f));
++  xic_style = best_xim_style (FRAME_X_XIM_STYLES (f));
+   /* Create X fontset. */
+   if (xic_style & (XIMPreeditPosition | XIMStatusArea))
      {
-       spot.x = 0; spot.y = 1;
+       xfs = xic_create_xfontset (f);
+       if (!xfs)
+         goto out;
  
-       /* Determine XIC style.  */
-       if (xic_style == 0)
-       {
-         supported_list.count_styles = (sizeof supported_xim_styles
-                                        / sizeof supported_xim_styles[0]);
-         supported_list.supported_styles = supported_xim_styles;
-         xic_style = best_xim_style (&supported_list,
-                                     FRAME_X_XIM_STYLES (f));
-       }
+       FRAME_XIC_FONTSET (f) = xfs;
+     }
  
+   if (xic_style & XIMPreeditPosition)
+     {
+       spot.x = 0; spot.y = 1;
        preedit_attr = XVaCreateNestedList (0,
                                          XNFontSet, xfs,
                                          XNForeground,