mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: fix bug where like... 5 terminals were being launched in the
background
This commit is contained in:
@ -7,12 +7,10 @@ extension Ghostty {
|
|||||||
/// split direction by splitting the terminal.
|
/// split direction by splitting the terminal.
|
||||||
struct TerminalSplit: View {
|
struct TerminalSplit: View {
|
||||||
@Environment(\.ghosttyApp) private var app
|
@Environment(\.ghosttyApp) private var app
|
||||||
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle: String?
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if let app = app {
|
if let app = app {
|
||||||
TerminalSplitRoot(app: app)
|
TerminalSplitRoot(app: app)
|
||||||
.navigationTitle(surfaceTitle ?? "Ghostty")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,7 +47,6 @@ extension Ghostty {
|
|||||||
class Leaf: ObservableObject {
|
class Leaf: ObservableObject {
|
||||||
let app: ghostty_app_t
|
let app: ghostty_app_t
|
||||||
@Published var surface: SurfaceView
|
@Published var surface: SurfaceView
|
||||||
@Published var parent: SplitNode? = nil
|
|
||||||
|
|
||||||
/// Initialize a new leaf which creates a new terminal surface.
|
/// Initialize a new leaf which creates a new terminal surface.
|
||||||
init(_ app: ghostty_app_t) {
|
init(_ app: ghostty_app_t) {
|
||||||
@ -85,11 +82,14 @@ extension Ghostty {
|
|||||||
/// This is an ignored value because at the root we can't close.
|
/// This is an ignored value because at the root we can't close.
|
||||||
@State private var ignoredRequestClose: Bool = false
|
@State private var ignoredRequestClose: Bool = false
|
||||||
|
|
||||||
|
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle: String?
|
||||||
|
|
||||||
init(app: ghostty_app_t) {
|
init(app: ghostty_app_t) {
|
||||||
_node = State(initialValue: SplitNode.noSplit(.init(app)))
|
_node = State(wrappedValue: SplitNode.noSplit(.init(app)))
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
switch (node) {
|
switch (node) {
|
||||||
case .noSplit(let leaf):
|
case .noSplit(let leaf):
|
||||||
TerminalSplitLeaf(leaf: leaf, node: $node, requestClose: $ignoredRequestClose)
|
TerminalSplitLeaf(leaf: leaf, node: $node, requestClose: $ignoredRequestClose)
|
||||||
@ -101,6 +101,8 @@ extension Ghostty {
|
|||||||
TerminalSplitContainer(direction: .vertical, node: $node, container: container)
|
TerminalSplitContainer(direction: .vertical, node: $node, container: container)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.navigationTitle(surfaceTitle ?? "Ghostty")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A noSplit leaf node of a split tree.
|
/// A noSplit leaf node of a split tree.
|
||||||
|
@ -476,6 +476,7 @@ pub fn deinit(self: *Surface) void {
|
|||||||
self.alloc.destroy(self.font_group);
|
self.alloc.destroy(self.font_group);
|
||||||
|
|
||||||
self.alloc.destroy(self.renderer_state.mutex);
|
self.alloc.destroy(self.renderer_state.mutex);
|
||||||
|
log.info("surface closed addr={x}", .{@ptrToInt(self)});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called from the app thread to handle mailbox messages to our specific
|
/// Called from the app thread to handle mailbox messages to our specific
|
||||||
|
Reference in New Issue
Block a user