@@ -190,17 +190,41 @@ int our::Application::run(int run_for_frames) {
190190
191191 auto win_config = getWindowConfiguration (); // Returns the WindowConfiguration current struct instance.
192192
193- // Create a window with the given "WindowConfiguration" attributes.
194- // If it should be fullscreen, monitor should point to one of the monitors (e.g. primary monitor), otherwise it
195- // should be null
196- GLFWmonitor* monitor = win_config.isFullscreen ? glfwGetPrimaryMonitor () : nullptr ;
193+ // Create the window. When fullscreen is requested, prefer a borderless fullscreen window
194+ // instead of exclusive monitor fullscreen so leaving the game doesn't disturb other desktop windows
195+ GLFWmonitor* primaryMonitor = glfwGetPrimaryMonitor ();
196+ GLFWmonitor* monitor = nullptr ;
197+ int windowWidth = win_config.size .x ;
198+ int windowHeight = win_config.size .y ;
199+ int windowPosX = GLFW_DONT_CARE ;
200+ int windowPosY = GLFW_DONT_CARE ;
201+
202+ if (win_config.isFullscreen && primaryMonitor) {
203+ if (const GLFWvidmode* videoMode = glfwGetVideoMode (primaryMonitor)) {
204+ windowWidth = videoMode->width ;
205+ windowHeight = videoMode->height ;
206+ }
207+ glfwGetMonitorPos (primaryMonitor, &windowPosX, &windowPosY);
208+ glfwWindowHint (GLFW_DECORATED , GLFW_FALSE );
209+ glfwWindowHint (GLFW_AUTO_ICONIFY , GLFW_FALSE );
210+ glfwWindowHint (GLFW_FLOATING , GLFW_TRUE );
211+ }
212+
197213 // The last parameter "share" can be used to share the resources (OpenGL objects) between multiple windows.
198- window = glfwCreateWindow (win_config. size . x , win_config. size . y , win_config.title .c_str (), monitor, nullptr );
214+ window = glfwCreateWindow (windowWidth, windowHeight , win_config.title .c_str (), monitor, nullptr );
199215 if (!window) {
200216 std::cerr << " Failed to Create Window" << std::endl;
201217 glfwTerminate ();
202218 return -1 ;
203219 }
220+
221+ if (win_config.isFullscreen && primaryMonitor) {
222+ glfwSetWindowAttrib (window, GLFW_DECORATED , GLFW_FALSE );
223+ glfwSetWindowAttrib (window, GLFW_FLOATING , GLFW_TRUE ); // so taskbar doesn't cover the window
224+ glfwSetWindowPos (window, windowPosX, windowPosY);
225+ glfwSetWindowSize (window, windowWidth, windowHeight);
226+ }
227+
204228 glfwMakeContextCurrent (
205229 window); // Tell GLFW to make the context of our window the main context on the current thread.
206230
0 commit comments