Skip to content

IME: Render overlay at the last visible cursor position and improvements under macOS #6049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

page-down
Copy link
Contributor

Render overlay at the last visible cursor position with a separate cursor.

Fix the problem caused by wrong cursor coordinates. No more messing with the main cursor, instead the cursor is saved when receiving a pre-edit text update and used for drawing later.

Update the overlay to the last visible cursor position before rendering to ensure it always moves with the cursor. Finally, draw the overlay after line rendering is complete, and restore the line buffer after updating the rendered data to ensure that the line text being read is correct at all times.

This also improves performance by only rendering once when changes are made, eliminating the need to repeatedly disable and draw after various commands and not even comprehensively.

Allow IME to actively get the cursor position in real time on macOS.

IME will automatically get the display position when needed, which keeps it consistent with the overlay as much as possible.
Fix the issue that when IME is activated after mouse click, it is displayed at the wrong position.

After the window is created, the initial activation of the IME will be in whatever position the cursor is located, not in the upper left corner.

Tested on:

  • macOS, builtin CJK IME
  • Linux X11/Wayland, IBUS/Fcitx5, RIME

Supersedes:
#6002

Please review, thank you.

…te cursor

Fix the problem caused by wrong cursor coordinates. No more messing with
the main cursor, instead the cursor is saved when receiving a pre-edit
text update and used for drawing later.

Update the overlay to the last visible cursor position before rendering
to ensure it always moves with the cursor. Finally, draw the overlay
after line rendering is complete, and restore the line buffer after
updating the rendered data to ensure that the line text being read is
correct at all times.

This also improves performance by only rendering once when changes are
made, eliminating the need to repeatedly disable and draw after various
commands and not even comprehensively.
IME will automatically get the display position when needed, which keeps
it consistent with the overlay as much as possible.

Fix the issue that when IME is activated after mouse click, it is
displayed at the wrong position.
@kovidgoyal kovidgoyal merged commit dba8d27 into kovidgoyal:master Feb 23, 2023
@page-down page-down deleted the ime branch February 23, 2023 16:06
@page-down
Copy link
Contributor Author

Thanks for the cleanup.

Do you know how to get readSelectionFromPasteboard (glfw/cocoa_window.m) to work?
9b5034f
18fc8da

Are there any tips from the contributor of that patch?

I want to test this piece of code to see if it affects the input and if there is another way.

@kovidgoyal
Copy link
Owner

I dont recall I think I tested the writetopasteboard not the readfrompasteboard. But I think there are some chinese translation services or something like that that export text. Also terminal.app support these services so selecting text there might be a way to test it.

@page-down
Copy link
Contributor Author

... I tested the writetopasteboard not the readfrompasteboard ...

I did the same.

... there are some ... export text.
... so selecting text there might be a way to test it.

I believe this is for writeSelectionToPasteboard.
And readSelectionFromPasteboard is used to handle the text sent to kitty by other services.
Have tried various ways, however I just can't get this function to be executed.

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   fast_data_types.so            	       0x108b2f3e9 get_ime_cursor_position + 57

After updating to the latest commit, I'm experiencing a crash just by pressing some keys after startup.

@kovidgoyal
Copy link
Owner

c5149de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants