From e77a6c245a73db8156d12c893ab42cad71196751 Mon Sep 17 00:00:00 2001 From: Francesca Frangipane Date: Sun, 22 Apr 2018 22:13:12 -0400 Subject: [PATCH] X11: Don't replace IME if it doesn't make sense to --- src/platform/linux/x11/ime/callbacks.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/platform/linux/x11/ime/callbacks.rs b/src/platform/linux/x11/ime/callbacks.rs index 0618b23364..dfeb3bedf7 100644 --- a/src/platform/linux/x11/ime/callbacks.rs +++ b/src/platform/linux/x11/ime/callbacks.rs @@ -145,14 +145,16 @@ pub unsafe extern fn xim_instantiate_callback( ) { let inner: *mut ImeInner = client_data as _; if !inner.is_null() { - let xconn = &(*inner).xconn; - let result = replace_im(inner); - if result.is_ok() { - let _ = unset_instantiate_callback(xconn, client_data); - (*inner).is_fallback = false; - } else if result.is_err() && (*inner).is_destroyed { - // We have no usable input methods! - result.expect("Failed to reopen input method"); + if (*inner).is_destroyed || (*inner).is_fallback { + let xconn = &(*inner).xconn; + let result = replace_im(inner); + if result.is_ok() { + let _ = unset_instantiate_callback(xconn, client_data); + (*inner).is_fallback = false; + } else if result.is_err() && (*inner).is_destroyed { + // We have no usable input methods! + result.expect("Failed to reopen input method"); + } } } }