From c226de5eb15a3a931be203efec0dd024b31f29d4 Mon Sep 17 00:00:00 2001 From: KENZ Date: Sun, 22 Feb 2026 10:36:14 +0900 Subject: [PATCH] Fix the candidate window position on Linux (or other platforms which winit's set_ime_cursor_area() supports only the position) --- winit/src/window.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/winit/src/window.rs b/winit/src/window.rs index 5911a47ec8..83d512897f 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -269,9 +269,17 @@ where } if self.ime_state != Some((cursor, purpose)) { + let (cursor_y, cursor_height) = if cfg!(any(target_os = "windows", target_os = "macos")) + { + (cursor.y, cursor.height) + } else { + // Specify the bottom-left position of the cursor because + // only the position is supported on Linux (or other platforms). + (cursor.y + cursor.height, 0f32) + }; self.raw.set_ime_cursor_area( - LogicalPosition::new(cursor.x, cursor.y), - LogicalSize::new(cursor.width, cursor.height), + LogicalPosition::new(cursor.x, cursor_y), + LogicalSize::new(cursor.width, cursor_height), ); self.raw.set_ime_purpose(conversion::ime_purpose(purpose));