diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-06 16:40:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-06 16:40:48 +0100 |
commit | 762a31169d5e0939fda5bdaab537cec5ab39f870 (patch) | |
tree | 7177d1f2ad04e881457799c507d104c52a278c99 | |
parent | fb6cf1e3b7a4734dac36cd40ddaaaedf5010d766 (diff) | |
parent | 635da44ef8d1875e2e8b8b7fbfbc574456e92226 (diff) |
Merge pull request #57633 from jordigcs/x11-snap-refresh-rate
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 844b5616c4..c3b44f348c 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -33,6 +33,7 @@ #ifdef X11_ENABLED #include "core/config/project_settings.h" +#include "core/math/math_funcs.h" #include "core/string/print_string.h" #include "core/string/ustring.h" #include "detect_prime_x11.h" @@ -1098,7 +1099,8 @@ float DisplayServerX11::screen_get_refresh_rate(int p_screen) const { for (int mode = 0; mode < screen_info->nmode; mode++) { XRRModeInfo m_info = screen_info->modes[mode]; if (m_info.id == current_mode) { - return (float)m_info.dotClock / ((float)m_info.hTotal * (float)m_info.vTotal); + // Snap to nearest 0.01 to stay consistent with other platforms. + return Math::snapped((float)m_info.dotClock / ((float)m_info.hTotal * (float)m_info.vTotal), 0.01); } } } |