aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Colascione2014-03-23 03:56:30 -0700
committerDaniel Colascione2014-03-23 03:56:30 -0700
commitdf3964ce56e2ceb4aa528098db5dada1a9222954 (patch)
treee25a429c6de8e3f81f7d59e30fd50e0f27ef2b9d /src
parentb27a404396a312f13f3cc9318a427a3a87d33a6c (diff)
downloademacs-df3964ce56e2ceb4aa528098db5dada1a9222954.tar.gz
emacs-df3964ce56e2ceb4aa528098db5dada1a9222954.zip
Improve XIC fix
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/xfns.c102
2 files changed, 65 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e468197c968..509875d87ea 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,8 @@
12014-03-23 Daniel Colascione <dancol@dancol.org> 12014-03-23 Daniel Colascione <dancol@dancol.org>
2 2
3 * xfns.c (create_frame_xic): If XCreateIC fails, try again without 3 * xfns.c (create_frame_xic): Pass XNStatusAttributes to XCreateIC
4 XNStatusAttributes; works around flaky XIM modules, apparently. 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 6
62014-03-23 Daniel Colascione <dancol@dancol.org> 72014-03-23 Daniel Colascione <dancol@dancol.org>
7 8
diff --git a/src/xfns.c b/src/xfns.c
index de92baa3ce6..7f4fc365833 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1964,27 +1964,27 @@ create_frame_xic (struct frame *f)
1964 XIM xim; 1964 XIM xim;
1965 XIC xic = NULL; 1965 XIC xic = NULL;
1966 XFontSet xfs = NULL; 1966 XFontSet xfs = NULL;
1967 XVaNestedList status_attr = NULL;
1968 XVaNestedList preedit_attr = NULL;
1969 XRectangle s_area;
1970 XPoint spot;
1971 XIMStyles supported_list;
1967 1972
1968 if (FRAME_XIC (f)) 1973 if (FRAME_XIC (f))
1969 return; 1974 return;
1970 1975
1971 /* Create X fontset. */ 1976 /* Create X fontset. */
1972 xfs = xic_create_xfontset (f); 1977 xfs = xic_create_xfontset (f);
1978 FRAME_XIC_FONTSET (f) = xfs;
1979
1973 xim = FRAME_X_XIM (f); 1980 xim = FRAME_X_XIM (f);
1974 if (xim) 1981 if (xim)
1975 { 1982 {
1976 XRectangle s_area;
1977 XPoint spot;
1978 XVaNestedList preedit_attr;
1979 XVaNestedList status_attr;
1980
1981 s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
1982 spot.x = 0; spot.y = 1; 1983 spot.x = 0; spot.y = 1;
1983 1984
1984 /* Determine XIC style. */ 1985 /* Determine XIC style. */
1985 if (xic_style == 0) 1986 if (xic_style == 0)
1986 { 1987 {
1987 XIMStyles supported_list;
1988 supported_list.count_styles = (sizeof supported_xim_styles 1988 supported_list.count_styles = (sizeof supported_xim_styles
1989 / sizeof supported_xim_styles[0]); 1989 / sizeof supported_xim_styles[0]);
1990 supported_list.supported_styles = supported_xim_styles; 1990 supported_list.supported_styles = supported_xim_styles;
@@ -2003,41 +2003,63 @@ create_frame_xic (struct frame *f)
2003 : NULL), 2003 : NULL),
2004 &spot, 2004 &spot,
2005 NULL); 2005 NULL);
2006 status_attr = XVaCreateNestedList (0, 2006
2007 XNArea, 2007 if (!preedit_attr)
2008 &s_area, 2008 goto out;
2009 XNFontSet, 2009
2010 xfs, 2010 if (xic_style & XIMStatusArea)
2011 XNForeground, 2011 {
2012 FRAME_FOREGROUND_PIXEL (f), 2012 s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
2013 XNBackground, 2013 status_attr = XVaCreateNestedList (0,
2014 FRAME_BACKGROUND_PIXEL (f), 2014 XNArea,
2015 NULL); 2015 &s_area,
2016 2016 XNFontSet,
2017 xic = XCreateIC (xim, 2017 xfs,
2018 XNInputStyle, xic_style, 2018 XNForeground,
2019 XNClientWindow, FRAME_X_WINDOW (f), 2019 FRAME_FOREGROUND_PIXEL (f),
2020 XNFocusWindow, FRAME_X_WINDOW (f), 2020 XNBackground,
2021 XNStatusAttributes, status_attr, 2021 FRAME_BACKGROUND_PIXEL (f),
2022 XNPreeditAttributes, preedit_attr, 2022 NULL);
2023 NULL); 2023
2024 2024 if (!status_attr)
2025 /* Some input methods don't support a status pixel. */ 2025 goto out;
2026 if (xic == NULL) 2026
2027 xic = XCreateIC (xim, 2027 xic = XCreateIC (xim,
2028 XNInputStyle, xic_style, 2028 XNInputStyle, xic_style,
2029 XNClientWindow, FRAME_X_WINDOW (f), 2029 XNClientWindow, FRAME_X_WINDOW (f),
2030 XNFocusWindow, FRAME_X_WINDOW (f), 2030 XNFocusWindow, FRAME_X_WINDOW (f),
2031 XNPreeditAttributes, preedit_attr, 2031 XNStatusAttributes, status_attr,
2032 NULL); 2032 XNPreeditAttributes, preedit_attr,
2033 2033 NULL);
2034 XFree (preedit_attr); 2034 }
2035 XFree (status_attr); 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;
2047
2048 FRAME_XIC (f) = xic;
2049 FRAME_XIC_STYLE (f) = xic_style;
2050 xfs = NULL; /* Don't free below. */
2036 } 2051 }
2037 2052
2038 FRAME_XIC (f) = xic; 2053 out:
2039 FRAME_XIC_STYLE (f) = xic_style; 2054
2040 FRAME_XIC_FONTSET (f) = xfs; 2055 if (xfs)
2056 free_frame_xic (f);
2057
2058 if (preedit_attr)
2059 XFree (preedit_attr);
2060
2061 if (status_attr)
2062 XFree (status_attr);
2041} 2063}
2042 2064
2043 2065