aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Colascione2014-03-23 04:35:21 -0700
committerDaniel Colascione2014-03-23 04:35:21 -0700
commitd2933655023701a8f994d0887ea07b5fef5066c2 (patch)
tree962ea4cbced52992b537859c5ec6b1868a2f0712
parentdf3964ce56e2ceb4aa528098db5dada1a9222954 (diff)
downloademacs-d2933655023701a8f994d0887ea07b5fef5066c2.tar.gz
emacs-d2933655023701a8f994d0887ea07b5fef5066c2.zip
Further improve create_frame_xic patch
-rw-r--r--src/ChangeLog3
-rw-r--r--src/xfns.c131
2 files changed, 75 insertions, 59 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 509875d87ea..951c4b7887f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -2,7 +2,8 @@
2 2
3 * xfns.c (create_frame_xic): Pass XNStatusAttributes to XCreateIC 3 * xfns.c (create_frame_xic): Pass XNStatusAttributes to XCreateIC
4 only if xic_style calls for it. This change allows Emacs to work 4 only if xic_style calls for it. This change allows Emacs to work
5 with ibus. Also, don't leak resources if create_frame_xic fails. 5 with ibus. Also, don't leak resources if create_frame_xic fails,
6 and stop caching xic_style across different displays.
6 7
72014-03-23 Daniel Colascione <dancol@dancol.org> 82014-03-23 Daniel Colascione <dancol@dancol.org>
8 9
diff --git a/src/xfns.c b/src/xfns.c
index 7f4fc365833..c29a17138f3 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1956,8 +1956,6 @@ best_xim_style (XIMStyles *user, XIMStyles *xim)
1956 1956
1957/* Create XIC for frame F. */ 1957/* Create XIC for frame F. */
1958 1958
1959static XIMStyle xic_style;
1960
1961void 1959void
1962create_frame_xic (struct frame *f) 1960create_frame_xic (struct frame *f)
1963{ 1961{
@@ -1969,29 +1967,34 @@ create_frame_xic (struct frame *f)
1969 XRectangle s_area; 1967 XRectangle s_area;
1970 XPoint spot; 1968 XPoint spot;
1971 XIMStyles supported_list; 1969 XIMStyles supported_list;
1970 XIMStyle xic_style;
1972 1971
1973 if (FRAME_XIC (f)) 1972 if (FRAME_XIC (f))
1974 return; 1973 goto out;
1975
1976 /* Create X fontset. */
1977 xfs = xic_create_xfontset (f);
1978 FRAME_XIC_FONTSET (f) = xfs;
1979 1974
1980 xim = FRAME_X_XIM (f); 1975 xim = FRAME_X_XIM (f);
1981 if (xim) 1976 if (!xim)
1977 goto out;
1978
1979 /* Determine XIC style. */
1980 supported_list.count_styles = (sizeof supported_xim_styles
1981 / sizeof supported_xim_styles[0]);
1982 supported_list.supported_styles = supported_xim_styles;
1983 xic_style = best_xim_style (&supported_list, FRAME_X_XIM_STYLES (f));
1984
1985 /* Create X fontset. */
1986 if (xic_style & (XIMPreeditPosition | XIMStatusArea))
1982 { 1987 {
1983 spot.x = 0; spot.y = 1; 1988 xfs = xic_create_xfontset (f);
1989 if (!xfs)
1990 goto out;
1984 1991
1985 /* Determine XIC style. */ 1992 FRAME_XIC_FONTSET (f) = xfs;
1986 if (xic_style == 0) 1993 }
1987 {
1988 supported_list.count_styles = (sizeof supported_xim_styles
1989 / sizeof supported_xim_styles[0]);
1990 supported_list.supported_styles = supported_xim_styles;
1991 xic_style = best_xim_style (&supported_list,
1992 FRAME_X_XIM_STYLES (f));
1993 }
1994 1994
1995 if (xic_style & XIMPreeditPosition)
1996 {
1997 spot.x = 0; spot.y = 1;
1995 preedit_attr = XVaCreateNestedList (0, 1998 preedit_attr = XVaCreateNestedList (0,
1996 XNFontSet, xfs, 1999 XNFontSet, xfs,
1997 XNForeground, 2000 XNForeground,
@@ -2006,50 +2009,62 @@ create_frame_xic (struct frame *f)
2006 2009
2007 if (!preedit_attr) 2010 if (!preedit_attr)
2008 goto out; 2011 goto out;
2012 }
2009 2013
2010 if (xic_style & XIMStatusArea) 2014 if (xic_style & XIMStatusArea)
2011 { 2015 {
2012 s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1; 2016 s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
2013 status_attr = XVaCreateNestedList (0, 2017 status_attr = XVaCreateNestedList (0,
2014 XNArea, 2018 XNArea,
2015 &s_area, 2019 &s_area,
2016 XNFontSet, 2020 XNFontSet,
2017 xfs, 2021 xfs,
2018 XNForeground, 2022 XNForeground,
2019 FRAME_FOREGROUND_PIXEL (f), 2023 FRAME_FOREGROUND_PIXEL (f),
2020 XNBackground, 2024 XNBackground,
2021 FRAME_BACKGROUND_PIXEL (f), 2025 FRAME_BACKGROUND_PIXEL (f),
2022 NULL); 2026 NULL);
2023 2027
2024 if (!status_attr) 2028 if (!status_attr)
2025 goto out;
2026
2027 xic = XCreateIC (xim,
2028 XNInputStyle, xic_style,
2029 XNClientWindow, FRAME_X_WINDOW (f),
2030 XNFocusWindow, FRAME_X_WINDOW (f),
2031 XNStatusAttributes, status_attr,
2032 XNPreeditAttributes, preedit_attr,
2033 NULL);
2034 }
2035 else
2036 {
2037 xic = XCreateIC (xim,
2038 XNInputStyle, xic_style,
2039 XNClientWindow, FRAME_X_WINDOW (f),
2040 XNFocusWindow, FRAME_X_WINDOW (f),
2041 XNPreeditAttributes, preedit_attr,
2042 NULL);
2043 }
2044
2045 if (!xic)
2046 goto out; 2029 goto out;
2047
2048 FRAME_XIC (f) = xic;
2049 FRAME_XIC_STYLE (f) = xic_style;
2050 xfs = NULL; /* Don't free below. */
2051 } 2030 }
2052 2031
2032 if (preedit_attr && status_attr)
2033 xic = XCreateIC (xim,
2034 XNInputStyle, xic_style,
2035 XNClientWindow, FRAME_X_WINDOW (f),
2036 XNFocusWindow, FRAME_X_WINDOW (f),
2037 XNStatusAttributes, status_attr,
2038 XNPreeditAttributes, preedit_attr,
2039 NULL);
2040 else if (preedit_attr)
2041 xic = XCreateIC (xim,
2042 XNInputStyle, xic_style,
2043 XNClientWindow, FRAME_X_WINDOW (f),
2044 XNFocusWindow, FRAME_X_WINDOW (f),
2045 XNPreeditAttributes, preedit_attr,
2046 NULL);
2047 else if (status_attr)
2048 xic = XCreateIC (xim,
2049 XNInputStyle, xic_style,
2050 XNClientWindow, FRAME_X_WINDOW (f),
2051 XNFocusWindow, FRAME_X_WINDOW (f),
2052 XNStatusAttributes, status_attr,
2053 NULL);
2054 else
2055 xic = XCreateIC (xim,
2056 XNInputStyle, xic_style,
2057 XNClientWindow, FRAME_X_WINDOW (f),
2058 XNFocusWindow, FRAME_X_WINDOW (f),
2059 NULL);
2060
2061 if (!xic)
2062 goto out;
2063
2064 FRAME_XIC (f) = xic;
2065 FRAME_XIC_STYLE (f) = xic_style;
2066 xfs = NULL; /* Don't free below. */
2067
2053 out: 2068 out:
2054 2069
2055 if (xfs) 2070 if (xfs)