From aa974b2aa7b99ec94f66272a7ddd4bfc62438a2f Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 28 Feb 2018 00:46:16 +0100 Subject: [PATCH] cocoa-cb: make fullscreen resize animation duration configurable --- DOCS/man/options.rst | 12 ++++++++++++ osdep/macosx_application.m | 7 +++++++ video/out/cocoa-cb/window.swift | 13 +++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 2a2ca665c3..8246dd0f49 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -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=`` + 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=`` 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 diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index fe117f7a1c..4bc8eec0eb 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -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 diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift index f720205e5c..c2a6feea9d 100644 --- a/video/out/cocoa-cb/window.swift +++ b/video/out/cocoa-cb/window.swift @@ -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"