Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: dynamically show app in dock & cmd+tab#224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 1 commit intomainfromethan/dynamically-show-in-dock
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
3 changes: 3 additions & 0 deletionsCoder-Desktop/Coder-Desktop/Coder_DesktopApp.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,20 +20,23 @@ struct DesktopApp: App {
Window("Sign In", id: Windows.login.rawValue) {
LoginForm()
.environmentObject(appDelegate.state)
.showDockIconWhenOpen()
}.handlesExternalEvents(matching: Set()) // Don't handle deep links
.windowResizability(.contentSize)
SwiftUI.Settings {
SettingsView<CoderVPNService>()
.environmentObject(appDelegate.vpn)
.environmentObject(appDelegate.state)
.environmentObject(appDelegate.autoUpdater)
.showDockIconWhenOpen()
}
.windowResizability(.contentSize)
Window("Coder File Sync", id: Windows.fileSync.rawValue) {
FileSyncConfig<CoderVPNService, MutagenDaemon>()
.environmentObject(appDelegate.state)
.environmentObject(appDelegate.fileSyncDaemon)
.environmentObject(appDelegate.vpn)
.showDockIconWhenOpen()
}.handlesExternalEvents(matching: Set()) // Don't handle deep links
}
}
Expand Down
23 changes: 23 additions & 0 deletionsCoder-Desktop/Coder-Desktop/Views/Util.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,26 @@
}
}
}

@MainActor
private struct ActivationPolicyModifier: ViewModifier {
func body(content: Content) -> some View {
content
// This lets us show and hide the app from the dock and cmd+tab
// when a window is open.
.onAppear {
NSApp.setActivationPolicy(.regular)
}
.onDisappear {
if NSApp.windows.filter { $0.level != .statusBar && $0.isVisible }.count <= 1 {

Check warning on line 58 in Coder-Desktop/Coder-Desktop/Views/Util.swift

View workflow job for this annotation

GitHub Actions/ test

trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning
NSApp.setActivationPolicy(.accessory)
}
}
}
}

public extension View {
func showDockIconWhenOpen() -> some View {
modifier(ActivationPolicyModifier())
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp