/[emacs]/emacs/src/xfns.c
ViewVC logotype

Diff of /emacs/src/xfns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.549.2.15 by miles, Mon Oct 25 04:19:36 2004 UTC revision 1.549.2.16 by miles, Mon Oct 25 04:22:27 2004 UTC
# Line 1941  static XIMStyle supported_xim_styles[] = Line 1941  static XIMStyle supported_xim_styles[] =
1941  };  };
1942    
1943    
1944  /* Create an X fontset on frame F with base font name  /* Create an X fontset on frame F with base font name BASE_FONTNAME.  */
    BASE_FONTNAME.. */  
1945    
1946  static XFontSet  static XFontSet
1947  xic_create_xfontset (f, base_fontname)  xic_create_xfontset (f, base_fontname)
1948       struct frame *f;       struct frame *f;
1949       char *base_fontname;       char *base_fontname;
1950  {  {
1951    XFontSet xfs;    XFontSet xfs = NULL;
1952    char **missing_list;    char **missing_list = NULL;
1953    int missing_count;    int missing_count;
1954    char *def_string;    char *def_string;
1955      Lisp_Object rest, frame;
1956    
1957      /* See if there is another frame already using same fontset.  */
1958      FOR_EACH_FRAME (rest, frame)
1959        {
1960          struct frame *cf = XFRAME (frame);
1961          if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
1962              && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
1963              && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
1964            {
1965              xfs = FRAME_XIC_FONTSET (cf);
1966              break;
1967            }
1968        }
1969    
1970      if (!xfs)
1971        {
1972          /* New fontset.  */
1973          xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
1974                                base_fontname, &missing_list,
1975                                &missing_count, &def_string);
1976          if (missing_list)
1977            XFreeStringList (missing_list);
1978        }
1979    
1980    xfs = XCreateFontSet (FRAME_X_DISPLAY (f),    if (FRAME_XIC_BASE_FONTNAME (f))
1981                          base_fontname, &missing_list,      xfree (FRAME_XIC_BASE_FONTNAME (f));
1982                          &missing_count, &def_string);    FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
   if (missing_list)  
     XFreeStringList (missing_list);  
1983    
1984    /* No need to free def_string. */    /* No need to free def_string.  */
1985    return xfs;    return xfs;
1986  }  }
1987    
1988    /* Free the X fontset of frame F if it is the last frame using it.  */
1989    
1990    void
1991    xic_free_xfontset (f)
1992         struct frame *f;
1993    {
1994      Lisp_Object rest, frame;
1995      int shared_p = 0;
1996    
1997      if (!FRAME_XIC_FONTSET (f))
1998        return;
1999    
2000      /* See if there is another frame sharing the same fontset.  */
2001      FOR_EACH_FRAME (rest, frame)
2002        {
2003          struct frame *cf = XFRAME (frame);
2004          if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
2005              && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
2006              && FRAME_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f))
2007            {
2008              shared_p = 1;
2009              break;
2010            }
2011        }
2012    
2013      if (!shared_p)
2014        /* The fontset is not used anymore.  It is safe to free it.  */
2015        XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2016    
2017      if (FRAME_XIC_BASE_FONTNAME (f))
2018        xfree (FRAME_XIC_BASE_FONTNAME (f));
2019      FRAME_XIC_BASE_FONTNAME (f) = NULL;
2020      FRAME_XIC_FONTSET (f) = NULL;
2021    }
2022    
2023    
2024  /* Value is the best input style, given user preferences USER (already  /* Value is the best input style, given user preferences USER (already
2025     checked to be supported by Emacs), and styles supported by the     checked to be supported by Emacs), and styles supported by the
# Line 2114  free_frame_xic (f) Line 2170  free_frame_xic (f)
2170      return;      return;
2171    
2172    XDestroyIC (FRAME_XIC (f));    XDestroyIC (FRAME_XIC (f));
2173    if (FRAME_XIC_FONTSET (f))    xic_free_xfontset (f);
     XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));  
2174    
2175    FRAME_XIC (f) = NULL;    FRAME_XIC (f) = NULL;
   FRAME_XIC_FONTSET (f) = NULL;  
2176  }  }
2177    
2178    
# Line 2197  xic_set_xfontset (f, base_fontname) Line 2251  xic_set_xfontset (f, base_fontname)
2251    XVaNestedList attr;    XVaNestedList attr;
2252    XFontSet xfs;    XFontSet xfs;
2253    
2254      xic_free_xfontset (f);
2255    
2256    xfs = xic_create_xfontset (f, base_fontname);    xfs = xic_create_xfontset (f, base_fontname);
2257    
2258    attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);    attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);
# Line 2206  xic_set_xfontset (f, base_fontname) Line 2262  xic_set_xfontset (f, base_fontname)
2262      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
2263    XFree (attr);    XFree (attr);
2264    
   if (FRAME_XIC_FONTSET (f))  
     XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));  
2265    FRAME_XIC_FONTSET (f) = xfs;    FRAME_XIC_FONTSET (f) = xfs;
2266  }  }
2267    

Legend:
Removed from v.1.549.2.15  
changed lines
  Added in v.1.549.2.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26