fix: use a nonactivating compact panel across fullscreen spaces
This commit is contained in:
@@ -93,7 +93,8 @@ extension PlayerModel {
|
||||
}
|
||||
|
||||
private func handleKeyEvent(_ event: NSEvent, in window: NSWindow, chord: KeyChord) -> Bool {
|
||||
guard event.window === window, NSApp.modalWindow == nil, window.attachedSheet == nil else { return false }
|
||||
guard self.window === window, event.window === window,
|
||||
NSApp.modalWindow == nil, window.attachedSheet == nil else { return false }
|
||||
if chord.modifiers.contains(.command), keyBindings.shortcuts(for: .openStream).contains(chord) {
|
||||
return perform(.openStream)
|
||||
}
|
||||
@@ -127,7 +128,7 @@ extension PlayerModel {
|
||||
perform(action)
|
||||
return
|
||||
}
|
||||
if let window = event.window ?? NSApp.keyWindow,
|
||||
if let window = window ?? event.window ?? NSApp.keyWindow,
|
||||
!handleKeyEvent(event, in: window, chord: chord),
|
||||
let responder = window.firstResponder as? NSView {
|
||||
if !responder.performKeyEquivalent(with: event) { responder.keyDown(with: event) }
|
||||
@@ -245,12 +246,12 @@ struct PlayerSponsorBlockMenu: View {
|
||||
|
||||
@MainActor
|
||||
struct PlayerCommands: Commands {
|
||||
@ObservedObject var model: PlayerModel
|
||||
@FocusedObject private var focusedModel: PlayerModel?
|
||||
|
||||
var body: some Commands {
|
||||
// The player has one scene; app-level Open/Quit still work before it becomes focused.
|
||||
let model = focusedModel ?? PlayerModel.shared
|
||||
let hasFocusedScene = focusedModel != nil
|
||||
// Nonactivating compact panels need not provide SwiftUI's scene focus.
|
||||
let hasFocusedScene = focusedModel != nil || model.window?.isKeyWindow == true
|
||||
let playback = model.playbackAction
|
||||
let mute = model.muteAction
|
||||
let fullscreen = model.fullscreenAction
|
||||
@@ -280,8 +281,8 @@ struct PlayerCommands: Commands {
|
||||
.disabled(!hasFocusedScene || !model.canPerform(.closeFile))
|
||||
}
|
||||
CommandGroup(replacing: .saveItem) {
|
||||
Button("Close Window") { NSApp.keyWindow?.performClose(nil) }
|
||||
.disabled(focusedModel == nil)
|
||||
Button("Close Window") { model.window?.performClose(nil) }
|
||||
.disabled(!hasFocusedScene)
|
||||
}
|
||||
CommandMenu("Playback") {
|
||||
CastDeviceMenu(model: model, icon: false)
|
||||
|
||||
Reference in New Issue
Block a user