From 599061780379458c1e69d038e5557d61f2b64f1e Mon Sep 17 00:00:00 2001 From: clasher113 Date: Fri, 29 Aug 2025 19:38:57 +0300 Subject: [PATCH] fix: fullscreen monitor refresh rate --- src/window/detail/GLFWWindow.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index cbf628af..3ac45a1f 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -418,7 +418,7 @@ public: if (fullscreen) { glfwGetWindowPos(window, &posX, &posY); glfwSetWindowMonitor( - window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE + window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate ); } else { glfwSetWindowMonitor( @@ -596,6 +596,17 @@ static void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) { handler->input.setCursorPosition(xpos, ypos); } +static void iconify_callback(GLFWwindow* window, int iconified) { + auto handler = static_cast(glfwGetWindowUserPointer(window)); + if (handler->isFullscreen() && iconified == 0) { + GLFWmonitor* monitor = glfwGetPrimaryMonitor(); + const GLFWvidmode* mode = glfwGetVideoMode(monitor); + glfwSetWindowMonitor( + window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate + ); + } +} + static void create_standard_cursors() { for (int i = 0; i <= static_cast(CursorShape::LAST); i++) { int cursor = GLFW_ARROW_CURSOR + i; @@ -615,6 +626,7 @@ static void setup_callbacks(GLFWwindow* window) { glfwSetWindowSizeCallback(window, window_size_callback); glfwSetCharCallback(window, character_callback); glfwSetScrollCallback(window, scroll_callback); + glfwSetWindowIconifyCallback(window, iconify_callback); } std::tuple<