mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 11:35:11 +00:00
Wayland: Emit size event when setting aspect ratio
This commit is contained in:
parent
8397b39afa
commit
c1a79c1c41
@ -1986,17 +1986,26 @@ void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom)
|
|||||||
if (window->wl.maximized || window->wl.fullscreen)
|
if (window->wl.maximized || window->wl.fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int width = window->wl.width, height = window->wl.height;
|
||||||
|
|
||||||
if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
|
if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
|
||||||
{
|
{
|
||||||
const float aspectRatio = (float) window->wl.width / (float) window->wl.height;
|
const float aspectRatio = (float) width / (float) height;
|
||||||
const float targetRatio = (float) numer / (float) denom;
|
const float targetRatio = (float) numer / (float) denom;
|
||||||
if (aspectRatio < targetRatio)
|
if (aspectRatio < targetRatio)
|
||||||
window->wl.height = window->wl.width / targetRatio;
|
height /= targetRatio;
|
||||||
else if (aspectRatio > targetRatio)
|
else if (aspectRatio > targetRatio)
|
||||||
window->wl.width = window->wl.height * targetRatio;
|
width *= targetRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width != window->wl.width || height != window->wl.height)
|
||||||
|
{
|
||||||
|
window->wl.width = width;
|
||||||
|
window->wl.height = height;
|
||||||
resizeWindow(window);
|
resizeWindow(window);
|
||||||
|
|
||||||
|
_glfwInputWindowSize(window, width, height);
|
||||||
|
|
||||||
if (window->wl.visible)
|
if (window->wl.visible)
|
||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user