Skip to content

[rcore][GLFW] Fix borderless-windowed mode being always on top#5868

Open
auwsmit wants to merge 2 commits into
raysan5:masterfrom
auwsmit:patch-2
Open

[rcore][GLFW] Fix borderless-windowed mode being always on top#5868
auwsmit wants to merge 2 commits into
raysan5:masterfrom
auwsmit:patch-2

Conversation

@auwsmit

@auwsmit auwsmit commented May 14, 2026

Copy link
Copy Markdown

Don't pass a monitor to glfwSetWindowMonitor(). This avoids setting the flag internal to glfw which keeps the window always on top.

BorderlessWindowed still works fine, and is properly detected on my two monitors at different resolutions.

Addresses this issue: #5854, but only for borderless FS.

A workaround for regular aka "exclusive" Fullscreen is mentioned in that thread, just add this to raylib's loop:

if (!IsWindowFocused() && IsWindowFullscreen())
{
    MinimizeWindow();
}

Don't pass a monitor to glfwSetWindowMonitor(). This avoids setting the flag which keeps the window always on top.
@auwsmit auwsmit changed the title Fix borderless fullscreen being always on top Fix borderless-windowed mode being always on top May 15, 2026
@raysan5

raysan5 commented May 18, 2026

Copy link
Copy Markdown
Owner

@auwsmit This is a sensible change, have you tested it on Windows, Linux, macOS and with multiple monitors and multiple DPIs?

@raysan5 raysan5 changed the title Fix borderless-windowed mode being always on top [rcore][GLFW] Fix borderless-windowed mode being always on top May 18, 2026
@auwsmit

auwsmit commented May 18, 2026

Copy link
Copy Markdown
Author

@raysan5 Testing on Linux, it does create a problem where the taskbar stays on top of the borderless window (at least for my laptop with wayland and KDE).

So is the best approach to do an #if windows so this change only affects Windows? Is something like this code snippet the proper way to do it?:

                // Set screen position and size
            #if defined(_WIN32)
                // NOTE: To prevent the window from always staying on top, don't pass a monitor at this point.
                glfwSetWindowMonitor(platform.handle, NULL, CORE.Window.position.x, CORE.Window.position.y,
                    CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate);
            #else
                glfwSetWindowMonitor(platform.handle, monitors[monitor], CORE.Window.position.x, CORE.Window.position.y,
                    CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate);
            #endif

Also sorry about closing the other issue and making this one. I realize in retrospect I probably should've just modified the old PR with a new commit and didnt have to close it and make this new one, but now I know not to that in the future.

@raysan5

raysan5 commented May 24, 2026

Copy link
Copy Markdown
Owner

As I commented, this is a sensible change, it should be tested on a multi-monitor configuration and with different DPI monitors, I think the change can impact current behaviour, for example have you tried opening the window from a different working monitor instead of primary monitor? because I think that NULL always uses primary instead of current...

Only apply the fix for Windows OS, since that seems to be the only
platform with the issue.
@auwsmit

auwsmit commented May 26, 2026

Copy link
Copy Markdown
Author

@raysan5 Did thorough testing on Windows with two monitors on two different PCs, at different resolutions and refresh rates. Everything seems to behave the same as before, except you can alt tab properly. 👍

I believe it is still able to get the correct monitor size and position from the earlier call to glfwGetMonitorPos() which remains unchanged.

@raysan5 raysan5 added the windowing Issues about the window system label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

windowing Issues about the window system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants