From 89d78ac410fc3f833a9dda06ffc8bd3c6acb1d7e Mon Sep 17 00:00:00 2001 From: kumattau Date: Tue, 24 May 2022 05:58:18 +0900 Subject: [PATCH] Fix IME candidate window position on macOS --- window/src/os/macos/window.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index a31e5ee56..22845798b 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -1714,10 +1714,9 @@ impl WindowView { range, actual ); - let frame = unsafe { - let window: id = msg_send![this, window]; - NSWindow::frame(window) - }; + let window: id = unsafe { msg_send![this, window] }; + let frame = unsafe { NSWindow::frame(window) }; + let content: NSRect = unsafe { msg_send![window, contentRectForFrameRect: frame] }; let backing_frame: NSRect = unsafe { msg_send![this, convertRectToBacking: frame] }; let scale = frame.size.width / backing_frame.size.width; @@ -1731,11 +1730,8 @@ impl WindowView { NSRect::new( NSPoint::new( - frame.origin.x + cursor_pos.origin.x, - // Position below the text so that drop-downs - // don't obscure the text in the terminal - frame.origin.y + frame.size.height - - (cursor_pos.max_y() + cursor_pos.size.height * 2.5), + content.origin.x + cursor_pos.min_x(), + content.origin.y + content.size.height - cursor_pos.max_y(), ), NSSize::new(cursor_pos.size.width, cursor_pos.size.height), )