mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Refactor: move Windows Korean IME workaround from egui to egui-winit
The bug is specific to `egui-winit` and is unlikely present in other implementations. Applying the workaround in `egui` degrades implementations that already behave correctly.
This commit is contained in:
@@ -706,7 +706,20 @@ impl State {
|
||||
text.get(..start_bytes).map(|s| s.chars().count()),
|
||||
text.get(start_bytes..end_bytes).map(|s| s.chars().count()),
|
||||
) {
|
||||
Some(start_chars..start_chars + middle_chars)
|
||||
if cfg!(target_os = "windows") && start_chars == 0 && middle_chars == 0
|
||||
{
|
||||
// Workaround for a bug on Windows where `winit`
|
||||
// incorrectly reports the cursor position at
|
||||
// the start of the preedit text during
|
||||
// composition with the builtin Korean IME.
|
||||
// See: https://github.com/emilk/egui/pull/8083#issuecomment-4206742668
|
||||
// TODO(umajho): Remove this workaround once the
|
||||
// `winit` bug is fixed and we've updated to a
|
||||
// version that includes the fix.
|
||||
None
|
||||
} else {
|
||||
Some(start_chars..start_chars + middle_chars)
|
||||
}
|
||||
} else {
|
||||
log::warn!("ignoring {ime:?}'s range because it is invalid");
|
||||
None
|
||||
|
||||
@@ -161,20 +161,6 @@ pub(crate) fn paint_ime_preedit_text_visuals(
|
||||
relative_active_range.end.index = preedit_range.end.index - preedit_range.start.index;
|
||||
}
|
||||
|
||||
if matches!(ui.ctx().os(), crate::os::OperatingSystem::Windows)
|
||||
&& let Some(r) = &relative_active_range
|
||||
&& r.start.index == 0
|
||||
&& r.end.index == 0
|
||||
{
|
||||
// Workaround for a bug on Windows where `winit` incorrectly reports
|
||||
// the cursor position at the start of the preedit text during
|
||||
// composition with the builtin Korean IME.
|
||||
// See: https://github.com/emilk/egui/pull/8083#issuecomment-4206742668
|
||||
// TODO(umajho): Remove this workaround once the `winit` bug is fixed
|
||||
// and we've updated to a version that includes the fix.
|
||||
relative_active_range = None;
|
||||
}
|
||||
|
||||
let visuals = ui.visuals();
|
||||
let active_underline_stroke = visuals.ime_composition.active_underline_stroke;
|
||||
let inactive_underline_stroke = visuals.ime_composition.inactive_underline_stroke;
|
||||
|
||||
Reference in New Issue
Block a user