summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_cb_common.swift
Commit message (Collapse)AuthorAgeFilesLines
* mac/log: rename log functions and cleanup classder richter2024-03-291-4/+4
|
* mac: use LogHelper directly instead of mp_logder richter2024-03-291-3/+3
|
* mac: rename mpvHandle to mpvder richter2024-03-291-5/+4
|
* mac: remove now unnecessary objective-c forwardingder richter2024-03-291-1/+1
|
* cocoa-cb: use EventHelper for event handlingder richter2024-03-241-8/+4
|
* cocoa-cb: use a separate mpv_handle for cocoa-cb to simplify shutdownder richter2024-03-241-5/+4
|
* mac: optimise and shorten some codeder richter2024-03-211-4/+1
|
* mac/option: rename option structs to properly represent their contentder richter2024-03-211-3/+3
| | | | also optimise option cache setup.
* mac/option: make option helper none optionalder richter2024-03-211-7/+6
| | | | gets rid of some unwrapping boilerplate and nil coalescing operators.
* mac/option: make option helper vo struct independentder richter2024-03-211-2/+3
|
* mac/option: remove unused and obsolete variablesder richter2024-03-211-1/+1
|
* mac/option: move option functionality from mpv helper to option helperder richter2024-03-211-7/+7
| | | | delete now empty mpv helper
* mac/helper: move input ctx related functionality into new input helperder richter2024-03-141-0/+1
| | | | also make functions thread safe.
* options: remove --focus-on-open and add --focus-onder richter2024-03-101-0/+3
| | | | | | | | | replaces the old focus-on-open option with a more generic focus-on options that can be extended. adjust the only platform that uses that option. Fixes #8337
* cocoa-cb: lock CGLContext on uninit and manual redrawder richter2024-02-181-0/+2
| | | | | | | | | | | | this fixes a crash on quit, when a CATransaction from a system owned thread/event is happening at the same time. locking the context synchronises these access and prevents the race condition. the draw operation induced by any display call from the CAOpenGLLayer doesn't need that lock, since the display function already does lock that current context. Fixes #11681
* mac: add support for --auto-window-resize optionder richter2023-12-231-1/+1
| | | | Fixes #9325
* mac: remove runtime checks and compatibility for macOS older than 10.15der richter2023-11-091-3/+1
| | | | | we stopped supporting macOS older than 10.15 and hence can remove all the unnecessary runtime checks and compatibility layers.
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-211-1/+1
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* mac: avoid unnecessary unsafe conversions; fixes crash in debug buildsrcombs2022-09-141-10/+2
| | | | | | | | | | | | | | | Previously, running a debug build of mpv would crash with this output when preinit() at vo_libmpv.c:732 calls control(vo, VOCTRL_PREINIT, NULL): Swift/Optional.swift:247: Fatal error: unsafelyUnwrapped of nil optional This comes from this line of code: var data = UnsafeMutableRawPointer.init(bitPattern: 0).unsafelyUnwrapped Unsafely unwrapping a UnsafeMutableRawPointer.init has always been UB, but the Swift runtime began asserting on it in debug builds a couple macOS versions ago.
* mac: fix traditional fullscreen on macOS 11der richter2021-02-271-2/+2
| | | | | | | | | | | the fullscreen style mask is not supported on macOS 11 anymore outside of the native fullscreen animation. this can lead to a none working fs or in the worst case a crash. to fix this we will simulate a fullscreen window with a borderless window with the size of the whole screen, though only on macOS 11. Fixes #8490
* mac: support screen-name and fs-screen-name optsder richter2020-12-061-2/+1
| | | | | | | the screen-name and fs-screen-name option allow for specifying screens based on their name. this is the name of the NSScreen and also reported by the VOCTRL_GET_DISPLAY_NAMES event. the old screen and fs-screen options by id, respectively, are preferred over these new ones.
* mac: add an option to prevent focusing of the window on opender richter2020-09-251-1/+2
| | | | | | | | | on macOS 10.15 setting the activation policy behaves quite weirdly. the call changes the current active App to a nameless process, which probably also the reason that prevents the not focusing to work. a workaround for that, is to refocus the previous active app. Fixes #7725
* cocoa-cb: force layer update on resizeder richter2020-08-221-1/+1
| | | | | | | | this fixes some race condition where the content of the layer wasn't updated because the size didn't changed and the layer was already marked as updated. just force an update on reconfig. Fixes #7989
* mac: use config cache und wakeup for mac option runtime changesder richter2020-08-221-33/+0
| | | | | | | | remove the libmpv observer for the macOS specific options and use a config cache + change callback for runtime changes. this is also a preparation for new backends and generalises even more, since libmpv functions can't and shouldn't be used in usual vo backends. for feature parity the config cache is used.
* cocoa-cb: generalisation of backend independent partsder richter2020-08-221-444/+77
| | | | | | | | | | | | | move all backend independent code parts in their own folder and files, to simplify adding new backends. the goal is to only extend one class and add the backend dependent parts there. usually only the (un)init, config and related parts need to be implemented per backend. furthermore all needed windowing and related events are propagated and can be overwritten. the other backend dependent part is usually the surface for rendering, for example the opengl oder metal layer. in the best case a new backend can be added with only a few hundred lines.
* cocoa-cb: report actual unfs window size for current window scaleder richter2020-04-251-0/+11
|
* cocoa-cb: support maximize/minimize on startupder richter2020-03-141-1/+9
| | | | | | | Allow the --window-maximized and --window-minimized flags to actually work when the player is started. since macOS doesn't like using both at the same time the minimized state takes precedence over the maximized state.
* cocoa-cb: fix crash with some japanese charactersder richter2020-02-221-1/+2
| | | | | | | | | | | | the actual character that made mpv crash is IDEOGRAPHIC COMMA (U+3001, UTF-8: E3 80 81, 、) and that only in some specific circumstances that could be reliably reproduced on my end. using an NSString instead of the Swift String actually fixes that issues even though they should technically do the exact same thing. i tested all the other String initialisers, but they all had had the same issue. this is kinda only a workaround till i can find a different way of handling it.
* cocoa-cb: remove unnecessary semicolonsder richter2020-02-221-2/+2
|
* cocoa-cb: simplify cursor hiding and make it less greedyder richter2020-02-081-10/+2
| | | | | | | | | | | | | | | | | | for reasons unknown to me the NSCursor (un)hide functions can be completely unreliable and the cursor can have an unknown state. this only happens on some system and wasn't able to reproduce this. it's probably some dumb race condition that might be possible to work around, though because of the lack of reproducibility on my end it's hard to test. i decided to rework the cursor hiding code yet again and make it a lot less greedy. the cursor will now always unhide when moved and there will never be a situation again the cursor can't be unhidden again. on the other hand there might be edge cases now where the cursor won't hide immediately and you have to move it slightly to make it disappear again. this should be an acceptable tradeoff. Fixes #6886
* cocoa-cb: fix race condition on quitder richter2020-01-261-0/+1
| | | | | | it was possible for mouse events to be triggered when the core was already being shut down. to prevent this properly close and remove the window and additional remove the reference to MPVHelper object.
* cocoa-cb: don't set App icon when called from bundleder richter2020-01-261-1/+3
| | | | | | | | | due to the bundle config the icon is set automatically via the bundle system mechanisms. this also makes it possible to set the icon to a custom one with the standard macOS copy paste method via the file info dialogue. Fixes #6874
* cocoa-cb: don't active window when minimized or hidden on file changeder richter2020-01-091-1/+6
| | | | Fixes #7195
* cocoa-cb: add runtime dpi change and use proper fallback for initial dpider richter2020-01-091-3/+6
| | | | | | | | at the time of the initial dpi query the window is not instantiated yet. we use a proper fallback in that case, eg the target configured screen or the main screen if none is set. also change some weird oversight and a small optimisation.
* cocoa-cb: implement hidpi scale reportingder richter2019-12-241-0/+6
|
* cocoa-cb: update and add more options to use new options handlingder richter2019-12-151-10/+20
| | | | | this updates and add the maximized, minimized, keepaspect and ontop options to use the new options handling
* cocoa-cb: use m_config_cache and new VOCTRL for option handlingder richter2019-12-151-33/+34
| | | | | | | | this removes the direct access of the mp_vo_opts stuct via the vo struct and replaces it with the m_config_cache usage. this updates the fullscreen and window-minimized property via m_config_cache_write_opt instead of the old mechanism via VOCTRL and event flagging. also use the new VOCTRL_VO_OPTS_CHANGED event for fullscreen and border changes.
* cocoa-cb: remove get_property_* usages and split up mpv helperder richter2019-10-061-55/+59
| | | | | | | | | | all the get_property_* usages were removed because in some circumstances they can lead to deadlocks. they were replaced by accessing the vo and mp_vo_opts structs directly, like on other vos. additionally the mpv helper was split into a mpv and libmpv helper, to differentiate between private and public APIs and for future changes like a macOS vulkan context for vo=gpu.
* cocoa-cb: migrate to swift 5 with swift 4 fallbackder richter2019-07-211-20/+20
| | | | | | | | | | | | | this migrates our current swift code to version 5 and 4. building is support from 10.12.6 and xcode 9.1 onwards. dynamic linking is the new default, since Apple removed static libs from their new toolchains and it's the recommended way. additionally the found macOS SDK version is printed since it's an important information for finding possible errors now. Fixes #6470
* cocoa-cb: fix quit in fs with none native fsder richter2019-05-111-1/+2
| | | | | | | | | | since the none native fs is a special legacy case it needs a special quit routine. it indefinitely waited for an exit fs screen event to shutdown properly, though that event only fires for the native fs. now we check if we really are using a native fullscreen and if not shutdown immediately. Fixes #6704
* cocoa-cb: remove all force unwrappings of optionalsder richter2019-04-251-110/+173
| | | | | | the force unwrapping of optionals caused many unpredictable segfaults instead of gracefully exiting or falling back. besides that, it is bad practice and the code is a lot more stable now.
* cocoa-cb: add support for custom colored title barder richter2019-04-021-0/+4
|
* cocoa-cb: refactor title bar stylingder richter2019-04-021-2/+6
| | | | | | | | | | | | | half of the materials we used were deprecated with macOS 10.14, broken and not supported by run time changes of the macOS theme. furthermore our styling names were completely inconsistent with the actually look since macOS 10.14, eg ultradark got a lot brighter and couldn't be considered ultradark anymore. i decided to drop the old option --macos-title-bar-style and rework the whole mechanism to allow more freedom. now materials and appearance can be set separately. even if apple changes the look or semantics in the future the new options can be easily adapted.
* cocoa-cb: move all title bar related functionality in its own fileder richter2019-04-021-1/+4
| | | | | | | | | quite a lot of the title bar functionality and logic was within our window. since we recently added a custom title bar class to our window i decided to move all that functionality into that class and in its own file. this is also a preparation for the next commits.
* cocoa-cb: remove an unused variableAkemi2019-04-021-1/+0
|
* cocoa-cb: fix Space switching when quitting fsAkemi2019-04-021-4/+6
| | | | | | | when quitting mpv in fullscreen the System always switchs to Space 1 regardless of which Space mpv was on previous to switching to fs. to fix this we close the window before quitting fs. that way the System switches back the the Space mpv was previous on before fs.
* cocoa-cb: fix crash when querying window stateAkemi2019-04-021-1/+2
| | | | Fixes #6489
* cocoa-cb: wakeup vo when new events are availableAkemi2019-04-021-0/+2
| | | | | | | new events were added but not fetched by the vo, because we didn't signal the vo that new events were available. actually wakeup the vo when new events are available.
* cocoa-cb: add support for VOCTRL_GET_DISPLAY_NAMESAkemi2019-02-101-0/+14
|
* cocoa-cb: use Swift Extensions for convenienceAkemi2019-02-101-7/+4
| | | | preparations for the following commit.
* cocoa-cb: use libmpv's advanced rendering control and timingAkemi2018-11-131-4/+0
| | | | | | | | this adds support for GPU rendered screenshots, DR (theoretically) and possible other advanced functions in the future that need to be executed from the rendering thread. additionally frames that would be off screen or not be displayed when on screen are being dropped now.
* cocoa-cb: move macOS option retrieval to the earliest point possibleAkemi2018-09-301-6/+0
| | | | | | | moved the retrieval of the macOS specific options from the backend initialisation to the initialisation of the CocoaCB class, the earliest point possible. this way macOS specific options can be used for the opengl context creation for example.
* cocoa-cb: fix crash on macOS 10.10Akemi2018-08-111-1/+3
| | | | | | the colorspace of the layer is only available on 10.11 and upwards. Fixes #6041
* cocoa-cb: fix building with Swift 4.2coverity_scanAkemi2018-06-121-6/+6
| | | | | | | | | init is a reserved keyword and Swift 4.2 got a bit stricter about using it. this could be fixed by adding apostrophes around init but makes the code uglier. hence i just renamed init to initialized and for consistency uninit to uninitialized. Fixes #5899
* cocoa-cb: remove pre-allocation of window, view and layerAkemi2018-06-121-53/+51
| | | | | | | | | | | the pre-allocation was needed because the layer allocated a opengl context async itself and we couldn't influence that. so we had to start the core after the context was actually allocated. furthermore a window, view and layer hierarchy had to be created so the layer would create a context. now, instead of relying on the layer to create a context we do this manually and re-use that context later when the layer wants to create one async itself.
* vo_libmpv: pass vo struct to the control callbackAkemi2018-06-121-9/+10
|
* cocoa-cb: render on a dedicated dispatch queueAkemi2018-03-251-3/+4
| | | | | | | | | | | we rendered on the displaylink thread which wasn't the best idea. if rendering took too long or was blocking it also blocked the displaylink callback. when that happened new vsyncs were reported delayed or not at all. consequently the mpv_render_context_report_swap function wasn't called consistently and that could cause bad video playback. so the rendering is moved to a dedicated dispatch queue. furthermore the update callback starts a layer update directly instead of the displaylink callback, making the rendering a bit more consistent.
* cocoa-cb: fix shutdown when fullscreen animation is runningAkemi2018-03-181-6/+16
| | | | | | | | commit 2edf00f changed the MPV_EVENT_SHUTDOWN behaviour slightly, such that it will only be sent once. cocoa-cb relied on it being sent continuously till all mpv_handles are destroyed. now it manually shuts down and destroys the mpv_handle after the animation instead of relying on this removed behaviour.
* cocoa-cb: remove unneeded icc-profile-auto checkAkemi2018-03-111-3/+1
| | | | | | with the new libmpv API it's not necessary to check for this property anymore since libmpv will only use the provided profile when it is needed.
* cocoa-cb: fix a segfault without videoAkemi2018-03-041-10/+7
| | | | | | | we activated the rendering loop a bit too early and it was possible that the first draw function was called before it was actually ready. this was a remnant from the old init routine and should have been changed. start the queue on reconfigure instead of preinit.
* cocoa-cb: change handling of window aspect ratio changesAkemi2018-03-041-0/+2
| | | | | | | | | | | | i tried being smart and handle aspect ratio differences manually via atomic drawing and resizing to aspect fitted frames. there were a few issues with that. like unexpected visibility of certain System GUI elements on entering fullscreen or visually dropped frames due to the atomic drawing. now we rely on system mechanics to keep the proper aspect ratio of our layer, the recommended way. as a side effect it also fixes a segfault. Fixes #5581
* cocoa-cb: use new libmpv API instead of opengl-cbAkemi2018-03-041-6/+6
| | | | | a new replacement API was introduced with b037121 and the old one was deprecated. porting cocoa-cb to the new API.
* cocoa-cb: change border and borderless window stylingAkemi2018-02-281-2/+6
| | | | | | | | | | | the title bar is now within the window bounds instead of outside. same as QuickTime Player. it supports several standard styles, two dark and two light ones. additionally we have properly rounded corners now and the borderless window also has the proper window shadow. Also make the earliest supported macOS version 10.10. Fixes #4789, #3944
* cocoa-cb: fix wrong fullscreen window sizeAkemi2018-02-251-1/+3
| | | | | | | | | | | | | | | | | | | even though the fullscreen animation has a shorter duration than the system wide animation (space sliding effect) there are still cases where it takes longer, eg performance issues (especially on init). furthermore the final size of the animation is usually different than the actual fullscreen size because of spect ratio differences. the actual resize to fullscreen is done automatically by cocoa itself when the actual transition to fullscreen happens (system event). so it could happen that the last animation resize happened after the actual resize to fullscreen leading to a wrongly sized frame after entering fullscreen. to prevent this we cancel the animation when entering fullscreen, we always set the proper frame size when in fullscreen and discard any other frame sizes, and to prevent some performance problems on init we push entering fullscreen to the end of the main queue to execute it when most of the init routines are done. Fixes #5525
* cocoa-cb: fix drawing on macOS 10.11Akemi2018-02-161-3/+19
| | | | | | | | | the CVDisplayLinkSetOutputHandler function introduced with 10.11 is broken on the very same version of the OS, which caused our render loop never to start. fallback to the old display link callback on 10.11. for reference the radar http://www.openradar.me/26640780 Fixes #5527