From 6a6ddc3f19333798002e37923b1380c337f58e05 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Tue, 21 Jun 2022 15:24:31 -0400 Subject: [PATCH] app: [Wayland] scale min/max window size correctly The xdg_toplevel expects the min/max window size in DP rather than pixels. The scaling factor would be applied twice because we supplied pixels that we scaled ourselves, resulting in windows twice the expected size on HiDPI screens. This bug probably went for so long without being detected because it only manifests if you actually set a minimum or maximum size. Signed-off-by: Chris Waldon --- app/os_wayland.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/os_wayland.go b/app/os_wayland.go index 98d02b65..b2115db8 100644 --- a/app/os_wayland.go +++ b/app/os_wayland.go @@ -1001,11 +1001,13 @@ func (w *window) Configure(options []Option) { } if prev.MinSize != cnf.MinSize { w.config.MinSize = cnf.MinSize - C.xdg_toplevel_set_min_size(w.topLvl, C.int32_t(cnf.MinSize.X), C.int32_t(cnf.MinSize.Y)) + scaled := cnf.MinSize.Div(w.scale) + C.xdg_toplevel_set_min_size(w.topLvl, C.int32_t(scaled.X), C.int32_t(scaled.Y)) } if prev.MaxSize != cnf.MaxSize { w.config.MaxSize = cnf.MaxSize - C.xdg_toplevel_set_max_size(w.topLvl, C.int32_t(cnf.MaxSize.X), C.int32_t(cnf.MaxSize.Y)) + scaled := cnf.MaxSize.Div(w.scale) + C.xdg_toplevel_set_max_size(w.topLvl, C.int32_t(scaled.X), C.int32_t(scaled.Y)) } } if cnf.Decorated != prev.Decorated {