-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix black window after exiting PiP, #4268 This commit will: - Add a VideoPIPViewController class that extends PIPViewController - This class will force drawing when entering and exiting PiP - Change MainWindowController to use VideoPIPViewController for the PiP controller - Remove the pendingRedrawsAfterEnteringPIP property from VideoView - Remove the layout method from VideoView - Remove code that set pendingRedrawsAfterEnteringPIP from the MainWindowController.enterPIP method Updated to address review comments and change VideoPIPViewController, adding a private forceDraw method that only forces drawing when required.
- Loading branch information
Showing
4 changed files
with
48 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// VideoPIPViewController.swift | ||
// iina | ||
// | ||
// Created by low-batt on 3/29/23. | ||
// Copyright © 2023 lhc. All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
|
||
class VideoPIPViewController: PIPViewController { | ||
|
||
/// Force a draw, if needed. | ||
/// | ||
/// If the image is changing there is no need to force a draw. However if playback is paused, or if playback is in progress but the video | ||
/// track is an album art still image then drawing is required. | ||
private func forceDraw() { | ||
guard let controller = delegate as? MainWindowController, controller.player.info.isPaused | ||
|| controller.player.info.currentTrack(.video)?.isAlbumart ?? false else { return } | ||
controller.videoView.videoLayer.draw(forced: true) | ||
} | ||
|
||
/// Force a draw after entering PiP. | ||
/// | ||
/// If playback is paused then after entering PiP mode the PiP window will sometimes be white. Force a draw to ensure this does not | ||
/// happen and a frame is displayed. See PR #3973 for details. | ||
/// | ||
/// Any changes in this area must be tested on multiple macOS versions. Under 10.15, `presentAsPictureInPicture` behaves | ||
/// asynchronously. | ||
override func viewDidLayout() { | ||
super.viewDidLayout() | ||
forceDraw() | ||
} | ||
|
||
/// Force a draw after exiting PiP. | ||
/// | ||
/// If playback is paused then after exiting PiP mode the main window will sometimes be black. Force a draw to ensure this does not | ||
/// happen and a frame is displayed. See issue #4268 and PR #4286 for details. | ||
override func viewDidDisappear() { | ||
super.viewDidDisappear() | ||
forceDraw() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters