From 7a0e7c6c012b6d3697389bf294f2321430e3b63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 16 Apr 2022 11:15:10 +0200 Subject: [PATCH] wayland: take (visible) border width into account on configure events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the compositor is asking us to resize ourselves, take our (visible) CSD borders into account. This is similar to how we already take the titlebar size into account. This fixes an issue where the window size “jumps” when the user starts an interactive resize, when csd.border-width > 0. This as been observed in GNOME. --- CHANGELOG.md | 2 ++ wayland.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 724bd636..3bd70f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,8 @@ (https://codeberg.org/dnkl/foot/issues/1009). * Window geometry when CSDs are enabled and CSD border width set to a non-zero value. This fixes window snapping in e.g. GNOME. +* Window size “jumping” when starting an interactive resize when CSDs + are enabled, and CSD border width set to a non-zero value. ### Security diff --git a/wayland.c b/wayland.c index 7206d982..d77cd65d 100644 --- a/wayland.c +++ b/wayland.c @@ -746,9 +746,15 @@ xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, else if (csd_was_enabled && !enable_csd) csd_destroy(win); - if (enable_csd && new_width > 0 && new_height > 0) + if (enable_csd && new_width > 0 && new_height > 0) { new_height -= win->term->conf->csd.title_height; + if (!win->is_maximized) { + new_height -= 2 * win->term->conf->csd.border_width_visible; + new_width -= 2 * win->term->conf->csd.border_width_visible; + } + } + xdg_surface_ack_configure(xdg_surface, serial); #if 1