mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Wayland: Fix error from glfwSetWindowAspectRatio
The aspect ratio was applied during resize but any call to
glfwSetWindowAspectRatio emitted a GLFW_FEATURE_UNIMPLEMENTED error.
(cherry picked from commit 91f18fb576
)
This commit is contained in:
parent
48e0e0acf5
commit
6b9087c575
@ -174,6 +174,8 @@ information on what to include when reporting a bug.
|
||||
scale
|
||||
- [Wayland] Bugfix: Window content scale events were not emitted when monitor
|
||||
scale changed
|
||||
- [Wayland] Bugfix: `glfwSetWindowAspectRatio` reported an error instead of
|
||||
applying the specified ratio
|
||||
|
||||
|
||||
## Contact
|
||||
|
@ -1988,8 +1988,20 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
|
||||
int numer, int denom)
|
||||
{
|
||||
// TODO: find out how to trigger a resize.
|
||||
// The actual limits are checked in the xdg_toplevel::configure handler.
|
||||
if (window->wl.maximized || window->wl.fullscreen)
|
||||
return;
|
||||
|
||||
if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
|
||||
{
|
||||
const float aspectRatio = (float) window->wl.width / (float) window->wl.height;
|
||||
const float targetRatio = (float) numer / (float) denom;
|
||||
if (aspectRatio < targetRatio)
|
||||
window->wl.height = window->wl.width / targetRatio;
|
||||
else if (aspectRatio > targetRatio)
|
||||
window->wl.width = window->wl.height * targetRatio;
|
||||
|
||||
resizeWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
|
||||
|
Loading…
Reference in New Issue
Block a user