From 0270516067299914d97e580bafd2277df57e626f Mon Sep 17 00:00:00 2001 From: Yuze Jiang Date: Sat, 20 Jan 2024 23:32:20 +0900 Subject: [PATCH] On macOS, fix incorrect IME cursor rect origin `window.set_ime_cursor_area` requires a position from the top left corner according to the documentation. However, the NSRect's origin is from bottom left. The y coordinate should correctly calculated for the NSRect. --- CHANGELOG.md | 2 ++ src/platform_impl/macos/view.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ac76a116..5f11729d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Unreleased` header. # Unreleased +- On macOS, fix incorrect IME cursor rect origin. + # 0.29.10 - On Web, account for canvas being focused already before event loop starts. diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs index bac77f9e2..69b357b7a 100644 --- a/src/platform_impl/macos/view.rs +++ b/src/platform_impl/macos/view.rs @@ -410,9 +410,9 @@ declare_class!( let content_rect = window.contentRectForFrameRect(window.frame()); let base_x = content_rect.origin.x as f64; let base_y = (content_rect.origin.y + content_rect.size.height) as f64; - let x = base_x + self.state.ime_position.get().x; - let y = base_y - self.state.ime_position.get().y; let LogicalSize { width, height } = self.state.ime_size.get(); + let x = base_x + self.state.ime_position.get().x; + let y = base_y - self.state.ime_position.get().y - height; NSRect::new(NSPoint::new(x as _, y as _), NSSize::new(width, height)) }