Skip to content

Commit

Permalink
Document the IME cursor area workaround (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab authored Jan 15, 2025
1 parent d724b1e commit 2e92e89
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion masonry/src/render_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub(crate) struct RenderRootState {
/// Whether an IME session is active.
pub(crate) is_ime_active: bool,

/// The area in which text is being edited.
/// The cursor area last sent to the platform.
pub(crate) last_sent_ime_area: Rect,

/// Scene cache for the widget tree.
Expand Down Expand Up @@ -617,6 +617,11 @@ impl RenderRoot {
.focused_widget
.expect("IME is active without a focused widget");
let ime_area = self.widget_arena.get_state(widget).item.get_ime_area();
// Certain desktop environments (primarily KDE on Wayland) re-synchronise IME state
// with the client (this app) in response to the safe area changing.
// Our handling of that ultimately results in us sending the safe area again,
// which causes an infinite loop.
// We break that loop by not re-sending the same safe area again.
if self.global_state.last_sent_ime_area != ime_area {
self.global_state.last_sent_ime_area = ime_area;
self.global_state
Expand Down

0 comments on commit 2e92e89

Please sign in to comment.