| | |
| | | |
| | | @MainActor |
| | | final class AlignerApplicationDelegate: NSObject, NSApplicationDelegate { |
| | | private static let quickSwitchConfirmBeforeCloseDefaultsKey = "QuickSwitchConfirmBeforeClose" |
| | | |
| | | private let permissionChecker = SystemPermissionChecker() |
| | | private let launchOptions = Round0DebugLaunchOptions.parse(arguments: ProcessInfo.processInfo.arguments) |
| | | private let round1PoCOptions = Round1PerformancePoCOptions.parse(arguments: ProcessInfo.processInfo.arguments) |
| | |
| | | let controller = QuickSwitchSessionController( |
| | | snapshotLoader: quickSwitchSnapshotLoader(), |
| | | windowActivationService: quickSwitchWindowActivationService(), |
| | | windowCloseService: quickSwitchWindowCloseService(), |
| | | disableScreenshotRefresh: round1QuickSwitchOptions.disableScreenshotRefresh, |
| | | closeConfirmationRequired: quickSwitchConfirmBeforeClose, |
| | | onCloseConfirmationDisabled: { [weak self] in |
| | | self?.setQuickSwitchConfirmBeforeClose(false) |
| | | }, |
| | | debugHoveredAppGroupIndex: round1QuickSwitchOptions.debugHoveredAppGroupIndex, |
| | | debugOverlayWidth: round1QuickSwitchOptions.debugOverlayWidth, |
| | | debugKeySequence: round1QuickSwitchOptions.debugKeySequence, |
| | |
| | | let controller = QuickSwitchSessionController( |
| | | snapshotLoader: quickSwitchSnapshotLoader(), |
| | | windowActivationService: quickSwitchWindowActivationService(), |
| | | windowCloseService: quickSwitchWindowCloseService(), |
| | | disableScreenshotRefresh: round1QuickSwitchOptions.disableScreenshotRefresh, |
| | | closeConfirmationRequired: quickSwitchConfirmBeforeClose, |
| | | onCloseConfirmationDisabled: { [weak self] in |
| | | self?.setQuickSwitchConfirmBeforeClose(false) |
| | | }, |
| | | debugHoveredAppGroupIndex: round1QuickSwitchOptions.debugHoveredAppGroupIndex, |
| | | debugOverlayWidth: round1QuickSwitchOptions.debugOverlayWidth, |
| | | debugKeySequence: round1QuickSwitchOptions.debugKeySequence, |
| | |
| | | return FixtureQuickSwitchSnapshotLoader( |
| | | appCount: fixtureAppCount, |
| | | windowsPerApp: round1QuickSwitchOptions.fixtureWindowsPerApp ?? 1, |
| | | mode: .layout |
| | | mode: .layout, |
| | | usesMultipleDisplays: round1QuickSwitchOptions.fixtureMultiDisplay |
| | | ) |
| | | } |
| | | |
| | |
| | | return CGWindowAXWindowService(spaceIDsByWindowIDProvider: { _ in [:] }) |
| | | } |
| | | |
| | | private func quickSwitchWindowCloseService() -> any WindowCloseServiceProtocol { |
| | | if round1QuickSwitchOptions.debugWindowClose { |
| | | return DebugWindowCloseService() |
| | | } |
| | | |
| | | return CGWindowAXWindowService(spaceIDsByWindowIDProvider: { _ in [:] }) |
| | | } |
| | | |
| | | private var quickSwitchConfirmBeforeClose: Bool { |
| | | let value = UserDefaults.standard.object(forKey: Self.quickSwitchConfirmBeforeCloseDefaultsKey) |
| | | return (value as? Bool) ?? true |
| | | } |
| | | |
| | | private func setQuickSwitchConfirmBeforeClose(_ enabled: Bool) { |
| | | UserDefaults.standard.set(enabled, forKey: Self.quickSwitchConfirmBeforeCloseDefaultsKey) |
| | | DevelopmentDiagnostics.log("app.quickSwitch.closeConfirmationPreferenceChanged", [ |
| | | "confirmBeforeClose": enabled |
| | | ]) |
| | | } |
| | | |
| | | @objc private func showPermissions() { |
| | | DevelopmentDiagnostics.log("app.permissions.show", [ |
| | | "accessibility": permissionStatusString(accessibilityStatus()), |