mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 12:18:51 -05:00
wayland: Implement size limits and aspect ratio
This commit is contained in:
parent
0b6a4313dd
commit
f0f5d9f644
|
@ -2049,7 +2049,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
|
|||
/*! @brief Sets the size limits of the specified window.
|
||||
*
|
||||
* This function sets the size limits of the client area of the specified
|
||||
* window. If the window is full screen, the size limits only take effect if
|
||||
* window. If the window is full screen, the size limits only take effect
|
||||
* once it is made windowed. If the window is not resizable, this function
|
||||
* does nothing.
|
||||
*
|
||||
|
|
|
@ -55,7 +55,32 @@ static void handleConfigure(void* data,
|
|||
int32_t height)
|
||||
{
|
||||
_GLFWwindow* window = data;
|
||||
_glfwInputFramebufferSize(window, width, height);
|
||||
float aspectRatio;
|
||||
float targetRatio;
|
||||
|
||||
if (!window->monitor)
|
||||
{
|
||||
if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
|
||||
{
|
||||
aspectRatio = (float)width / (float)height;
|
||||
targetRatio = (float)window->numer / (float)window->denom;
|
||||
if (aspectRatio < targetRatio)
|
||||
height = width / targetRatio;
|
||||
else if (aspectRatio > targetRatio)
|
||||
width = height * targetRatio;
|
||||
}
|
||||
|
||||
if (window->minwidth != GLFW_DONT_CARE && width < window->minwidth)
|
||||
width = window->minwidth;
|
||||
else if (window->maxwidth != GLFW_DONT_CARE && width > window->maxwidth)
|
||||
width = window->maxwidth;
|
||||
|
||||
if (window->minheight != GLFW_DONT_CARE && height < window->minheight)
|
||||
height = window->minheight;
|
||||
else if (window->maxheight != GLFW_DONT_CARE && height > window->maxheight)
|
||||
height = window->maxheight;
|
||||
}
|
||||
|
||||
_glfwInputWindowSize(window, width, height);
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfwInputWindowDamage(window);
|
||||
|
@ -429,14 +454,14 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
|||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
{
|
||||
// TODO
|
||||
fprintf(stderr, "_glfwPlatformSetWindowSizeLimits not implemented yet\n");
|
||||
// TODO: find out how to trigger a resize.
|
||||
// The actual limits are checked in the wl_shell_surface::configure handler.
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
|
||||
{
|
||||
// TODO
|
||||
fprintf(stderr, "_glfwPlatformSetWindowAspectRatio not implemented yet\n");
|
||||
// TODO: find out how to trigger a resize.
|
||||
// The actual limits are checked in the wl_shell_surface::configure handler.
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||
|
|
Loading…
Reference in New Issue
Block a user