[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 r117348: Backport from trunk.
From: |
Jan D. |
Subject: |
[Emacs-diffs] emacs-24 r117348: Backport from trunk. |
Date: |
Fri, 04 Jul 2014 15:15:10 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117348
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17928
committer: Jan D. <address@hidden>
branch nick: emacs-24
timestamp: Fri 2014-07-04 17:15:02 +0200
message:
Backport from trunk.
* 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,
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.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/xfns.c xfns.c-20091113204419-o5vbwnq5f7feedwu-274
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-07-04 13:22:04 +0000
+++ b/src/ChangeLog 2014-07-04 15:15:02 +0000
@@ -1,3 +1,15 @@
+2014-07-04 Daniel Colascione <address@hidden>
+
+ Backport from trunk.
+ * 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,
+ and stop caching xic_style across different displays (Bug#17928).
+ (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-07-04 Eli Zaretskii <address@hidden>
* xdisp.c (redisplay_window): If redisplay of a window ends up
=== modified file 'src/xfns.c'
--- a/src/xfns.c 2014-03-11 06:50:01 +0000
+++ b/src/xfns.c 2014-07-04 15:15:02 +0000
@@ -1641,12 +1641,12 @@
#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,16 @@
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;
@@ -1956,42 +1958,41 @@
/* Create XIC for frame F. */
-static XIMStyle xic_style;
-
void
create_frame_xic (struct frame *f)
{
XIM xim;
XIC xic = NULL;
XFontSet xfs = NULL;
+ XVaNestedList status_attr = NULL;
+ XVaNestedList preedit_attr = NULL;
+ XRectangle s_area;
+ XPoint spot;
+ XIMStyle xic_style;
if (FRAME_XIC (f))
- return;
+ goto out;
+
+ xim = FRAME_X_XIM (f);
+ if (!xim)
+ goto out;
+
+ /* Determine XIC style. */
+ xic_style = best_xim_style (FRAME_X_XIM_STYLES (f));
/* Create X fontset. */
- xfs = xic_create_xfontset (f);
- xim = FRAME_X_XIM (f);
- if (xim)
- {
- XRectangle s_area;
- XPoint spot;
- XVaNestedList preedit_attr;
- XVaNestedList status_attr;
-
- s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
+ if (xic_style & (XIMPreeditPosition | XIMStatusArea))
+ {
+ xfs = xic_create_xfontset (f);
+ if (!xfs)
+ goto out;
+
+ FRAME_XIC_FONTSET (f) = xfs;
+ }
+
+ if (xic_style & XIMPreeditPosition)
+ {
spot.x = 0; spot.y = 1;
-
- /* Determine XIC style. */
- if (xic_style == 0)
- {
- XIMStyles supported_list;
- 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));
- }
-
preedit_attr = XVaCreateNestedList (0,
XNFontSet, xfs,
XNForeground,
@@ -2003,31 +2004,75 @@
: NULL),
&spot,
NULL);
+
+ if (!preedit_attr)
+ goto out;
+ }
+
+ if (xic_style & XIMStatusArea)
+ {
+ s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
status_attr = XVaCreateNestedList (0,
- XNArea,
- &s_area,
- XNFontSet,
- xfs,
- XNForeground,
- FRAME_FOREGROUND_PIXEL (f),
- XNBackground,
- FRAME_BACKGROUND_PIXEL (f),
- NULL);
+ XNArea,
+ &s_area,
+ XNFontSet,
+ xfs,
+ XNForeground,
+ FRAME_FOREGROUND_PIXEL (f),
+ XNBackground,
+ FRAME_BACKGROUND_PIXEL (f),
+ NULL);
- xic = XCreateIC (xim,
- XNInputStyle, xic_style,
- XNClientWindow, FRAME_X_WINDOW (f),
- XNFocusWindow, FRAME_X_WINDOW (f),
- XNStatusAttributes, status_attr,
- XNPreeditAttributes, preedit_attr,
- NULL);
- XFree (preedit_attr);
- XFree (status_attr);
+ if (!status_attr)
+ goto out;
}
+ if (preedit_attr && status_attr)
+ xic = XCreateIC (xim,
+ XNInputStyle, xic_style,
+ XNClientWindow, FRAME_X_WINDOW (f),
+ XNFocusWindow, FRAME_X_WINDOW (f),
+ XNStatusAttributes, status_attr,
+ XNPreeditAttributes, preedit_attr,
+ NULL);
+ else if (preedit_attr)
+ xic = XCreateIC (xim,
+ XNInputStyle, xic_style,
+ XNClientWindow, FRAME_X_WINDOW (f),
+ XNFocusWindow, FRAME_X_WINDOW (f),
+ XNPreeditAttributes, preedit_attr,
+ NULL);
+ else if (status_attr)
+ xic = XCreateIC (xim,
+ XNInputStyle, xic_style,
+ XNClientWindow, FRAME_X_WINDOW (f),
+ XNFocusWindow, FRAME_X_WINDOW (f),
+ XNStatusAttributes, status_attr,
+ NULL);
+ else
+ xic = XCreateIC (xim,
+ XNInputStyle, xic_style,
+ XNClientWindow, FRAME_X_WINDOW (f),
+ XNFocusWindow, FRAME_X_WINDOW (f),
+ NULL);
+
+ if (!xic)
+ goto out;
+
FRAME_XIC (f) = xic;
FRAME_XIC_STYLE (f) = xic_style;
- FRAME_XIC_FONTSET (f) = xfs;
+ xfs = NULL; /* Don't free below. */
+
+ out:
+
+ if (xfs)
+ free_frame_xic (f);
+
+ if (preedit_attr)
+ XFree (preedit_attr);
+
+ if (status_attr)
+ XFree (status_attr);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 r117348: Backport from trunk.,
Jan D. <=