From 7eacac24d53aba1443d54eaa2fd1958bca37dc52 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 9 Dec 2019 15:14:56 -0800 Subject: [PATCH] SetWindowMonitor made functioning again. (#1036) * We get the video mode from the target monitor and use that to set, therefore keeping windowed-fullscreen * Added a GLFW_AUTO_ICONIFY 0 hint so that glfw does not minimize the window when changing focus from a windowed fullscreen window. This is more expected behavior for windowed full screen, when a user alt-tabs or clicks on a window in the other monitor, they expect their windowed-fullscreen window to remaining up. --- src/core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index e33034173..739d54dd7 100644 --- a/src/core.c +++ b/src/core.c @@ -933,8 +933,9 @@ void SetWindowMonitor(int monitor) if ((monitor >= 0) && (monitor < monitorCount)) { - //glfwSetWindowMonitor(window, monitors[monitor], 0, 0, screenWidth, screenHeight, GLFW_DONT_CARE); TraceLog(LOG_INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor])); + const GLFWvidmode* mode = glfwGetVideoMode(monitors[monitor]); + glfwSetWindowMonitor(window, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate); } else TraceLog(LOG_WARNING, "Selected monitor not found"); #endif @@ -2743,6 +2744,15 @@ static bool InitGraphicsDevice(int width, int height) } } +#if defined(PLATFORM_DESKTOP) + // If we are windowed fullscreen, ensures that window does not minimize + // when focus is lost. + if (screenHeight == displayHeight && screenWidth == displayWidth) + { + glfwWindowHint(GLFW_AUTO_ICONIFY, 0); + } +#endif + TraceLog(LOG_WARNING, "Closest fullscreen videomode: %i x %i", displayWidth, displayHeight); // NOTE: ISSUE: Closest videomode could not match monitor aspect-ratio, for example,