diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 7a59241ad6..0c2dba3561 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -3543,10 +3543,12 @@ void Graphics::render(void) draw_window_background(); - SDL_Rect rect; - get_stretch_info(&rect); + SDL_Rect stretch_info; + get_stretch_info(&stretch_info); + + ime_set_rect(&stretch_info); - copy_texture(gameTexture, NULL, &rect, 0, NULL, flipmode ? SDL_FLIP_VERTICAL : SDL_FLIP_NONE); + copy_texture(gameTexture, NULL, &stretch_info, 0, NULL, flipmode ? SDL_FLIP_VERTICAL : SDL_FLIP_NONE); } void Graphics::renderwithscreeneffects(void) diff --git a/desktop_version/src/IMERender.cpp b/desktop_version/src/IMERender.cpp index 57132fb3b0..2a320b99c3 100644 --- a/desktop_version/src/IMERender.cpp +++ b/desktop_version/src/IMERender.cpp @@ -6,15 +6,19 @@ #include "KeyPoll.h" #include "UTF8.h" +static bool render_done = false; +static SDL_Rect imebox; + void ime_render(void) { + render_done = false; + if (!SDL_IsTextInputActive() || key.imebuffer == "") { return; } int fontheight = font::height(PR_FONT_LEVEL); - SDL_Rect imebox; imebox.x = 8; imebox.y = SCREEN_HEIGHT_PIXELS - 32 - fontheight; imebox.w = font::len(PR_FONT_LEVEL, key.imebuffer.c_str()) + 1; @@ -76,5 +80,22 @@ void ime_render(void) } font::print(PR_FONT_LEVEL | PR_CJK_LOW, imebox.x + 1, imebox.y + 1, key.imebuffer, 255, 255, 255); - SDL_SetTextInputRect(&imebox); + + render_done = true; +} + +void ime_set_rect(SDL_Rect* stretch_info) +{ + if (!render_done) + { + return; + } + + SDL_Rect imebox_scaled = imebox; + imebox_scaled.x += stretch_info.x; + imebox_scaled.y += stretch_info.y; + imebox_scaled.w *= stretch_info.w / SCREEN_WIDTH_PIXELS; + imebox_scaled.h *= stretch_info.h / SCREEN_HEIGHT_PIXELS; + + SDL_SetTextInputRect(&imebox_scaled); } diff --git a/desktop_version/src/IMERender.h b/desktop_version/src/IMERender.h index 883efd7d45..9e48ebd184 100644 --- a/desktop_version/src/IMERender.h +++ b/desktop_version/src/IMERender.h @@ -2,5 +2,6 @@ #define IMERENDER_H void ime_render(void); +void ime_set_rect(SDL_Rect* stretch_info); #endif /* IMERENDER_H */