On Windows, fix IME area not working

This commit is contained in:
wjian23 2023-12-22 03:44:30 +08:00 committed by GitHub
parent 8b5c84f404
commit 8702a09333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -28,6 +28,7 @@ Unreleased` header.
- On Web, remove queuing fullscreen request in absence of transient activation. - On Web, remove queuing fullscreen request in absence of transient activation.
- On Web, fix setting cursor icon overriding cursor visibility. - On Web, fix setting cursor icon overriding cursor visibility.
- On Wayland, fix resize being sent on focus change. - On Wayland, fix resize being sent on focus change.
- On Windows, fix `set_ime_cursor_area`.
# 0.29.4 # 0.29.4

View file

@ -10,9 +10,9 @@ use windows_sys::Win32::{
UI::{ UI::{
Input::Ime::{ Input::Ime::{
ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext, ImmReleaseContext, ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext, ImmReleaseContext,
ImmSetCandidateWindow, ATTR_TARGET_CONVERTED, ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, ImmSetCandidateWindow, ImmSetCompositionWindow, ATTR_TARGET_CONVERTED,
CFS_EXCLUDE, GCS_COMPATTR, GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, IACE_CHILDREN, ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, CFS_EXCLUDE, CFS_POINT, COMPOSITIONFORM,
IACE_DEFAULT, GCS_COMPATTR, GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, IACE_CHILDREN, IACE_DEFAULT,
}, },
WindowsAndMessaging::{GetSystemMetrics, SM_IMMENABLED}, WindowsAndMessaging::{GetSystemMetrics, SM_IMMENABLED},
}, },
@ -124,7 +124,7 @@ impl ImeContext {
left: x, left: x,
top: y, top: y,
right: x + width, right: x + width,
bottom: y - height, bottom: y + height,
}; };
let candidate_form = CANDIDATEFORM { let candidate_form = CANDIDATEFORM {
dwIndex: 0, dwIndex: 0,
@ -132,8 +132,16 @@ impl ImeContext {
ptCurrentPos: POINT { x, y }, ptCurrentPos: POINT { x, y },
rcArea: rc_area, rcArea: rc_area,
}; };
let composition_form = COMPOSITIONFORM {
dwStyle: CFS_POINT,
ptCurrentPos: POINT { x, y: y + height },
rcArea: rc_area,
};
unsafe { ImmSetCandidateWindow(self.himc, &candidate_form) }; unsafe {
ImmSetCompositionWindow(self.himc, &composition_form);
ImmSetCandidateWindow(self.himc, &candidate_form);
}
} }
pub unsafe fn set_ime_allowed(hwnd: HWND, allowed: bool) { pub unsafe fn set_ime_allowed(hwnd: HWND, allowed: bool) {