Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 19f0fe2

Browse files
committedNov 23, 2021
Fixes #23, + minor formatting changes to previous PR
1 parent 5efce96 commit 19f0fe2

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed
 

‎src/renderer/renderer.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -687,21 +687,24 @@ void UpdateCursorPos(Renderer *renderer, mpack_node_t cursor_goto) {
687687
}
688688

689689
void UpdateImePos(Renderer* renderer) {
690-
HIMC hIMC = ImmGetContext(renderer->hwnd);
691-
COMPOSITIONFORM cf = { 0 };
692-
693-
cf.dwStyle = CFS_POINT;
694-
cf.ptCurrentPos.x = renderer->cursor.col * renderer->font_width;
695-
cf.ptCurrentPos.y = renderer->cursor.row * renderer->font_height;
690+
HIMC input_context = ImmGetContext(renderer->hwnd);
691+
COMPOSITIONFORM composition_form {
692+
.dwStyle = CFS_POINT,
693+
.ptCurrentPos = {
694+
.x = static_cast<LONG>(renderer->cursor.col * renderer->font_width),
695+
.y = static_cast<LONG>(renderer->cursor.row * renderer->font_height)
696+
}
697+
};
696698

697-
if (ImmSetCompositionWindow(hIMC, &cf)) {
698-
LOGFONTW lf = { 0 };
699-
lf.lfHeight = static_cast<LONG>(renderer->font_height);
700-
wcscpy_s(lf.lfFaceName, LF_FACESIZE, renderer->font);
701-
ImmSetCompositionFontW(hIMC, &lf);
699+
if (ImmSetCompositionWindow(input_context, &composition_form)) {
700+
LOGFONTW font_attribs {
701+
.lfHeight = static_cast<LONG>(renderer->font_height)
702+
};
703+
wcscpy_s(font_attribs.lfFaceName, LF_FACESIZE, renderer->font);
704+
ImmSetCompositionFontW(input_context, &font_attribs);
702705
}
703706

704-
ImmReleaseContext(renderer->hwnd, hIMC);
707+
ImmReleaseContext(renderer->hwnd, input_context);
705708
}
706709

707710
void UpdateCursorMode(Renderer *renderer, mpack_node_t mode_change) {

0 commit comments

Comments
 (0)
Please sign in to comment.