Skip to content

The display position of the IME Candidate List does not meet expectations #4786

@wre40

Description

@wre40

When using IME, it will be offset by some pixels down from the expected position. Rewriting the function WIN_SetTextInputRect can solve this problem

void
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
HIMC himc = 0;

if (!rect) {
    SDL_InvalidParamError("rect");
    return;
}

videodata->ime_rect = *rect;

himc = ImmGetContext(videodata->ime_hwnd_current);
if (himc)
{
    COMPOSITIONFORM cof;
    CANDIDATEFORM caf;

    cof.dwStyle = CFS_EXCLUDE;
    cof.rcArea.left = rect->x;
    cof.rcArea.right = rect->x+rect->w;
    cof.rcArea.top = rect->y;
    cof.rcArea.bottom = rect->y + rect->h;
    cof.ptCurrentPos.x = videodata->ime_rect.x+rect->w;
    cof.ptCurrentPos.y = videodata->ime_rect.y+rect->h;
    ImmSetCompositionWindow(himc, &cof);

    caf.dwIndex = 0;
    caf.dwStyle = CFS_EXCLUDE;
    caf.ptCurrentPos.x = videodata->ime_rect.x+rect->w;
    caf.ptCurrentPos.y = videodata->ime_rect.y + rect->h;
    caf.rcArea.left = rect->x;
    caf.rcArea.right = rect->x + rect->w;
    caf.rcArea.top = rect->y;
    caf.rcArea.bottom = rect->y + rect->h;
    ImmSetCandidateWindow(himc, &caf);

    ImmReleaseContext(videodata->ime_hwnd_current,himc);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions