Skip to content

Commit

Permalink
On X11, fix IME crashing during reload
Browse files Browse the repository at this point in the history
During reload we were picking old styles, but the styles could
change during reload leading to errors during IME building.

Fixes rust-windowing#2510.
  • Loading branch information
kchibisov committed Oct 9, 2022
1 parent bb0f965 commit a03d496
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ And please only add new entries to the top of this list, right below the `# Unre
- On Wayland, `wayland-csd-adwaita` now uses `ab_glyph` instead of `crossfont` to render the title for decorations.
- On Wayland, a new `wayland-csd-adwaita-crossfont` feature was added to use `crossfont` instead of `ab_glyph` for decorations.
- On Wayland, if not otherwise specified use upstream automatic CSD theme selection.
- On X11, fixed IME crashing during reload.

# 0.27.3

Expand Down
15 changes: 13 additions & 2 deletions src/platform_impl/linux/x11/ime/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,21 @@ 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 style = old_context

// Check if the IME was allowed on that context.
let is_allowed = old_context
.as_ref()
.map(|old_context| old_context.style)
.map(|old_context| old_context.is_allowed())
.unwrap_or_default();

// We can't use the style from the old context here, since it may change on reload, so
// pick style from the nem xim based on the old state.
let style = if is_allowed {
new_im.preedit_style
} else {
new_im.none_style
};

let new_context = {
let result = ImeContext::new(
xconn,
Expand Down

0 comments on commit a03d496

Please sign in to comment.