From a6058f92678037bbf74d0016d4e9a1963d99e585 Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:02:55 -0300 Subject: [PATCH] Fixes GetCurrentMonitor() detection inconsistency issue --- src/rcore.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 66a914ee7..282fec17e 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1835,20 +1835,24 @@ int GetCurrentMonitor(void) int mx = 0; int my = 0; - int width = 0; - int height = 0; - monitor = monitors[i]; - glfwGetMonitorWorkarea(monitor, &mx, &my, &width, &height); - - if ((x >= mx) && - (x < (mx + width)) && - (y >= my) && - (y < (my + height))) + glfwGetMonitorPos(monitor, &mx, &my); + const GLFWvidmode *mode = glfwGetVideoMode(monitor); + if (mode) { - index = i; - break; + const int width = mode->width; + const int height = mode->height; + + if ((x >= mx) && + (x < (mx + width)) && + (y >= my) && + (y < (my + height))) + { + index = i; + break; + } } + else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor"); } } }