From eb788cad88d4458c4ce07668b5d3fb0e2b50a591 Mon Sep 17 00:00:00 2001 From: Eduard Gert Date: Wed, 10 Jun 2026 16:37:07 +0200 Subject: [PATCH] fix dynamic window height on linux --- .../frontend/src/hooks/useAutoSizeWindow.ts | 25 ++++++++++++------- client/ui/frontend/src/lib/platform.ts | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/client/ui/frontend/src/hooks/useAutoSizeWindow.ts b/client/ui/frontend/src/hooks/useAutoSizeWindow.ts index 14a18308b..d4f4d80b2 100644 --- a/client/ui/frontend/src/hooks/useAutoSizeWindow.ts +++ b/client/ui/frontend/src/hooks/useAutoSizeWindow.ts @@ -1,6 +1,7 @@ import { useLayoutEffect, useRef } from "react"; import { Window } from "@wailsio/runtime"; import i18next from "@/lib/i18n"; +import { isLinux } from "@/lib/platform"; // Sizes the current Wails window to the measured content height (keeping `width`), // then shows it. Re-applies on content resize and language change. @@ -18,18 +19,24 @@ export function useAutoSizeWindow(width: number, ready: b Window.Show().catch(() => {}); Window.Focus().catch(() => {}); }; - const apply = () => { + const apply = async () => { if (!ready) return; const h = Math.ceil(el.getBoundingClientRect().height); if (h <= 0) return; - // Window.SetSize takes the frame size, so add the OS title-bar height or content clips. - Window.Size() - .then((frame) => { - const chrome = Math.max(0, frame.height - window.innerHeight); - return Window.SetSize(width, h + chrome); - }) - .then(showOnce) - .catch(() => {}); + try { + // Window.SetSize takes the frame size, so add the OS title-bar height or content clips. + const frame = await Window.Size(); + const targetH = h + Math.max(0, frame.height - window.innerHeight); + // Linux: SetSize no-ops on a mapped non-resizable window (X11), so pin via min/max instead. + if (isLinux()) { + await Window.SetMinSize(width, targetH); + await Window.SetMaxSize(width, targetH); + } + await Window.SetSize(width, targetH); + showOnce(); + } catch { + // window gone / not ready — ignore + } }; const scheduleApply = () => { cancelAnimationFrame(raf1); diff --git a/client/ui/frontend/src/lib/platform.ts b/client/ui/frontend/src/lib/platform.ts index 7a169b69e..c256dde23 100644 --- a/client/ui/frontend/src/lib/platform.ts +++ b/client/ui/frontend/src/lib/platform.ts @@ -36,3 +36,4 @@ function get(): Platform { export const isWindows = (): boolean => get().isWindows; export const isMacOS = (): boolean => get().isMacOS; +export const isLinux = (): boolean => !get().isWindows && !get().isMacOS;