浏览代码

Fix ToggleBorderlessFullscreen() Not Hiding Taskbar (#5383)

* Use glfwSetWindowMonitor instead of Pos and Size GLFW functions

* Fix window not resetting properly when toggling out of fullscreen, formatting
Aly 2 周之前
父节点
当前提交
78a81bf407
共有 1 个文件被更改,包括 18 次插入4 次删除
  1. 18 4
      src/platforms/rcore_desktop_glfw.c

+ 18 - 4
src/platforms/rcore_desktop_glfw.c

@@ -265,8 +265,15 @@ void ToggleBorderlessWindowed(void)
                 const int monitorHeight = mode->height;
 
                 // Set screen position and size
-                glfwSetWindowPos(platform.handle, monitorPosX, monitorPosY);
-                glfwSetWindowSize(platform.handle, monitorWidth, monitorHeight);
+                glfwSetWindowMonitor(
+                    platform.handle,
+                    monitors[monitor],
+                    monitorPosX,
+                    monitorPosY,
+                    monitorWidth,
+                    monitorHeight,
+                    mode->refreshRate
+                );
 
                 // Refocus window
                 glfwFocusWindow(platform.handle);
@@ -281,8 +288,15 @@ void ToggleBorderlessWindowed(void)
 
                 // Return previous screen size and position
                 // NOTE: The order matters here, it must set size first, then set position, otherwise the screen will be positioned incorrectly
-                glfwSetWindowSize(platform.handle,  CORE.Window.previousScreen.width, CORE.Window.previousScreen.height);
-                glfwSetWindowPos(platform.handle, CORE.Window.previousPosition.x, CORE.Window.previousPosition.y);
+                glfwSetWindowMonitor(
+                    platform.handle,
+                    NULL,
+                    CORE.Window.previousPosition.x,
+                    CORE.Window.previousPosition.y,
+                    CORE.Window.previousScreen.width,
+                    CORE.Window.previousScreen.height,
+            	    mode->refreshRate
+            	);
 
                 // Refocus window
                 glfwFocusWindow(platform.handle);