macos: remove unnecessary call

This commit is contained in:
Mitchell Hashimoto
2023-09-17 12:01:36 -07:00
parent 833be445ba
commit d911c49f44

View File

@ -305,7 +305,8 @@ extension Ghostty {
// We only support the standard clipboard // We only support the standard clipboard
if (location != GHOSTTY_CLIPBOARD_STANDARD) { return nil } if (location != GHOSTTY_CLIPBOARD_STANDARD) { return nil }
guard let appState = self.appState(fromSurface: userdata) else { return nil } guard let surface = self.surfaceUserdata(from: userdata) else { return nil }
guard let appState = self.appState(fromView: surface) else { return nil }
guard let str = NSPasteboard.general.string(forType: .string) else { return nil } guard let str = NSPasteboard.general.string(forType: .string) else { return nil }
// Ghostty requires we cache the string because the pointer we return has to remain // Ghostty requires we cache the string because the pointer we return has to remain
@ -385,7 +386,8 @@ extension Ghostty {
static func newTab(_ userdata: UnsafeMutableRawPointer?, config: ghostty_surface_config_s) { static func newTab(_ userdata: UnsafeMutableRawPointer?, config: ghostty_surface_config_s) {
guard let surface = self.surfaceUserdata(from: userdata) else { return } guard let surface = self.surfaceUserdata(from: userdata) else { return }
guard self.appState(fromSurface: userdata)?.windowDecorations else { guard let appState = self.appState(fromView: surface) else { return }
guard appState.windowDecorations else {
let alert = NSAlert() let alert = NSAlert()
alert.messageText = "Tabs are disabled" alert.messageText = "Tabs are disabled"
alert.informativeText = "Enable window decorations to use tabs" alert.informativeText = "Enable window decorations to use tabs"
@ -417,9 +419,8 @@ extension Ghostty {
} }
/// Returns the GhosttyState from the given userdata value. /// Returns the GhosttyState from the given userdata value.
static private func appState(fromSurface userdata: UnsafeMutableRawPointer?) -> AppState? { static private func appState(fromView view: SurfaceView) -> AppState? {
let surfaceView = Unmanaged<SurfaceView>.fromOpaque(userdata!).takeUnretainedValue() guard let surface = view.surface else { return nil }
guard let surface = surfaceView.surface else { return nil }
guard let app = ghostty_surface_app(surface) else { return nil } guard let app = ghostty_surface_app(surface) else { return nil }
guard let app_ud = ghostty_app_userdata(app) else { return nil } guard let app_ud = ghostty_app_userdata(app) else { return nil }
return Unmanaged<AppState>.fromOpaque(app_ud).takeUnretainedValue() return Unmanaged<AppState>.fromOpaque(app_ud).takeUnretainedValue()