-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Windows: implement Window.set_ime_position() with IMM API. #1790
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the contribution 👋
I played a bit with the provided demo and works ok overall. I noticed a bit of flickering when moving around the mouse cursor, not sure if this is platform specific, also the candidate window doesn't seem to follow (how does unix handle this?) - overall not sure how important this is in a real application. I assume 'static' composition windows are more common on text input. It might make sense to adjust the demo a bit to only set the position on click?
Also, please add a changelog entry please for other users to know!
src/platform_impl/windows/window.rs
Outdated
@@ -616,9 +618,25 @@ impl Window { | |||
self.window_state.lock().taskbar_icon = taskbar_icon; | |||
} | |||
|
|||
pub(crate) fn set_ime_position_physical(&self, x: i32, y: i32) { | |||
if unsafe { winuser::GetSystemMetrics(winuser::SM_DBCSENABLED) } != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I installed an east asian language pack for testing and it only worked when switching to SM_IMMENABLED
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I made a mistake. Thanks,
I fixed that demo based on your review, and add to changelog. Thank a lot! |
I ran the demo in Windows 10 1809, Windows 8.1, and it worked. |
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to usersI tested in Windows 10 18363.1198 with Microsoft Japanese IME. I am not tested without IME. I followed IMM documentation and implementation will not call IMM API if Windows has no IME.
IMM docs: https://docs.microsoft.com/ja-jp/windows/win32/intl/about-input-method-manager
ImmSetCompositionWindow docs: https://docs.microsoft.com/en-us/windows/win32/api/imm/nf-imm-immsetcompositionwindow
COMPOSITIONFORM docs: https://docs.microsoft.com/en-us/windows/win32/api/imm/ns-imm-compositionform
GetSystemMetrics and SM_IMMENABLED docs: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics