From a7b6f355008237c28faad86c2188cc5f132aec64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 12 Jun 2022 21:36:26 +0200 Subject: [PATCH] Wayland: Fix size limits for fallback decorations The size limits set on our XDG surface did not include the sizes of the fallback decorations on all sides, when in use. This led to its content area being too small. Related to #2127 --- README.md | 1 + src/wl_window.c | 53 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3fd1a353..6a76c298 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: If `glfwInit` failed it would close stdin - [Wayland] Bugfix: Manual resizing with fallback decorations behaved erratically (#1991,#2115,#2127) + - [Wayland] Bugfix: Size limits included frame size for fallback decorations - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index 900aae2a..a32ccfb6 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -617,13 +617,6 @@ static GLFWbool createXdgSurface(_GLFWwindow* window) if (window->wl.title) xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title); - if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE) - xdg_toplevel_set_min_size(window->wl.xdg.toplevel, - window->minwidth, window->minheight); - if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE) - xdg_toplevel_set_max_size(window->wl.xdg.toplevel, - window->maxwidth, window->maxheight); - if (window->monitor) { xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel, @@ -642,6 +635,34 @@ static GLFWbool createXdgSurface(_GLFWwindow* window) setXdgDecorations(window); } + if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE) + { + int minwidth = window->minwidth; + int minheight = window->minheight; + + if (window->wl.decorations.top.surface) + { + minwidth += GLFW_BORDER_SIZE * 2; + minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; + } + + xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight); + } + + if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE) + { + int maxwidth = window->maxwidth; + int maxheight = window->maxheight; + + if (window->wl.decorations.top.surface) + { + maxwidth += GLFW_BORDER_SIZE * 2; + maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; + } + + xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight); + } + wl_surface_commit(window->wl.surface); wl_display_roundtrip(_glfw.wl.display); @@ -1877,8 +1898,26 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, { if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) minwidth = minheight = 0; + else + { + if (window->wl.decorations.top.surface) + { + minwidth += GLFW_BORDER_SIZE * 2; + minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; + } + } + if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE) maxwidth = maxheight = 0; + else + { + if (window->wl.decorations.top.surface) + { + maxwidth += GLFW_BORDER_SIZE * 2; + maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; + } + } + xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight); xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight); wl_surface_commit(window->wl.surface);