Skip to content

Commit

Permalink
On Windows, fix IME area not working
Browse files Browse the repository at this point in the history
  • Loading branch information
wjian23 authored and kchibisov committed Dec 21, 2023
1 parent cafcaa2 commit 6fbdbce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@ Unreleased` header.
- On X11, fix `Xft.dpi` detection from Xresources.
- On Windows, fix consecutive calls to `window.set_fullscreen(Some(Fullscreen::Borderless(None)))` resulting in losing previous window state when eventually exiting fullscreen using `window.set_fullscreen(None)`.
- On Wayland, fix resize being sent on focus change.
- On Windows, fix `set_ime_cursor_area`.

# 0.29.4

Expand Down
18 changes: 13 additions & 5 deletions src/platform_impl/windows/ime.rs
Expand Up @@ -10,9 +10,9 @@ use windows_sys::Win32::{
UI::{
Input::Ime::{
ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext, ImmReleaseContext,
ImmSetCandidateWindow, ATTR_TARGET_CONVERTED, ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM,
CFS_EXCLUDE, GCS_COMPATTR, GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, IACE_CHILDREN,
IACE_DEFAULT,
ImmSetCandidateWindow, ImmSetCompositionWindow, ATTR_TARGET_CONVERTED,
ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, CFS_EXCLUDE, CFS_POINT, COMPOSITIONFORM,
GCS_COMPATTR, GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, IACE_CHILDREN, IACE_DEFAULT,
},
WindowsAndMessaging::{GetSystemMetrics, SM_IMMENABLED},
},
Expand Down Expand Up @@ -124,16 +124,24 @@ impl ImeContext {
left: x,
top: y,
right: x + width,
bottom: y - height,
bottom: y + height,
};
let candidate_form = CANDIDATEFORM {
dwIndex: 0,
dwStyle: CFS_EXCLUDE,
ptCurrentPos: POINT { x, y },
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) {
Expand Down

0 comments on commit 6fbdbce

Please sign in to comment.