diff --git a/backends/imgui_impl_emscripten.cpp b/backends/imgui_impl_emscripten.cpp index 03a682472..59f9beb7e 100644 --- a/backends/imgui_impl_emscripten.cpp +++ b/backends/imgui_impl_emscripten.cpp @@ -4,6 +4,7 @@ // // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2026-09-06: DPI: Added public ImGui_ImplEmscripten_UpdateDisplayProperties() wrapper. // 2026-09-06: Inputs: Exposed mouse button and key translation functions as public. // 2026-09-06: DPI: Added ImGui_ImplEmscripten_GetCssToImGuiScale() getter. // 2026-09-05: DPI: Use the canvas framebuffer dimensions for display sizing and exact per-axis mouse coordinate scaling. @@ -406,6 +407,13 @@ ImVec2 ImGui_ImplEmscripten_GetCssToImGuiScale() return bd != nullptr ? bd->CssToImGuiScale : ImVec2(1.0f, 1.0f); } +void ImGui_ImplEmscripten_UpdateDisplayProperties() +{ + ImGui_ImplEmscripten_Data* bd = ImGui_ImplEmscripten_GetBackendData(); + IM_ASSERT(bd != nullptr && "Context or backend not initialized? Did you call ImGui_ImplEmscripten_Init()?"); + if (bd != nullptr) ImGui_ImplEmscripten_UpdateDisplayProperties(ImGui::GetIO(), bd); +} + void ImGui_ImplEmscripten_Shutdown() { ImGui_ImplEmscripten_Data* bd = ImGui_ImplEmscripten_GetBackendData(); diff --git a/backends/imgui_impl_emscripten.h b/backends/imgui_impl_emscripten.h index b7a8a707e..7589e2669 100644 --- a/backends/imgui_impl_emscripten.h +++ b/backends/imgui_impl_emscripten.h @@ -50,6 +50,9 @@ IMGUI_IMPL_API void ImGui_ImplEmscripten_SetTargetDevicePixelRatio(float target_ // Return the scale used to convert browser CSS pixel coordinates to Dear ImGui coordinates. Valid after Init(). IMGUI_IMPL_API ImVec2 ImGui_ImplEmscripten_GetCssToImGuiScale(); +// Refresh display size and scaling properties immediately. Call after changing the canvas framebuffer or CSS size. +IMGUI_IMPL_API void ImGui_ImplEmscripten_UpdateDisplayProperties(); + // Input translation helpers. IMGUI_IMPL_API ImGuiMouseButton ImGui_ImplEmscripten_TranslateMouseButton(unsigned short emscripten_button); IMGUI_IMPL_API ImGuiKey ImGui_ImplEmscripten_TranslateKey(const char* emscripten_key);