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
e256c42e53
commit
ad76ae2301
42 files changed
+9301
-179
No files matched your search
@@ -1,8 +1,8 @@
|
||||
//! OpenGL function loader for the `GLArea`.
|
||||
//!
|
||||
//! GTK uses libepoxy, which exports dispatching stubs for every GL entry
|
||||
//! point and resolves them against whichever context (EGL or GLX) is current.
|
||||
//! So `dlsym` on libepoxy gives us a loader that works on both Wayland and
|
||||
//! GTK uses libepoxy, which exports a lazily-resolving function pointer for
|
||||
//! every GL entry point (resolved against whichever context, EGL or GLX, is
|
||||
//! current). So reading those pointers gives us a loader that works on both Wayland and
|
||||
//! X11, which is what `ghostty-renderer`'s `prepare_context(|name| ..)` and
|
||||
//! `glow::Context::from_loader_function` need. Call it only while the GLArea
|
||||
//! context is current.
|
||||
@@ -28,17 +28,25 @@ fn epoxy() -> Option<&'static libloading::Library> {
|
||||
}
|
||||
|
||||
/// Resolve an OpenGL function by name (null if unavailable).
|
||||
///
|
||||
/// libepoxy does not export `glFoo` symbols; it exports a function pointer
|
||||
/// *variable* `epoxy_glFoo` per entry point. The variable initially points
|
||||
/// at a resolver stub which, on first call, resolves the real function for
|
||||
/// the current context (EGL/GLX) and rewrites the variable. Reading the
|
||||
/// variable therefore yields a callable function pointer.
|
||||
#[must_use]
|
||||
pub fn proc_address(name: &str) -> *const c_void {
|
||||
let Some(lib) = epoxy() else {
|
||||
return std::ptr::null();
|
||||
};
|
||||
// SAFETY: we only read the symbol's address; the library is kept alive
|
||||
// for the whole process lifetime by the `static` above, so the returned
|
||||
// pointer stays valid. Callers cast it to the correct GL signature.
|
||||
let symbol = format!("epoxy_{name}");
|
||||
// SAFETY: we read the pointer value stored in the exported variable; the
|
||||
// library is kept alive for the whole process lifetime by the `static`
|
||||
// above, so the returned pointer stays valid. Callers cast it to the
|
||||
// correct GL signature.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
lib.get::<*const c_void>(name.as_bytes())
|
||||
.map_or(std::ptr::null(), |sym| *sym)
|
||||
lib.get::<*const *const c_void>(symbol.as_bytes())
|
||||
.map_or(std::ptr::null(), |sym| **sym)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user