Phase 9, MA1: crates/ghostty-macos (AppKit via objc2; empty stub on non-Apple targets) ports the foundation of Ghostty 1.3.1's Swift macOS app (ghostty/macos): main, AppDelegate (+Ghostty) with lifecycle, dock menu, open-file, notifications, shortcut sync and quit/reopen paths; MainMenu.xib as generated menu tables built into NSMenus; the Ghostty.App/Config/Surface wrappers driving libghostty in-process via ghostty-lib; the generic helpers; scripts/macos-bundle.sh to assemble Ghostty.app (dry-run on Linux). Feature areas are stubbed for MA2-MA5. Design and type mapping: docs/rewrite/notes/macos-app-design.md (App Intents is a Swift-only framework and cannot be ported). Compile-checked only (no macOS here): just check-macos passes for aarch64/x86_64-apple-darwin with -D warnings; 125 platform-independent tests run on Linux. Test Plan: - just check-macos - cargo test -p ghostty-macos
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
//! `AppDelegate+Ghostty.swift`: the Ghostty app delegate protocol
|
|
//! (`Ghostty.Delegate`), used by the libghostty glue for app-global
|
|
//! information.
|
|
|
|
use objc2::{MainThreadOnly, rc::Retained};
|
|
use objc2_app_kit::NSApplication;
|
|
use objc2_foundation::{NSObjectProtocol, NSUUID};
|
|
|
|
use super::app_delegate::AppDelegate;
|
|
use crate::{features::terminal::BaseTerminalController, ghostty::surface_view::SurfaceView};
|
|
|
|
impl AppDelegate {
|
|
/// `ghosttySurface(id:)`: find a surface view by its id in any terminal window.
|
|
#[must_use]
|
|
pub fn ghostty_surface(&self, id: &NSUUID) -> Option<Retained<SurfaceView>> {
|
|
for window in NSApplication::sharedApplication(self.mtm()).windows() {
|
|
let Some(controller) = window
|
|
.windowController()
|
|
.and_then(|c| c.downcast::<BaseTerminalController>().ok())
|
|
else {
|
|
continue;
|
|
};
|
|
|
|
for surface in controller.surface_tree() {
|
|
if surface.id().isEqual(Some(id)) {
|
|
return Some(surface);
|
|
}
|
|
}
|
|
}
|
|
|
|
None
|
|
}
|
|
}
|