mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
Honor Lock Controls on macOS player
The macOS controls stack (MacOSPlayerControlsView + MacOSControlBar) never read playerState.isControlsLocked, so locking via the settings sheet had no effect: buttons, the scrubber, the volume slider, and the AppKit keyboard shortcuts all kept working. When locked, dim and disable transport, volume, the progress bar, queue, the more menu, PiP, the pin/floating toggle, and the title-tap details button; ignore playback keyboard shortcuts (space/arrows/mute) while keeping F/Esc for fullscreen. Settings and Close stay enabled so the user can reopen Settings to unlock.
This commit is contained in:
@@ -107,7 +107,8 @@ struct MacOSPlayerControlsView: View {
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(onTitleTap == nil)
|
||||
.disabled(onTitleTap == nil || playerState.isControlsLocked)
|
||||
.opacity(playerState.isControlsLocked ? 0.5 : 1.0)
|
||||
.help(Text("player.controls.info"))
|
||||
}
|
||||
|
||||
@@ -129,6 +130,8 @@ struct MacOSPlayerControlsView: View {
|
||||
.buttonStyle(.plain)
|
||||
.help(Text("player.controls.keepOnTop"))
|
||||
.accessibilityLabel(Text("player.controls.keepOnTop"))
|
||||
.disabled(playerState.isControlsLocked)
|
||||
.opacity(playerState.isControlsLocked ? 0.5 : 1.0)
|
||||
}
|
||||
|
||||
if onClose != nil {
|
||||
@@ -273,6 +276,24 @@ struct MacOSPlayerControlsView: View {
|
||||
// Only handle events when the player window is key (active)
|
||||
guard NSApp.keyWindow != nil else { return event }
|
||||
|
||||
// When controls are locked, ignore playback keys (space/arrows/mute) and
|
||||
// only keep fullscreen (F) and exit-fullscreen (Esc) working.
|
||||
if playerState.isControlsLocked {
|
||||
switch event.keyCode {
|
||||
case 3: // F
|
||||
onToggleFullscreen?()
|
||||
return nil
|
||||
case 53: // Escape
|
||||
if isFullscreen {
|
||||
onToggleFullscreen?()
|
||||
return nil
|
||||
}
|
||||
return event
|
||||
default:
|
||||
return event // Pass through space/arrows/M while locked
|
||||
}
|
||||
}
|
||||
|
||||
// Handle keyboard shortcuts
|
||||
switch event.keyCode {
|
||||
case 49: // Space
|
||||
|
||||
Reference in New Issue
Block a user