From 13e682ea9252ccf7b34d972f6b17dd87aa5c1b93 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 12 Oct 2026 21:11:39 +0200 Subject: [PATCH] fix(gtk): register the gresource before startup so style.css loads Ghostty's stylesheets (style.css, style-dark.css, style-hc*.css) were never loaded. AdwApplication loads them from `resource-base-path` once, during startup, and only if the resources exist at that moment. Zig's gresource is registered by a glib-compile-resources C constructor before main; the Rust build registered it lazily on first template instantiation (windows, dialogs), i.e. after startup. Visible effect: every rule in style.css was missing, e.g. the clipboard confirmation dialog (`clipboard-read = ask`) rendered its preview without the rounded inset and overlapping the "Remember choice" row. Registering in Application::new restores parity; the Adwaita "style-dark.css is deprecated" warnings Zig logs now appear too, which confirms the files are picked up. Test Plan: - clipboard-read = ask, run `printf '\e]52;c;?\a'`: dialog is pixel-identical to Ghostty 1.3.1 (nested weston capture) --- crates/ghostty-apprt-gtk/src/class/application.rs | 6 ++++++ docs/rewrite/notes/ghostty-apprt-gtk.md | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ghostty-apprt-gtk/src/class/application.rs b/crates/ghostty-apprt-gtk/src/class/application.rs index ac58d72..522a104 100644 --- a/crates/ghostty-apprt-gtk/src/class/application.rs +++ b/crates/ghostty-apprt-gtk/src/class/application.rs @@ -419,6 +419,12 @@ impl Application { pub fn new(core_app: Rc) -> Self { init_locale(); + // AdwApplication loads style.css & co. from `resource-base-path` once, + // during startup, and only if the resources exist then. Zig's + // gresource is registered by a C constructor before main; ours must + // be registered explicitly before startup. + crate::register_resources(); + // Capture GLib/GObject/GTK log messages. glib::log_set_writer_func(glib_log_writer); diff --git a/docs/rewrite/notes/ghostty-apprt-gtk.md b/docs/rewrite/notes/ghostty-apprt-gtk.md index ac80353..c93e3ab 100644 --- a/docs/rewrite/notes/ghostty-apprt-gtk.md +++ b/docs/rewrite/notes/ghostty-apprt-gtk.md @@ -3,7 +3,8 @@ ## Overview / status Port of ZIG/src/apprt/gtk (GTK4 + libadwaita, gtk4-rs 0.11 / libadwaita 0.9, baseline GTK 4.14 / adw 1.5). build.rs compiles resources/ui/**/*.blp with blueprint-compiler and bundles UI+CSS+icons into a gresource -(`register_resources()`). Inspector/imgui deferred (menu action is a no-op with TODO). Dropped the ghostty-core +(`register_resources()`, called in `Application::new` before startup so AdwApplication +auto-loads style.css from `resource-base-path`). Inspector/imgui deferred (menu action is a no-op with TODO). Dropped the ghostty-core dependency (cycle): the core boundary is the trait set in `src/core.rs`. ## Core trait boundary (src/core.rs, authoritative spec = the file)