Skip to content

Commit

Permalink
Backends: SDL2/SDL3: Fixed IME text input rectangle position with vie…
Browse files Browse the repository at this point in the history
…wports. (#6071, #1953)
  • Loading branch information
ocornut committed Apr 6, 2023
1 parent ec461c6 commit 1668693
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions backends/imgui_impl_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
}

// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{
if (data->WantVisible)
{
SDL_Rect r;
r.x = (int)data->InputPos.x;
r.y = (int)data->InputPos.y;
r.x = (int)(data->InputPos.x - viewport->Pos.x);
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
r.w = 1;
r.h = (int)data->InputLineHeight;
SDL_SetTextInputRect(&r);
Expand Down
6 changes: 3 additions & 3 deletions backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
SDL_SetClipboardText(text);
}

static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{
if (data->WantVisible)
{
SDL_Rect r;
r.x = (int)data->InputPos.x;
r.y = (int)data->InputPos.y;
r.x = (int)(data->InputPos.x - viewport->Pos.x);
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
r.w = 1;
r.h = (int)data->InputLineHeight;
SDL_SetTextInputRect(&r);
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Docking+Viewports Branch:
- Docking: Fixed using GetItemXXX() or IsItemXXX() functions after a DockSpace(). (#6217)
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
- Backends: GLFW: Fixed Emscripten erroneously enabling multi-viewport support, leading to assert. (#5683)
- Backends: SDL2/SDL3: Fixed IME text input rectangle position with viewports. (#6071, #1953)
- Backends: SDL3: Fixed for compilation with multi-viewports. (#6255) [@P3RK4N]


Expand Down

0 comments on commit 1668693

Please sign in to comment.