cocoa-cb: make fullscreen resize animation duration configurable

This commit is contained in:
Akemi 2018-02-28 00:46:16 +01:00 committed by Kevin Mitchell
parent 38d614d8d6
commit aa974b2aa7
3 changed files with 30 additions and 2 deletions

View File

@ -4864,6 +4864,18 @@ The following video options are currently all specific to ``--vo=gpu`` and
:auto: Detects the system settings and sets the title bar styling
appropriately, either ultradark or mediumlight.
``--macos-fs-animation-duration=<default|0-1000>``
Sets the fullscreen resize animation duration in ms (default: default).
The default value is slightly less than the system's animation duration
(500ms) to prevent some problems when the end of an async animation happens
at the same time as the end of the system wide fullscreen animation. Setting
anything higher than 500ms will only prematurely cancel the resize animation
after the system wide animation ended. The upper limit is still set at
1000ms since it's possible that Apple or the user changes the system
defaults. Anything higher than 1000ms though seems too long and shouldn't be
set anyway.
OS X and cocoa-cb only
``--android-surface-size=<WxH>``
Set dimensions of the rendering surface used by the Android gpu context.
Needs to be set by the embedding application if the dimensions change during

View File

@ -42,6 +42,7 @@
struct macos_opts {
int macos_title_bar_style;
int macos_fs_animation_duration;
};
#define OPT_BASE_STRUCT struct macos_opts
@ -50,9 +51,15 @@ const struct m_sub_options macos_conf = {
OPT_CHOICE("macos-title-bar-style", macos_title_bar_style, 0,
({"dark", 0}, {"ultradark", 1}, {"light", 2},
{"mediumlight", 3}, {"auto", 4})),
OPT_CHOICE_OR_INT("macos-fs-animation-duration",
macos_fs_animation_duration, 0, 0, 1000,
({"default", -1})),
{0}
},
.size = sizeof(struct macos_opts),
.defaults = &(const struct macos_opts){
.macos_fs_animation_duration = -1,
},
};
// Whether the NSApplication singleton was created. If this is false, we are

View File

@ -252,7 +252,7 @@ class Window: NSWindow, NSWindowDelegate {
hideTitleBar()
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = duration - 0.05
context.duration = getFsAnimationDuration(duration - 0.05)
window.animator().setFrame(intermediateFrame, display: true)
}, completionHandler: { })
}
@ -264,7 +264,7 @@ class Window: NSWindow, NSWindowDelegate {
setFrame(intermediateFrame, display: true)
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = duration - 0.05
context.duration = getFsAnimationDuration(duration - 0.05)
window.animator().setFrame(newFrame, display: true)
}, completionHandler: { })
}
@ -328,6 +328,15 @@ class Window: NSWindow, NSWindowDelegate {
cocoaCB.layer.neededFlips += 1
}
func getFsAnimationDuration(_ def: Double) -> Double{
let duration = mpv.getStringProperty("macos-fs-animation-duration") ?? "default"
if duration == "default" {
return def
} else {
return Double(duration)!/1000
}
}
func setOnTop(_ state: Bool) {
if state {
let ontopLevel = mpv.getStringProperty("ontop-level") ?? "window"