Skip to content
Permalink
Browse files

Never call displayOSD directly

Always call PlayerCore.sendOSD since it checks whether or not
should show OSD according to the preference

Ref: #2462
  • Loading branch information...
alejx committed May 21, 2019
1 parent ab8a369 commit 985fc877433473ab1199a1876e44280528483a91
@@ -27,25 +27,25 @@ class CropSettingsViewController: CropBoxViewController {
}

@IBAction func doneBtnAction(_ sender: AnyObject) {
let playerCore = mainWindow.player
let player = mainWindow.player

mainWindow.exitInteractiveMode {
if self.cropx == 0 && self.cropy == 0 &&
self.cropw == playerCore.info.videoWidth &&
self.croph == playerCore.info.videoHeight {
self.cropw == player.info.videoWidth &&
self.croph == player.info.videoHeight {
// if no crop, remove the crop filter
if let vf = playerCore.info.cropFilter {
let _ = playerCore.removeVideoFilter(vf)
playerCore.info.unsureCrop = "None"
if let vf = player.info.cropFilter {
let _ = player.removeVideoFilter(vf)
player.info.unsureCrop = "None"
return
}
}
// else, set the filter
let filter = MPVFilter.crop(w: self.cropw, h: self.croph, x: self.cropx, y: self.cropy)
playerCore.setCrop(fromFilter: filter)
player.setCrop(fromFilter: filter)
// custom crop has no corresponding menu entry
playerCore.info.unsureCrop = ""
self.mainWindow.displayOSD(.crop(self.readableCropString))
player.info.unsureCrop = ""
player.sendOSD(.crop(self.readableCropString))
}
}

@@ -912,7 +912,7 @@ class MainWindowController: NSWindowController, NSWindowDelegate {
if returnValue == 0 {
// screenshot
if keyBinding.action[0] == MPVCommand.screenshot.rawValue {
displayOSD(.screenshot)
player.sendOSD(.screenshot)
}
} else {
Logger.log("Return value \(returnValue) when executing key command \(keyBinding.rawAction)", level: .error)
@@ -1735,6 +1735,7 @@ class MainWindowController: NSWindowController, NSWindowDelegate {

// MARK: - UI: OSD
// Do not call displayOSD directly, call PlayerCore.sendOSD instead.
func displayOSD(_ message: OSDMessage, autoHide: Bool = true, accessoryView: NSView? = nil) {
guard player.displayOSD && !isShowingPersistentOSD else { return }

@@ -2534,9 +2535,9 @@ class MainWindowController: NSWindowController, NSWindowDelegate {
@IBAction func muteButtonAction(_ sender: NSButton) {
player.toggleMute(nil)
if player.info.isMuted {
displayOSD(.mute)
player.sendOSD(.mute)
} else {
displayOSD(.unMute)
player.sendOSD(.unMute)
}
}

@@ -376,7 +376,7 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi
@IBAction func clearPlaylistBtnAction(_ sender: AnyObject) {
player.clearPlaylist()
reloadData(playlist: true, chapters: false)
mainWindow.displayOSD(.clearPlaylist)
player.sendOSD(.clearPlaylist)
}

@IBAction func playlistBtnAction(_ sender: AnyObject) {
@@ -444,7 +444,7 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi
let chapter = player.info.chapters[index]
tv.deselectAll(self)
tv.reloadData()
mainWindow.displayOSD(.chapter(chapter.title))
player.sendOSD(.chapter(chapter.title))
}

func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
@@ -391,27 +391,27 @@ class QuickSettingViewController: NSViewController, NSTableViewDataSource, NSTab
@IBAction func aspectChangedAction(_ sender: NSSegmentedControl) {
let aspect = AppData.aspectsInPanel[sender.selectedSegment]
player.setVideoAspect(aspect)
mainWindow.displayOSD(.aspect(aspect))
player.sendOSD(.aspect(aspect))
}

@IBAction func cropChangedAction(_ sender: NSSegmentedControl) {
let cropStr = AppData.cropsInPanel[sender.selectedSegment]
player.setCrop(fromString: cropStr)
mainWindow.displayOSD(.crop(cropStr))
player.sendOSD(.crop(cropStr))
}

@IBAction func rotationChangedAction(_ sender: NSSegmentedControl) {
let value = AppData.rotations[sender.selectedSegment]
player.setVideoRotate(value)
mainWindow.displayOSD(.rotate(value))
player.sendOSD(.rotate(value))
}

@IBAction func customAspectEditFinishedAction(_ sender: AnyObject?) {
let value = customAspectTextField.stringValue
if value != "" {
aspectSegment.setSelected(false, forSegment: aspectSegment.selectedSegment)
player.setVideoAspect(value)
mainWindow.displayOSD(.aspect(value))
player.sendOSD(.aspect(value))
}
}

0 comments on commit 985fc87

Please sign in to comment.
You can’t perform that action at this time.