On X11 query for XIM styles before creating IME

Fixes #2448.
This commit is contained in:
Kirill Chibisov 2022-09-11 19:36:56 +03:00 committed by GitHub
parent 3b56b0e76f
commit 155f1f9720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 179 additions and 79 deletions

View file

@ -108,17 +108,17 @@ unsafe fn replace_im(inner: *mut ImeInner) -> Result<(), ReplaceImError> {
let mut new_contexts = HashMap::new();
for (window, old_context) in (*inner).contexts.iter() {
let spot = old_context.as_ref().map(|old_context| old_context.ic_spot);
let is_allowed = old_context
let style = old_context
.as_ref()
.map(|old_context| old_context.is_allowed)
.map(|old_context| old_context.style)
.unwrap_or_default();
let new_context = {
let result = ImeContext::new(
xconn,
new_im.im,
style,
*window,
spot,
is_allowed,
(*inner).event_sender.clone(),
);
if result.is_err() {
@ -132,7 +132,7 @@ unsafe fn replace_im(inner: *mut ImeInner) -> Result<(), ReplaceImError> {
// If we've made it this far, everything succeeded.
let _ = (*inner).destroy_all_contexts_if_necessary();
let _ = (*inner).close_im_if_necessary();
(*inner).im = new_im.im;
(*inner).im = Some(new_im);
(*inner).contexts = new_contexts;
(*inner).is_destroyed = false;
(*inner).is_fallback = is_fallback;