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
29 lines
1.1 KiB
Rust
29 lines
1.1 KiB
Rust
//! `Sources/Features/Custom App Icon` (owner: MA4).
|
|
//! MA1 provides only the notification name and the `AppDelegate.updateAppIcon`
|
|
//! hook. TODO(MA4): AppIcon, ColorizedGhosttyIcon, DockTilePlugin, UserDefaults+AppIcon.
|
|
|
|
use crate::helpers::notification_center::Name;
|
|
|
|
/// `Notification.Name.ghosttyIconDidChange` (posted on the *distributed*
|
|
/// notification center).
|
|
pub const GHOSTTY_ICON_DID_CHANGE: Name = Name("com.mitchellh.ghostty.iconDidChange");
|
|
|
|
/// Posts `.ghosttyIconDidChange` on the distributed notification center
|
|
/// (`DistributedNotificationCenter.default().postNotificationName(...,
|
|
/// deliverImmediately: true)`), which the dock tile plugin observes.
|
|
#[cfg(target_vendor = "apple")]
|
|
#[allow(unsafe_code)]
|
|
pub fn post_icon_did_change() {
|
|
use objc2_foundation::{NSDistributedNotificationCenter, NSString};
|
|
let center = NSDistributedNotificationCenter::defaultCenter();
|
|
// SAFETY: a name string, no object/userInfo.
|
|
unsafe {
|
|
center.postNotificationName_object_userInfo_deliverImmediately(
|
|
&NSString::from_str(GHOSTTY_ICON_DID_CHANGE.raw_value()),
|
|
None,
|
|
None,
|
|
true,
|
|
);
|
|
}
|
|
}
|