fix: fullscreen monitor refresh rate

This commit is contained in:
clasher113 2025-08-29 19:38:57 +03:00
parent 77b251ef09
commit 5990617803

View File

@ -418,7 +418,7 @@ public:
if (fullscreen) { if (fullscreen) {
glfwGetWindowPos(window, &posX, &posY); glfwGetWindowPos(window, &posX, &posY);
glfwSetWindowMonitor( glfwSetWindowMonitor(
window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate
); );
} else { } else {
glfwSetWindowMonitor( glfwSetWindowMonitor(
@ -596,6 +596,17 @@ static void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) {
handler->input.setCursorPosition(xpos, ypos); handler->input.setCursorPosition(xpos, ypos);
} }
static void iconify_callback(GLFWwindow* window, int iconified) {
auto handler = static_cast<GLFWWindow*>(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() { static void create_standard_cursors() {
for (int i = 0; i <= static_cast<int>(CursorShape::LAST); i++) { for (int i = 0; i <= static_cast<int>(CursorShape::LAST); i++) {
int cursor = GLFW_ARROW_CURSOR + i; int cursor = GLFW_ARROW_CURSOR + i;
@ -615,6 +626,7 @@ static void setup_callbacks(GLFWwindow* window) {
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetCharCallback(window, character_callback); glfwSetCharCallback(window, character_callback);
glfwSetScrollCallback(window, scroll_callback); glfwSetScrollCallback(window, scroll_callback);
glfwSetWindowIconifyCallback(window, iconify_callback);
} }
std::tuple< std::tuple<