mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-18 09:18:26 +00:00
Backends: GLFW/SDL2/SDL3: Update monitors and work areas information every frame, as the later may change regardless of monitor changes. (#8415)
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2025-02-21: [Docking] Update monitors and work areas information every frame, as the later may change regardless of monitor changes. (#8415)
|
||||
// 2025-02-10: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn handler.
|
||||
// 2025-01-20: Made ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode_Manual) accept an empty array.
|
||||
// 2024-10-24: Emscripten: from SDL 2.30.9, SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f.
|
||||
@@ -144,7 +145,6 @@ struct ImGui_ImplSDL2_Data
|
||||
Uint64 Time;
|
||||
char* ClipboardTextData;
|
||||
bool UseVulkan;
|
||||
bool WantUpdateMonitors;
|
||||
|
||||
// Mouse handling
|
||||
Uint32 MouseWindowID;
|
||||
@@ -436,15 +436,6 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||
return true;
|
||||
}
|
||||
#if SDL_HAS_DISPLAY_EVENT
|
||||
case SDL_DISPLAYEVENT:
|
||||
{
|
||||
// 2.0.26 has SDL_DISPLAYEVENT_CONNECTED/SDL_DISPLAYEVENT_DISCONNECTED/SDL_DISPLAYEVENT_ORIENTATION,
|
||||
// so change of DPI/Scaling are not reflected in this event. (SDL3 has it)
|
||||
bd->WantUpdateMonitors = true;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
ImGuiViewport* viewport = ImGui_ImplSDL2_GetViewportForWindowID(event->window.windowID);
|
||||
@@ -862,10 +853,8 @@ static void ImGui_ImplSDL2_UpdateGamepads()
|
||||
// FIXME: Note that doesn't update with DPI/Scaling change only as SDL2 doesn't have an event for it (SDL3 has).
|
||||
static void ImGui_ImplSDL2_UpdateMonitors()
|
||||
{
|
||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Monitors.resize(0);
|
||||
bd->WantUpdateMonitors = false;
|
||||
int display_count = SDL_GetNumVideoDisplays();
|
||||
for (int n = 0; n < display_count; n++)
|
||||
{
|
||||
@@ -921,8 +910,7 @@ void ImGui_ImplSDL2_NewFrame()
|
||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||
|
||||
// Update monitors
|
||||
if (bd->WantUpdateMonitors)
|
||||
ImGui_ImplSDL2_UpdateMonitors();
|
||||
ImGui_ImplSDL2_UpdateMonitors();
|
||||
|
||||
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
||||
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
||||
|
Reference in New Issue
Block a user