/[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.615 by jhd, Mon Oct 11 10:50:00 2004 UTC revision 1.616 by jhd, Thu Oct 21 18:38:57 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;
1953    int missing_count;    int missing_count;
1954    char *def_string;    char *def_string;
1955      Lisp_Object rest, frame;
1956    
1957    xfs = XCreateFontSet (FRAME_X_DISPLAY (f),    /* See if there is another frame already using same fontset.  */
1958                          base_fontname, &missing_list,    FOR_EACH_FRAME (rest, frame)
1959                          &missing_count, &def_string);      {
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        /* New fontset.  */
1972        xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
1973                              base_fontname, &missing_list,
1974                              &missing_count, &def_string);
1975    if (missing_list)    if (missing_list)
1976      XFreeStringList (missing_list);      XFreeStringList (missing_list);
1977    
1978    /* No need to free def_string. */    if (FRAME_XIC_BASE_FONTNAME (f))
1979        xfree (FRAME_XIC_BASE_FONTNAME (f));
1980      FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
1981    
1982      /* No need to free def_string.  */
1983    return xfs;    return xfs;
1984  }  }
1985    
1986    /* Free the X fontset of frame F if it is the last frame using it.  */
1987    
1988    void
1989    xic_free_xfontset (f)
1990         struct frame *f;
1991    {
1992      Lisp_Object rest, frame;
1993      int shared_p = 0;
1994    
1995      if (!FRAME_XIC_FONTSET (f))
1996        return;
1997    
1998      /* See if there is another frame sharing the same fontset.  */
1999      FOR_EACH_FRAME (rest, frame)
2000        {
2001          struct frame *cf = XFRAME (frame);
2002          if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
2003              && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
2004              && FRAME_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f))
2005            {
2006              shared_p = 1;
2007              break;
2008            }
2009        }
2010    
2011      if (!shared_p)
2012        /* The fontset is not used anymore.  It is safe to free it.  */
2013        XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2014    
2015      if (FRAME_XIC_BASE_FONTNAME (f))
2016        xfree (FRAME_XIC_BASE_FONTNAME (f));
2017      FRAME_XIC_BASE_FONTNAME (f) = NULL;
2018      FRAME_XIC_FONTSET (f) = NULL;
2019    }
2020    
2021    
2022  /* Value is the best input style, given user preferences USER (already  /* Value is the best input style, given user preferences USER (already
2023     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 2168  free_frame_xic (f)
2168      return;      return;
2169    
2170    XDestroyIC (FRAME_XIC (f));    XDestroyIC (FRAME_XIC (f));
2171    if (FRAME_XIC_FONTSET (f))    xic_free_xfontset (f);
     XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));  
2172    
2173    FRAME_XIC (f) = NULL;    FRAME_XIC (f) = NULL;
   FRAME_XIC_FONTSET (f) = NULL;  
2174  }  }
2175    
2176    
# Line 2197  xic_set_xfontset (f, base_fontname) Line 2249  xic_set_xfontset (f, base_fontname)
2249    XVaNestedList attr;    XVaNestedList attr;
2250    XFontSet xfs;    XFontSet xfs;
2251    
2252      xic_free_xfontset (f);
2253    
2254    xfs = xic_create_xfontset (f, base_fontname);    xfs = xic_create_xfontset (f, base_fontname);
2255    
2256    attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);    attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);
# Line 2206  xic_set_xfontset (f, base_fontname) Line 2260  xic_set_xfontset (f, base_fontname)
2260      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
2261    XFree (attr);    XFree (attr);
2262    
   if (FRAME_XIC_FONTSET (f))  
     XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));  
2263    FRAME_XIC_FONTSET (f) = xfs;    FRAME_XIC_FONTSET (f) = xfs;
2264  }  }
2265    

Legend:
Removed from v.1.615  
changed lines
  Added in v.1.616

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