feat(apprt-gtk): port the GTK4/libadwaita app runtime
Ports ZIG/src/apprt/gtk into ghostty-apprt-gtk: every GObject class (application, window, tab, split tree, surface + scrolled window, child-exited banner, search/key-state/resize overlays, command palette, global shortcuts, all dialogs, config wrapper) as glib subclasses with the same GType names, properties, signals and template children; GDK key translation; X11 and Wayland window-protocol helpers (blur, CSD, quick terminal via gtk4-layer-shell); single-instance D-Bus IPC; gsettings; cgroup scope creation. build.rs compiles Ghostty's blueprints with blueprint-compiler and bundles UI, CSS and icons into a gresource, as Ghostty's build does. The core is not ported yet, so the crate defines the boundary it needs in src/core.rs (CoreApp, CoreSurface, RtApp, RtSurface, Waker); the spec is in docs/rewrite/notes/ghostty-apprt-gtk.md. ghostty-core will implement these traits (the crate no longer depends on core to avoid a cycle). examples/demo.rs runs the app with a dummy core that clears the GLArea; it launches on Wayland without GTK criticals. Stubs/open items: toggle_visibility, float_window, secure_input and close_all_windows return false; inspector is a no-op; X11/Wayland protocol code is untested against real compositors; gtk4-rs doesn't expose the GLArea framebuffer id, so the renderer must query it. Also registers ghostty-apprt and ghostty-cli in workspace.dependencies. Test Plan: - cargo test -p ghostty-apprt-gtk (36 tests) - DEMO_QUIT_AFTER_MS=3000 cargo run -p ghostty-apprt-gtk --example demo
This commit is contained in:
1 parent
72434a1255
commit
88cc13871c
80 files changed
+17271
-4
No files matched your search
@@ -0,0 +1,79 @@
|
||||
//! GTK version helpers (port of `apprt/gtk/gtk_version.zig`).
|
||||
//!
|
||||
//! Zig reads the compile-time version from the headers; here it is the
|
||||
//! version of the gtk4-rs `v4_*` feature level this crate is compiled against
|
||||
//! (see `Cargo.toml`) combined with the system library detected at runtime.
|
||||
|
||||
/// A (major, minor, micro) version triple.
|
||||
pub type Version = (u32, u32, u32);
|
||||
|
||||
/// The minimum GTK version this crate is compiled against (feature level
|
||||
/// `v4_14`). Newer symbols must be guarded with [`at_least`]/feature flags.
|
||||
pub const COMPTIME_VERSION: Version = (4, 14, 0);
|
||||
|
||||
/// Returns the runtime GTK version.
|
||||
pub fn get_runtime_version() -> Version {
|
||||
(
|
||||
gtk::major_version(),
|
||||
gtk::minor_version(),
|
||||
gtk::micro_version(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs the build and runtime GTK version.
|
||||
pub fn log_version() {
|
||||
let (a, b, c) = COMPTIME_VERSION;
|
||||
let (x, y, z) = get_runtime_version();
|
||||
log::info!("GTK version build={a}.{b}.{c} runtime={x}.{y}.{z}");
|
||||
}
|
||||
|
||||
/// Verifies that the GTK version at runtime is at least the given version.
|
||||
/// Unlike Zig this can't compile out unknown symbols; callers needing newer
|
||||
/// API must gate it on a cargo feature too.
|
||||
pub fn at_least(major: u32, minor: u32, micro: u32) -> bool {
|
||||
// Anything below the build level is trivially satisfied by the runtime
|
||||
// requirement of the build level, but we still check the runtime.
|
||||
runtime_at_least(major, minor, micro)
|
||||
}
|
||||
|
||||
/// Verifies that the GTK runtime version is at least the given version.
|
||||
pub fn runtime_at_least(major: u32, minor: u32, micro: u32) -> bool {
|
||||
get_runtime_version() >= (major, minor, micro)
|
||||
}
|
||||
|
||||
/// Verifies that the GTK runtime version is older than the given version.
|
||||
pub fn runtime_until(major: u32, minor: u32, micro: u32) -> bool {
|
||||
get_runtime_version() < (major, minor, micro)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn at_least_test() {
|
||||
let (a, b, c) = get_runtime_version();
|
||||
for f in [at_least, runtime_at_least] {
|
||||
assert!(f(a, b, c));
|
||||
assert!(!f(a, b, c + 1));
|
||||
assert!(!f(a, b + 1, c));
|
||||
assert!(!f(a + 1, b, c));
|
||||
assert!(f(a - 1, b, c));
|
||||
assert!(f(a - 1, b + 1, c));
|
||||
assert!(f(a - 1, b, c + 1));
|
||||
assert!(f(a, b - 1, c + 1));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_until_test() {
|
||||
let (a, b, c) = get_runtime_version();
|
||||
assert!(!runtime_until(a, b, c));
|
||||
assert!(runtime_until(a, b, c + 1));
|
||||
assert!(runtime_until(a, b + 1, c));
|
||||
assert!(runtime_until(a + 1, b, c));
|
||||
assert!(!runtime_until(a - 1, b, c));
|
||||
assert!(!runtime_until(a - 1, b + 1, c));
|
||||
assert!(!runtime_until(a, b - 1, c + 1));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user