Browse Source

Fix fullscreen and borderless windowed scaling on Wayland with HiDPI

ToggleFullscreen and ToggleBorderlessWindowed exit paths manually
scale screen size by DPI before passing to glfwSetWindowMonitor,
which double-scales on Wayland where GLFW_SCALE_FRAMEBUFFER already
handles it. Skip the manual resize on Wayland.

Also fix FramebufferSizeCallback fullscreen branch: on Wayland with
GLFW_SCALE_FRAMEBUFFER the framebuffer is still scaled in fullscreen,
so use the logical window size as screen size and derive screenScale
from the framebuffer/window ratio.

Fixes #5504
pull/5564/head
0xPD33 5 days ago
parent
commit
3f230027bf
1 changed files with 23 additions and 2 deletions
  1. +23
    -2
      src/platforms/rcore_desktop_glfw.c

+ 23
- 2
src/platforms/rcore_desktop_glfw.c View File

@ -221,7 +221,9 @@ void ToggleFullscreen(void)
#if !defined(__APPLE__)
// Make sure to restore render size considering HighDPI scaling
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
// NOTE: On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling, skip manual resize
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) &&
(glfwGetPlatform() != GLFW_PLATFORM_WAYLAND))
{
Vector2 scaleDpi = GetWindowScaleDPI();
CORE.Window.screen.width = (unsigned int)(CORE.Window.screen.width*scaleDpi.x);
@ -300,7 +302,9 @@ void ToggleBorderlessWindowed(void)
#if !defined(__APPLE__)
// Make sure to restore size considering HighDPI scaling
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
// NOTE: On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling, skip manual resize
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) &&
(glfwGetPlatform() != GLFW_PLATFORM_WAYLAND))
{
Vector2 scaleDpi = GetWindowScaleDPI();
CORE.Window.screen.width = (unsigned int)(CORE.Window.screen.width*scaleDpi.x);
@ -1871,6 +1875,23 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
CORE.Window.screen.height = height;
CORE.Window.screenScale = MatrixScale(1.0f, 1.0f, 1.0f);
SetMouseScale(1.0f, 1.0f);
// On Wayland with GLFW_SCALE_FRAMEBUFFER, the framebuffer is still scaled
// in fullscreen. Use logical window size as screen and apply screenScale.
if ((glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) &&
FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
int winWidth, winHeight;
glfwGetWindowSize(platform.handle, &winWidth, &winHeight);
if ((winWidth != width) || (winHeight != height))
{
CORE.Window.screen.width = winWidth;
CORE.Window.screen.height = winHeight;
float scaleX = (float)width/winWidth;
float scaleY = (float)height/winHeight;
CORE.Window.screenScale = MatrixScale(scaleX, scaleY, 1.0f);
}
}
}
else // Window mode (including borderless window)
{

Loading…
Cancel
Save