Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions LaunchNext/LaunchpadApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ class BorderlessWindow: NSWindow {
@main
struct LaunchpadApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene { Settings {} }
var body: some Scene {
Settings{
EmptyView()
}
.commands {
CommandGroup(replacing: .appSettings) {
Button("Settings") {
AppDelegate.shared?.openSettings()
}
.keyboardShortcut(",", modifiers: .command)
}
}
}
}

class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSGestureRecognizerDelegate {
Expand Down Expand Up @@ -74,7 +86,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSGestureR

if appStore.isFullscreenMode { updateWindowMode(isFullscreen: true) }
}


private var isLaunchpadWindowVisibleNow: Bool {
guard windowIsVisible, !isAnimatingWindow, let w = window else { return false }
if !w.isVisible { return false }
if !w.occlusionState.contains(.visible) { return false }
return true
}

func openSettings() {
guard isLaunchpadWindowVisibleNow else { return }
self.appStore.isSetting = true
}

// MARK: - Global Hotkey

func updateGlobalHotKey(configuration: AppStore.HotKeyConfiguration?) {
Expand Down