Răsfoiți Sursa

Backends: ensure that ImGuiPlatformMonitor list is available after backend Init call. (#7995)

ocornut 11 luni în urmă
părinte
comite
42272505c9

+ 2 - 1
backends/imgui_impl_glfw.cpp

@@ -649,7 +649,8 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
     if (install_callbacks)
     if (install_callbacks)
         ImGui_ImplGlfw_InstallCallbacks(window);
         ImGui_ImplGlfw_InstallCallbacks(window);
 
 
-    // Update monitors the first time (note: monitor callback are broken in GLFW 3.2 and earlier, see github.com/glfw/glfw/issues/784)
+    // Update monitor a first time during init
+    // (note: monitor callback are broken in GLFW 3.2 and earlier, see github.com/glfw/glfw/issues/784)
     ImGui_ImplGlfw_UpdateMonitors();
     ImGui_ImplGlfw_UpdateMonitors();
     glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
     glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
 
 

+ 3 - 1
backends/imgui_impl_sdl2.cpp

@@ -520,7 +520,6 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
 #else
 #else
     bd->MouseCanReportHoveredViewport = false;
     bd->MouseCanReportHoveredViewport = false;
 #endif
 #endif
-    bd->WantUpdateMonitors = true;
 
 
     ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
     ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
     platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
     platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
@@ -531,6 +530,9 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
     platform_io.Platform_OpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
     platform_io.Platform_OpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
 #endif
 #endif
 
 
+    // Update monitor a first time during init
+    ImGui_ImplSDL2_UpdateMonitors();
+
     // Gamepad handling
     // Gamepad handling
     bd->GamepadMode = ImGui_ImplSDL2_GamepadMode_AutoFirst;
     bd->GamepadMode = ImGui_ImplSDL2_GamepadMode_AutoFirst;
     bd->WantUpdateGamepadsList = true;
     bd->WantUpdateGamepadsList = true;

+ 3 - 1
backends/imgui_impl_sdl3.cpp

@@ -509,13 +509,15 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
 #else
 #else
     bd->MouseCanReportHoveredViewport = false;
     bd->MouseCanReportHoveredViewport = false;
 #endif
 #endif
-    bd->WantUpdateMonitors = true;
 
 
     ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
     ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
     platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
     platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
     platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
     platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
     platform_io.Platform_SetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
     platform_io.Platform_SetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
 
 
+    // Update monitor a first time during init
+    ImGui_ImplSDL3_UpdateMonitors();
+
     // Gamepad handling
     // Gamepad handling
     bd->GamepadMode = ImGui_ImplSDL3_GamepadMode_AutoFirst;
     bd->GamepadMode = ImGui_ImplSDL3_GamepadMode_AutoFirst;
     bd->WantUpdateGamepadsList = true;
     bd->WantUpdateGamepadsList = true;

+ 3 - 1
backends/imgui_impl_win32.cpp

@@ -176,12 +176,14 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
     io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
     io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
 
 
     bd->hWnd = (HWND)hwnd;
     bd->hWnd = (HWND)hwnd;
-    bd->WantUpdateMonitors = true;
     bd->TicksPerSecond = perf_frequency;
     bd->TicksPerSecond = perf_frequency;
     bd->Time = perf_counter;
     bd->Time = perf_counter;
     bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
     bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
     ImGui_ImplWin32_UpdateKeyboardCodePage();
     ImGui_ImplWin32_UpdateKeyboardCodePage();
 
 
+    // Update monitor a first time during init
+    ImGui_ImplWin32_UpdateMonitors();
+
     // Our mouse update function expect PlatformHandle to be filled for the main viewport
     // Our mouse update function expect PlatformHandle to be filled for the main viewport
     ImGuiViewport* main_viewport = ImGui::GetMainViewport();
     ImGuiViewport* main_viewport = ImGui::GetMainViewport();
     main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
     main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;

+ 1 - 0
docs/CHANGELOG.txt

@@ -91,6 +91,7 @@ Docking+Viewports Branch:
 
 
 - Viewports: fixed an issue where a window manually constrained to the main viewport while crossing
 - Viewports: fixed an issue where a window manually constrained to the main viewport while crossing
   over main viewport bounds isn't translated properly. (#7985)
   over main viewport bounds isn't translated properly. (#7985)
+- Backends: SDL2, SDL3, Win32: ensure that ImGuiPlatformMonitor list is available after backend Init call. (#7995)
 - Backends: Win32: fixed direct calls to platform_io.Platform_SetWindowPos()/Platform_SetWindowSize()
 - Backends: Win32: fixed direct calls to platform_io.Platform_SetWindowPos()/Platform_SetWindowSize()
   on windows created by application (typically main viewport).
   on windows created by application (typically main viewport).
 - Backends: Win32: fixed an issue where a viewport destroyed while clicking would hog
 - Backends: Win32: fixed an issue where a viewport destroyed while clicking would hog