8000 Don't resize on opening media and switching modes by uiryuu · Pull Request #5054 · iina/iina · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't resize on opening media and switching modes #5054

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

uiryuu
Copy link
Member
@uiryuu uiryuu commented Jul 8, 2024

Description:
Thanks to #5029, now initiating rendering doesn't require a forced draw to the main window. Previously, IINA first draw the video in a small window, then resize to the desired window size. This PR change the behavior to show the main window after the geometry is calculated, therefore no resizing animation is required, the window will show directly to the final size.

Specifically, this PR:

  • Removed windowWillOpen() and moved contents to newly added override showWindow(_:)
  • Removed windowDidOpen() and moved contents to the end of windowDidLoad()
    • PlayerWindowController.windowDidOpen() also got removed.
  • Removed code which explicitly shows the main window when opening media and creating the main window
  • Calls showWindow(_:) after the final window geometry is calculated and set as the window frame
  • Show mini player after videoreconfig

windowWillOpen() and windowDidOpen() are not standard NSWindow functions, and they are easy to be confused with other NSWindow lifecycle functions, so I moved them and move the code into override functions.

The current implementation is far from clean, but in order to not refactor too much code, I only made changes to necessary parts. Also I feel the animation for changing modes (music -> normal and reverse) bit clunky and not consistent, but that's not in the scope of this PR.

Demo:
Before:
https://github.com/iina/iina/assets/20237141/241eca90-66b5-47e9-92c1-551316fc1e36

After:
https://github.com/iina/iina/assets/20237141/3ea7629e-38b2-47ba-ba5c-9c36c9707990

Copy link
Contributor
@low-batt low-batt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled PR, built IINA, tested. Looks good to me.

@svobs
Copy link
Contributor
svobs commented Jul 10, 2024

Looks like some much needed refactoring. Although I for one began to enjoy the zoom animation 😂

@uiryuu
Copy link
Member Author
uiryuu commented Jul 14, 2024

Known issues: when opening online resources, the window will still resize after the buffering is done. We need a UI to reflect the buffering process.

@lhc70000
Copy link
Member

Try this:

  • Enable auto switching to music mode (enabled by default)
  • Open a music file, IINA opens in music mode
  • Click the back button to return to normal mode

Expected: The main window appears with the album art.
Actual: No video window shown, the welcome window is shown instead. The player hangs when trying to quit IINA.

@lhc70000
Copy link
Member

@svobs I actually feel nostalgic about the animation. Maybe I'm going to implement a more sleek opening animation and make it an option.

if player.disableWindowAnimation || Preference.bool(for: .disableAnimations) {
if !player.mainWindow.window!.isVisible && !player.isInMiniPlayer {
window.setFrame(rect, display: false, animate: false)
showWindow(nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why put it here in adjustFrameByVideoSize()? This can be called whenever the video's size is changed.

Consider the following case: I open an IINA window and hide it using Cmd+H. Then it automatically continues to the next video (or some plugin/mpv script changed the video/window size), and this line will show the window unexpectedly.

@lhc70000 lhc70000 self-assigned this Jul 17, 2024
uiryuu added 3 commits July 26, 2024 09:37
This commit:
- Removed `windowWillOpen()` and moved contents to newly added `override
  showWindow(_:)`
- Removed `windowDidOpen()` and moved contents to the end of
  `windowDidLoad()`
  - `PlayerWindowController.windowDidOpen()` also got removed.
- Removed code which explicitly shows the main window when opening media
  and creating the main window
- Calls `showWindow(_:)` after the final window geometry is calcuated and
  set as the window frame

Handle entering music mode correctly

+ cleared up the code
@uiryuu uiryuu force-pushed the dont-resize-on-start-2 branch from a1ea146 to 9a05b02 Compare July 26, 2024 00:50
- Changed the method for detecting no album art in mini player
- Renamed `notifyMainWindowVideoSizeChanged()` to
  `notifyWindowVideoSizeChanged()`
- Don't try to update video size on tracklistchange, instead, wait for videoreconfig
@uiryuu uiryuu force-pushed the dont-resize-on-start-2 branch from 9a05b02 to e43510e Compare July 26, 2024 00:50
uiryuu added 2 commits August 8, 2024 15:56
- Merge `adjustFrameByVideoSize` and `updateVideoSize` into
  `handleVideoSizeChange`
- Move `pendingShow` into `PlayerWindowController`
- Set `pendingShow` for both player to true when loading files
@lhc70000 lhc70000 merged commit 58af397 into develop Aug 9, 2024
1 check passed
@lhc70000 lhc70000 deleted the dont-resize-on-start-2 branch August 9, 2024 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0