Sfoglia il codice sorgente

Backends: SDL2: Content Scales are always reported as 1.0 on Wayland. (#8921)

SDL_GetDisplayDPI() seems generally broken on X11/Wayland, but our logs shows that on Wayland we get both a content scale from SDL_GetDisplayDPI() and a framebuffer scale.
ocornut 22 ore fa
parent
commit
d92c8c6aff
3 ha cambiato i file con 8 aggiunte e 4 eliminazioni
  1. 1 1
      backends/imgui_impl_glfw.cpp
  2. 4 0
      backends/imgui_impl_sdl2.cpp
  3. 3 3
      docs/CHANGELOG.txt

+ 1 - 1
backends/imgui_impl_glfw.cpp

@@ -29,7 +29,7 @@
 
 // CHANGELOG
 // (minor and older changes stripped away, please see git history for details)
-//  2025-09-15: Content Scales always reported as 1.0 on Wayland. FramebufferScale are always reported as 1.0 on X11. (#8920, #8921)
+//  2025-09-15: Content Scales are always reported as 1.0 on Wayland. FramebufferScale are always reported as 1.0 on X11. (#8920, #8921)
 //  2025-07-08: Made ImGui_ImplGlfw_GetContentScaleForWindow(), ImGui_ImplGlfw_GetContentScaleForMonitor() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
 //  2025-06-18: Added support for multiple Dear ImGui contexts. (#8676, #8239, #8069)
 //  2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps.

+ 4 - 0
backends/imgui_impl_sdl2.cpp

@@ -21,6 +21,7 @@
 
 // CHANGELOG
 // (minor and older changes stripped away, please see git history for details)
+//  2025-09-15: Content Scales are always reported as 1.0 on Wayland. (#8921)
 //  2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
 //  2025-06-11: Added ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) and ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) helper to facilitate making DPI-aware apps.
 //  2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561)
@@ -719,6 +720,9 @@ float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window)
 
 float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
 {
+    const char* sdl_driver = SDL_GetCurrentVideoDriver();
+    if (sdl_driver && strcmp(sdl_driver, "wayland") == 0)
+        return 1.0f;
 #if SDL_HAS_PER_MONITOR_DPI
 #if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
     float dpi = 0.0f;

+ 3 - 3
docs/CHANGELOG.txt

@@ -112,9 +112,9 @@ Other Changes:
 - Backends: GLFW: distinguish X11 vs Wayland to fix various scaling issues.
   (#8920, #8921) [@TheBrokenRail, @pthom, @ocornut]
   - window/monitor content scales are always reported as 1.0 on Wayland.
-  - framebuffer scales are always reported as 1.0 on X11. (#8920, #8921)
-- Backends: GLFW:
-  [@TheBrokenRail, @pthom, @ocornut]
+  - framebuffer scales are always reported as 1.0 on X11.
+- Backends: SDL2: window/monitor content scales are always reported as 1.0 on Wayland.
+  (#8920, #8921) [@TheBrokenRail, @pthom, @ocornut]
 - Backends: SDL3: use SDL_GetWindowDisplayScale() on Mac to obtain DisplayFrameBufferScale,
   fixing incorrect values during resolution changes e.g. going fullscreen.
   (#8703, #4414) [@jclounge]