Skip to content
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

player: add --auto-window-resize option #9360

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

Dudemanguy
Copy link
Member

@Dudemanguy Dudemanguy commented Oct 26, 2021

mpv's window resizing logic always automatically resized the window
whenever the video resolution changed (i.e. advancing forward in a
playlist). This simply introduces the option to make this behavior
configurable. Every windowing backend would need to implement this
behavior in their code. This commit implements it for Wayland and X11.

Related issue: #9325

@Dudemanguy
Copy link
Member Author

Sadly, the x11 change is no longer one line because the autofit/geometry stuff also must execute vo_x11_config_vo_window. It should work as intended now though.

@Dudemanguy Dudemanguy force-pushed the auto-window-resize branch 3 times, most recently from 69e9edd to 7bae9fb Compare October 26, 2021 18:58
@Akemi
Copy link
Member

Akemi commented Oct 26, 2021

i am just wondering, wouldn't it make more sense to do this deeper in the core instead of the platform specific code or is there a specific reason why we want ti implemented on every platform separately?

@Dudemanguy
Copy link
Member Author

Dudemanguy commented Oct 26, 2021

I did initially attempt to do this by just messing with player/video.c and/or vo.c, but I didn't think there was a sane/clean way to do it it. Or at least, I couldn't think of one anyway. In player/video.c, mpv will do a check if the vo->params are not equal to the params from the incoming frame and thus trigger a reconfig (vo_reconfig2) in the vo which propagates downwards to every backend. This is the source of mpv's automatic resizing behavior. You can, of course, not do the reconfig and ensure the window won't change its size but that doesn't change the fact that the new frame is of a different size than the previous one. In practice, this means that the picture will be cut off if you go from a smaller resolution to a bigger one (didn't try the reverse actually).

So as far as I can tell, this requires the reconfig call which calls a resize (this is the part that's really needed) and the only way that can be done is by propagating to every backend.

@Dudemanguy
Copy link
Member Author

I took a peek at the windows code and I think the required change is trivial so I went ahead and added it to this.

@occivink
Copy link
Contributor

Another relevant case is when setting video-aspect-override, the window is automatically resized to match the new video ratio and avoid black bars.
With this new option enabled, the window size stays the same as expected.

@Dudemanguy
Copy link
Member Author

P.S. if someone could test if the Windows change actually works correctly, that would be nice. mac was left out since swift makes my head spin.

@dyphire
Copy link
Contributor

dyphire commented Feb 1, 2022

I tested it on windows, and the option of auto-window-resize works correctly.

@Dudemanguy
Copy link
Member Author

Thanks for confirming. I think this is OK to merge (unless there's still some disagreements over the implementation). It's missing mac support, but no one can do that other than @Akemi anyways.

@anonish
Copy link

anonish commented Nov 30, 2022

I have always used

geometry=1920x1080+0+0
no-keepaspect-window
force-window=yes
keep-open=yes
idle=yes

and never had the window auto-resize on me on switching videos (either through playlist skip, playlist end, or dragging a new video into the window), is this going to change anything?

@Dudemanguy
Copy link
Member Author

For your configuration, no. The main thing this does is prevent auto-resizing without having to specify an arbitrary geometry (i.e. it'll just stay at whatever the first value in the playlist happens to be).

@Dudemanguy Dudemanguy force-pushed the auto-window-resize branch 2 times, most recently from b189bc8 to 521c7f6 Compare February 27, 2023 02:11
@Dudemanguy
Copy link
Member Author

Dudemanguy commented Feb 27, 2023

People still ping me about this occasionally and it's a useful feature so I plan to finally merge it soonish in case anyone wants to take another look at it.

mpv's window resizing logic always automatically resized the window
whenever the video resolution changed (i.e. advancing forward in a
playlist). This simply introduces the option to make this behavior
configurable. Every windowing backend would need to implement this
behavior in their code since a reconfigure event must always be a
resize. The params of the frame changed so you either have to resize the
window to the new size of the params or make the params the same size as
the window. This commit implements it for wayland, win32, and x11.
@Dudemanguy Dudemanguy merged commit c993d5c into mpv-player:master Mar 2, 2023
@Dudemanguy Dudemanguy deleted the auto-window-resize branch March 2, 2023 02:55
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.

6 participants