feat(core): port App/Surface and wire up the runnable ghostty binary
This is the integration step that turns the ported crates into a working
terminal: `cargo run` now opens a GTK window running the user's shell.
ghostty-core ports App.zig, Surface.zig (split into keyboard, mouse,
binding, clipboard and config submodules), surface_mouse.zig and
global.zig, and implements the runtime traits. perform_binding_action
handles every binding action.
Cross-crate integration:
- The core<->runtime traits (CoreApp, CoreSurface, RtApp, RtSurface,
Waker) move from apprt-gtk into ghostty_apprt::runtime_api so the core
stays runtime-agnostic; Scrollbar/RendererHealth stand-ins are replaced
by the real terminal/renderer types.
- termio now uses ghostty_renderer::state::{State, SharedState}; the
renderer calls kitty_update; image-storage-limit is applied at init
and on config change.
- The search thread locks the terminal through a TerminalLock trait so
it can share the render state mutex; termio's Wakeup gained a hook to
wake the renderer thread.
- apprt-gtk: GL proc addresses are resolved through libepoxy's
epoxy_glFoo pointer variables (plain glFoo symbols resolved to null),
default DPI fixed to 96, libadwaita version read without GTK init so
--version works headless.
The root binary dispatches +actions to ghostty-cli (list-fonts,
show-face and new-window are now wired) and otherwise runs the GTK app
with the real core.
Verified at runtime on Wayland and X11: shell prompt and colored output
render, child exit closes the window cleanly. Not yet verified: keyboard
and mouse input, clipboard, IME, tabs and splits (no key injection was
possible in this environment). GHOSTTY_DEBUG_SCREENSHOT=<png> dumps the
renderer's last frame for headless checks.
Test Plan:
- cargo test --workspace (2890 passed)
- cargo clippy --workspace --all-targets -- -D warnings
- GSETTINGS_BACKEND=memory GHOSTTY_RESOURCES_DIR=/usr/share/ghostty \
cargo run
This commit is contained in:
1 parent
9c3eeeba50
commit
3266108c10
42 files changed
+9301
-179
No files matched your search
@@ -41,9 +41,9 @@ use crate::class::split_tree::SplitTree;
|
||||
use crate::class::surface::{Size, Surface};
|
||||
use crate::class::tab::Tab;
|
||||
use crate::class::window::{SelectTab, TabOverrides, Window};
|
||||
use crate::core::{AppMessage, CoreApp, RtApp, SurfaceId};
|
||||
use crate::css::CssProviders;
|
||||
use crate::winproto;
|
||||
use ghostty_apprt::runtime_api::{AppMessage, CoreApp, RtApp, SurfaceId};
|
||||
|
||||
/// Errors from [`Application::run_loop`].
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! scrolled window), embedding a `GtkGLArea` that the core renders into.
|
||||
//!
|
||||
//! The "apprt Surface" of Zig (`Surface.zig`, the object the core calls back
|
||||
//! into) is [`RtSurfaceHandle`], which implements [`crate::core::RtSurface`]
|
||||
//! into) is [`RtSurfaceHandle`], which implements [`ghostty_apprt::runtime_api::RtSurface`]
|
||||
//! and holds only a weak reference to the widget.
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
@@ -43,11 +43,11 @@ use crate::class::search_overlay::SearchOverlay;
|
||||
use crate::class::surface_child_exited::SurfaceChildExited;
|
||||
use crate::class::title_dialog::{self, TitleDialog};
|
||||
use crate::class::window::Window;
|
||||
use crate::core::{
|
||||
use crate::key as gtk_key;
|
||||
use ghostty_apprt::runtime_api::{
|
||||
ClipboardError, CoreSurface, DesiredFontSize, InputEffect, MIN_WINDOW_HEIGHT_CELLS,
|
||||
MIN_WINDOW_WIDTH_CELLS, RtSurface, SurfaceId,
|
||||
};
|
||||
use crate::key as gtk_key;
|
||||
|
||||
/// Simple dimensions struct for the surface used by various properties
|
||||
/// (Zig: `Surface.Size`, GType `GhosttySurfaceSize`).
|
||||
@@ -1834,6 +1834,29 @@ impl RtSurface for RtSurfaceHandle {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn gl_proc_address(&self, name: &str) -> *const std::ffi::c_void {
|
||||
crate::gl::proc_address(name)
|
||||
}
|
||||
|
||||
fn create_scope_fn(&self) -> Option<ghostty_apprt::runtime_api::CreateScopeFn> {
|
||||
// GDBusConnection is thread-safe; the closure runs on the IO thread
|
||||
// right after fork.
|
||||
let dbus = gtk::gio::Application::default().and_then(|a| a.dbus_connection())?;
|
||||
Some(std::sync::Arc::new(move |pid, memory_high, tasks_max| {
|
||||
Some(
|
||||
crate::cgroup::create_scope(
|
||||
&dbus,
|
||||
pid,
|
||||
crate::cgroup::Options {
|
||||
memory_high,
|
||||
tasks_max,
|
||||
},
|
||||
)
|
||||
.map_err(|e| e.to_string()),
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
fn redraw_inspector(&self) {
|
||||
if let Some(s) = self.gobj() {
|
||||
s.redraw_inspector();
|
||||
|
||||
Reference in new issue
Block a user