Skip to content
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

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

Closed
wre40 opened this issue Sep 27, 2021 · 3 comments
Closed

Comments

@wre40
Copy link

wre40 commented Sep 27, 2021

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);
}

}

@andyten
Copy link

andyten commented Mar 15, 2022

@zreedy
This PR does not fix the problem that the IME candidate window is not displayed #5398

@zreedy
Copy link
Contributor

zreedy commented Mar 15, 2022

@andyten The code written here was already committed and added by another user. This should already be marked as closed as that commit fixed the issue.

Just in case there's some confusion this should work with the following code added to whatever app you're using to test:

SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); // Prior to SDL_Init()

SDL_Rect rect;
rect.x = x; // top of line where text is being entered
rect.y = y; // left of line where text is being entered
rect.w = lineHeight; // Height of line where text is being entered
rect.h = lineHeight;

SDL_SetTextInputRect(&rect);

Does that resolve the issue?

@andyten
Copy link

andyten commented Mar 16, 2022

@andyten The code written here was already committed and added by another user. This should already be marked as closed as that commit fixed the issue.

Just in case there's some confusion this should work with the following code added to whatever app you're using to test:

SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); // Prior to SDL_Init()

SDL_Rect rect;
rect.x = x; // top of line where text is being entered
rect.y = y; // left of line where text is being entered
rect.w = lineHeight; // Height of line where text is being entered
rect.h = lineHeight;

SDL_SetTextInputRect(&rect);

Does that resolve the issue?

issue solved .
Thank you.

@slouken slouken closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants