Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the IME cursor area workaround #826

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Ideally I'd choose to expand this here, with something like "\n\nUsed to avoid an infinite loop on some platforms" but that has been vetoed)

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
Loading