|
26 | 26 | // CHANGELOG
|
27 | 27 | // (minor and older changes stripped away, please see git history for details)
|
28 | 28 | // 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
| 29 | +// 2025-04-09: [Docking] Revert update monitors and work areas information every frame. Only do it on Windows. (#8415, #8558) |
29 | 30 | // 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
|
30 | 31 | // 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
|
31 | 32 | // 2025-02-26: Only start SDL_CaptureMouse() when mouse is being dragged, to mitigate issues with e.g.Linux debuggers not claiming capture back. (#6410, #3650)
|
@@ -151,6 +152,7 @@ struct ImGui_ImplSDL2_Data
|
151 | 152 | Uint64 Time;
|
152 | 153 | char* ClipboardTextData;
|
153 | 154 | bool UseVulkan;
|
| 155 | + bool WantUpdateMonitors; |
154 | 156 |
|
155 | 157 | // Mouse handling
|
156 | 158 | Uint32 MouseWindowID;
|
@@ -459,6 +461,15 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
459 | 461 | 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.
|
460 | 462 | return true;
|
461 | 463 | }
|
| 464 | +#if SDL_HAS_DISPLAY_EVENT |
| 465 | + case SDL_DISPLAYEVENT: |
| 466 | + { |
| 467 | + // 2.0.26 has SDL_DISPLAYEVENT_CONNECTED/SDL_DISPLAYEVENT_DISCONNECTED/SDL_DISPLAYEVENT_ORIENTATION, |
| 468 | + // so change of DPI/Scaling are not reflected in this event. (SDL3 has it) |
| 469 | + bd->WantUpdateMonitors = true; |
| 470 | + return true; |
| 471 | + } |
| 472 | +#endif |
462 | 473 | case SDL_WINDOWEVENT:
|
463 | 474 | {
|
464 | 475 | ImGuiViewport* viewport = ImGui_ImplSDL2_GetViewportForWindowID(event->window.windowID);
|
@@ -882,8 +893,10 @@ static void ImGui_ImplSDL2_UpdateGamepads()
|
882 | 893 | // FIXME: Note that doesn't update with DPI/Scaling change only as SDL2 doesn't have an event for it (SDL3 has).
|
883 | 894 | static void ImGui_ImplSDL2_UpdateMonitors()
|
884 | 895 | {
|
| 896 | + ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); |
885 | 897 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
886 | 898 | platform_io.Monitors.resize(0);
|
| 899 | + bd->WantUpdateMonitors = false; |
887 | 900 | int display_count = SDL_GetNumVideoDisplays();
|
888 | 901 | for (int n = 0; n < display_count; n++)
|
889 | 902 | {
|
@@ -941,7 +954,11 @@ void ImGui_ImplSDL2_NewFrame()
|
941 | 954 | io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
942 | 955 |
|
943 | 956 | // Update monitors
|
944 |
| - ImGui_ImplSDL2_UpdateMonitors(); |
| 957 | +#ifdef WIN32 |
| 958 | + bd->WantUpdateMonitors = true; // Keep polling under Windows to handle changes of work area when resizing task-bar (#8415) |
| 959 | +#endif |
| 960 | + if (bd->WantUpdateMonitors) |
| 961 | + ImGui_ImplSDL2_UpdateMonitors(); |
945 | 962 |
|
946 | 963 | // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
947 | 964 | // (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
|
0 commit comments