From 7084221623a19ff609734e68865a10a3036331af Mon Sep 17 00:00:00 2001 From: albnavper <10882334+albnavper@users.noreply.github.com> Date: Sun, 26 Jul 2026 17:39:00 +0200 Subject: [PATCH 1/2] fix(linux): correct X11 child webview packing --- CHANGELOG.md | 11 ++++++++ src-tauri/Cargo.lock | 1 + src-tauri/Cargo.toml | 4 +++ src-tauri/src/strip.rs | 64 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b072041..6142f4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [Unreleased] + +### Fixed + +- **Linux/X11: the WebUI no longer occupies only the lower half of the window** + (issue #83). Tauri 2.11 inserts Linux child webviews into a GTK box with + `expand=true` and ignores their requested bounds, so the 38px tab strip and + content webview split the available height. Linux now gives the strip a fixed + 38px allocation and lets only the content webview expand. Other platforms are + unaffected. + ## [v0.7.0] — 2026-07-18 An issue-sweep release: nine tracker items land at once — Wayland layout, diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ebab2a6..8991e09 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1710,6 +1710,7 @@ version = "0.7.0" dependencies = [ "arboard", "base64 0.22.1", + "gtk", "image", "libc", "log", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8ea644b..8385045 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -46,6 +46,10 @@ libc = "0.2" # internal threads race Xlib otherwise (intermittent startup abort). dlopen # wrapper, so Wayland-only systems without libX11 degrade gracefully. x11-dl = "2" +# Tauri 2.11 builds Linux child webviews into the window's GtkBox and ignores +# their requested bounds. strip.rs sets per-child packing so the 38px strip +# stays fixed while the active content webview expands into the remaining area. +gtk = "0.18" [target.'cfg(target_os = "macos")'.dependencies] objc2 = "0.5" diff --git a/src-tauri/src/strip.rs b/src-tauri/src/strip.rs index a100364..a7c5ff1 100644 --- a/src-tauri/src/strip.rs +++ b/src-tauri/src/strip.rs @@ -22,6 +22,48 @@ use tauri::{ pub const STRIP_HEIGHT: f64 = 38.0; +#[cfg(any(test, target_os = "linux"))] +fn linux_child_packing(is_strip: bool) -> (bool, i32) { + if is_strip { + (false, STRIP_HEIGHT as i32) + } else { + (true, -1) + } +} + +/// Tauri 2.11's Linux `WindowChild` path calls `build_gtk(default_vbox)`; +/// wry then packs every webview into that GtkBox with expand=true and ignores +/// the requested child bounds. With the strip and content both expanding they +/// split the window vertically — the issue #83 "gap" is an oversized strip. +/// Correct the GTK child packing directly: fixed 38px strip, expanding content. +#[cfg(target_os = "linux")] +fn apply_linux_child_packing(webview: &Webview, is_strip: bool) { + if !linux_backend_is_x11() { + return; + } + let (expand, height) = linux_child_packing(is_strip); + if let Err(e) = webview.with_webview(move |native| { + use gtk::prelude::*; + + let child = native.inner(); + child.set_hexpand(true); + child.set_vexpand(expand); + child.set_size_request(-1, height); + + if let Some(parent) = child + .parent() + .and_then(|widget| widget.downcast::().ok()) + { + parent.set_child_packing(&child, expand, true, 0, gtk::PackType::Start); + parent.queue_resize(); + } else { + log::error!("strip: Linux child webview parent is not a GtkBox"); + } + }) { + log::error!("strip: failed to schedule Linux GTK child packing: {e}"); + } +} + /// Convert a logical child-webview position to the unit the platform's wry /// backend wants for `add_child` / `set_position`. /// @@ -318,12 +360,17 @@ fn build_strip_window( .inner_size() .map(|s| s.to_logical::(scale)) .unwrap_or(LogicalSize::new(1280.0, 830.0)); - if let Err(e) = win.add_child( + match win.add_child( swb, child_position(0.0, 0.0, scale), child_size(logical.width, STRIP_HEIGHT, scale), ) { - log::error!("strip: strip webview failed: {e}"); + Ok(strip_webview) => { + #[cfg(target_os = "linux")] + apply_linux_child_packing(&strip_webview, true); + drop(strip_webview); + } + Err(e) => log::error!("strip: strip webview failed: {e}"), } log::info!("strip: window {label} built, strip webview added"); @@ -736,6 +783,8 @@ pub(crate) fn add_tab_with(app: &AppHandle, window_label: &str, spec: TabSpec) { return; } }; + #[cfg(target_os = "linux")] + apply_linux_child_packing(&webview, false); // Seed the FRESH jar, then load the real target — cookies are committed // before the navigation request fires (set_cookie is synchronous on @@ -1499,7 +1548,16 @@ pub fn forget_window(app: &AppHandle, window_label: &str) { #[cfg(test)] mod tests { - use super::{partition_suffix, x11_from_env}; + use super::{linux_child_packing, partition_suffix, x11_from_env, STRIP_HEIGHT}; + + #[test] + fn linux_gtk_box_reserves_only_the_strip_height() { + // Issue #83: Tauri builds Linux child webviews into a GtkBox. If both + // children keep GTK's default expand=true, they split the window and + // produce the huge blank band. The strip is fixed; content gets rest. + assert_eq!(linux_child_packing(true), (false, STRIP_HEIGHT as i32)); + assert_eq!(linux_child_packing(false), (true, -1)); + } #[test] fn parses_partition_suffix() { From 8f2e814a2bf1306a01b043f5ce99f5924b0b2c67 Mon Sep 17 00:00:00 2001 From: Daniel Vecera <1vecera@users.noreply.github.com> Date: Thu, 27 Aug 2026 18:09:52 +0200 Subject: [PATCH 2/2] fix(linux): apply child packing on Wayland --- CHANGELOG.md | 7 +------ src-tauri/Cargo.toml | 4 ++-- src-tauri/src/strip.rs | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6142f4c..4ffe088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,7 @@ ### Fixed -- **Linux/X11: the WebUI no longer occupies only the lower half of the window** - (issue #83). Tauri 2.11 inserts Linux child webviews into a GTK box with - `expand=true` and ignores their requested bounds, so the 38px tab strip and - content webview split the available height. Linux now gives the strip a fixed - 38px allocation and lets only the content webview expand. Other platforms are - unaffected. +- **Linux: the WebUI no longer occupies only the lower half of the window** (issues #80/#83). Tauri 2.11 inserts child webviews into a GTK box with `expand=true` and ignores their requested bounds, so the 38px tab strip and content webview split the available height on both X11 and Wayland. Linux now gives the strip a fixed 38px allocation and lets only the content webview expand. Other platforms are unaffected. ## [v0.7.0] — 2026-07-18 diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8385045..cab4b10 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -47,8 +47,8 @@ libc = "0.2" # wrapper, so Wayland-only systems without libX11 degrade gracefully. x11-dl = "2" # Tauri 2.11 builds Linux child webviews into the window's GtkBox and ignores -# their requested bounds. strip.rs sets per-child packing so the 38px strip -# stays fixed while the active content webview expands into the remaining area. +# their requested bounds on X11 and Wayland. strip.rs sets per-child packing so +# the 38px strip stays fixed while active content expands into the remaining area. gtk = "0.18" [target.'cfg(target_os = "macos")'.dependencies] diff --git a/src-tauri/src/strip.rs b/src-tauri/src/strip.rs index a7c5ff1..88fd939 100644 --- a/src-tauri/src/strip.rs +++ b/src-tauri/src/strip.rs @@ -33,14 +33,14 @@ fn linux_child_packing(is_strip: bool) -> (bool, i32) { /// Tauri 2.11's Linux `WindowChild` path calls `build_gtk(default_vbox)`; /// wry then packs every webview into that GtkBox with expand=true and ignores -/// the requested child bounds. With the strip and content both expanding they -/// split the window vertically — the issue #83 "gap" is an oversized strip. -/// Correct the GTK child packing directly: fixed 38px strip, expanding content. +/// the requested child bounds. This behavior is shared by the X11 and Wayland +/// GTK backends: with the strip and content both expanding, they split the +/// window vertically and the oversized strip appears as a large empty gap. +/// Correct the GTK child packing directly on every Linux backend: fixed 38px +/// strip, expanding content. Keep backend-specific coordinate compensation in +/// `child_position` and `child_size`; packing itself is coordinate-free. #[cfg(target_os = "linux")] fn apply_linux_child_packing(webview: &Webview, is_strip: bool) { - if !linux_backend_is_x11() { - return; - } let (expand, height) = linux_child_packing(is_strip); if let Err(e) = webview.with_webview(move |native| { use gtk::prelude::*; @@ -1551,10 +1551,11 @@ mod tests { use super::{linux_child_packing, partition_suffix, x11_from_env, STRIP_HEIGHT}; #[test] - fn linux_gtk_box_reserves_only_the_strip_height() { - // Issue #83: Tauri builds Linux child webviews into a GtkBox. If both - // children keep GTK's default expand=true, they split the window and - // produce the huge blank band. The strip is fixed; content gets rest. + fn linux_gtk_box_reserves_only_the_strip_height_on_every_backend() { + // Issues #80/#83: Tauri builds both X11 and Wayland child webviews into + // a GtkBox. If both children keep GTK's default expand=true, they split + // the window and produce the huge blank band. The strip is fixed; + // content gets the rest, independently of backend-specific coordinates. assert_eq!(linux_child_packing(true), (false, STRIP_HEIGHT as i32)); assert_eq!(linux_child_packing(false), (true, -1)); }