From acdf06bf5df8ccbd88edba79063a662c839cdd54 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Nov 2021 22:11:21 +0530 Subject: [PATCH] Tell cocoa the previous character range is invalid when updating IME position Without this IME popup position is sometimes incorrect, for instance, at startup --- glfw/cocoa_window.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 01badaf4e..84c845a0e 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1505,12 +1505,13 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) { top /= window->ns.yscale; cellWidth /= window->ns.xscale; cellHeight /= window->ns.yscale; - debug_key("updateIMEState: left=%f, top=%f, width=%f, height=%f\n", left, top, cellWidth, cellHeight); + debug_key("updateIMEPosition: left=%f, top=%f, width=%f, height=%f\n", left, top, cellWidth, cellHeight); const NSRect frame = [window->ns.view frame]; const NSRect rectInView = NSMakeRect(left, frame.size.height - top - cellHeight, cellWidth, cellHeight); markedRect = [window->ns.object convertRectToScreen: rectInView]; + if (_glfwPlatformWindowFocused(window)) [[window->ns.view inputContext] invalidateCharacterCoordinates]; } - (NSArray*)validAttributesForMarkedText