summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb
Commit message (Collapse)AuthorAgeFilesLines
* cocoa-cb: generalisation of backend independent partsder richter2020-08-224-1418/+0
| | | | | | | | | | | | | 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: fix unfs window size when toggling out of fullscreender richter2020-07-121-1/+3
| | | | | | | | | | we properly set the unfs window size on live resize end. due to a race condition in the fullscreen events, which is also a live resize, the unfs window size is incorrectly set to a fullscreen size. this happens when the end fs screen event triggers before the end of live resize one. this just adds a second condition to not be un fullscreen when updating the unfs window size.
* cocoa-cb: properly reset window isMoving state on title bar clicksder richter2020-06-061-0/+2
| | | | | | | | | since the title bar catches the mouse up and down events, the underlying events view doesn't reset the isMoving state and no mouse movements are signalled to the core. now we also reset the state in mouse up events on the title bar. Fixes #7807
* cocoa-cb: report actual unfs window size for current window scaleder richter2020-04-251-0/+4
|
* cocoa-cb: remove unnecessary semicolonsder richter2020-02-222-14/+14
|
* cocoa-cb: fix auto-selection of title bar style with older SDKsder richter2020-02-081-0/+4
| | | | | returning a nil value only works when build with a +10.14 SDK otherwise we need to fallback to the old mechanism.
* cocoa-cb: simplify cursor hiding and make it less greedyder richter2020-02-082-2/+5
| | | | | | | | | | | | | | | | | | 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: add pinch to resize window gestureder richter2020-01-262-0/+11
| | | | | | | the event returns a delta ratio so we can just add it to the current window-scale. Adds support for #3214
* cocoa-cb: never set a window size smaller than the set minSizeder richter2020-01-261-0/+5
| | | | this prevents a vanishing window if the size is set too small.
* cocoa-cb: add support for forcing the dedicated GPU for renderingder richter2020-01-261-2/+9
| | | | | | | | this deprecates the old cocoa backend only option and moves it to the general macos ones. add support for the new option in the cocoa-cb layer creation and use the new option in the olde cocoa backend. Fixes #7272
* cocoa-cb: add runtime dpi change and use proper fallback for initial dpider richter2020-01-091-1/+1
| | | | | | | | 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: force redraw when screen or size changesder richter2019-12-241-0/+2
| | | | | | | | | in certain circumstances the video was not redrawn even when the size or the backing scale factor changed. this could lead to a lower resolution output than intended. now it redraws the video when screen properties or the window size changes.
* cocoa-cb: implement hidpi scale reportingder richter2019-12-241-0/+1
|
* cocoa-cb: report fullscreen state for legacy fullscreender richter2019-12-171-0/+2
| | | | | report the fs screen state when the fullscreen is externally triggered for the legacy fullscreen.
* command, vo: remove old option change notification mechanismswm42019-12-171-2/+0
| | | | | | | These all have been replaced recently. There was a leftover in window.swift. It couldn't have done anything useful in the current state of the code, so drop these lines.
* mac: replace old event tap for media key support with MediaPlayerder richter2019-12-152-7/+7
| | | | | | | | | | | | | | | the old event tap has several problems, like no proper priority support or having to set accessibility permissions for mpv or the terminal. it is now replaced by the new MediaPlayer which has proper priority support and isn't as greedy as previously. this only includes Media Key support and not any of the other features included in the MediaPlayer framework, like proper Now Playing data (only set dummy data for now). this is only available on macOS 10.12.2 and higher. also removes some unnecessary redefines. Fixes #6389
* cocoa-cb: update and add more options to use new options handlingder richter2019-12-151-0/+21
| | | | | 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-4/+4
| | | | | | | | 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-064-78/+64
| | | | | | | | | | 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: add support for 10bit opengl renderingder richter2019-09-261-19/+38
| | | | | | | this will request a 16bit half-float framebuffer instead if a 8bit integer framebuffer. Fixes #3613
* cocoa-cb: fix title bar button state on start upder richter2019-09-231-0/+2
| | | | | on start up it was possible to click the hidden buttons. hide the buttons ons tart up to make the state consistent with the visible state.
* cocoa-cb: remove an unused variableder richter2019-09-021-1/+0
|
* cocoa-cb: migrate to swift 5 with swift 4 fallbackder richter2019-07-213-49/+40
| | | | | | | | | | | | | 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 optional cases on macOS 10.12der richter2019-07-211-4/+4
|
* cocoa-cb: conditional compilation for Dark Mode and Material featuresder richter2019-07-211-1/+4
| | | | Fixes #6621
* cocoa-cb: remove all force unwrappings of optionalsder richter2019-04-254-199/+238
| | | | | | 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/+16
|
* cocoa-cb: refactor title bar stylingder richter2019-04-021-47/+102
| | | | | | | | | | | | | 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: add support for mac 10.14 Dark mode and run time switchingAkemi2019-04-021-5/+10
| | | | | | setting the appearance of the window to nil will always use the system setting and changes on run time switches too. this is only the case for macOS 10.14.
* cocoa-cb: move all title bar related functionality in its own fileder richter2019-04-023-155/+174
| | | | | | | | | 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: simplify CGL pixel format creationAkemi2019-04-021-57/+75
| | | | | | | | | | | | | | | i found the old pixel format creation a bit too messy. pixel format attribute arrays and look ups were all over the place, the actual logic what kind of format was created was inscrutable, the software pixel format was hardcoded and no probing was done. i split the attributes into mandatory and optional ones, one mandatory for a hardware and software pixel format each, and moved those to the top of the class. that way new attributes can be easily added to either the mandatory or optional attributes and they don't mess up the actual pixel creation logic any more. furthermore both hardware and software pixel formats are being probed the same way now. to minimise code duplications the probing was moved into its own function.
* cocoa-cb: add support for dragging certain strings onto the windowAkemi2019-04-021-2/+31
| | | | | | | | | | | | | | | only the dragged types NSFilenamesPboardType and NSURLPboardType were supported to be dropped on the window, which was inconsistent with the dragged types the dock icon supports. the dock icon additional supports strings that represents an URL or a path. the system takes care of validating the strings properly in the case of the dock icon, but in the case of dropping on the window it needs to be done manually. support for strings is added by also allowing the NSPasteboardTypeString type and manually validating the strings. strings are split by new lines and trimmed, to also support a list of URLs and paths. every new element is checked if being an URL or path and only then being added to the playlist.
* cocoa-cb: synchronise the flush with the renderAkemi2019-04-021-3/+2
| | | | | | | this could lead to a crash on deinit when flush was called while the opengl state was cleaned up. Fixes #6323
* cocoa-cb: fix a Cocoa window position on init bugAkemi2019-04-021-0/+13
| | | | | | | | | | | | on init an NSWindow can't be placed on a none Main screen NSScreen outside the Main screen's frame bounds. To fix this we just check if the target screen is different from the main screen and if that is the case we check the actual position with the expect one. if they are different we try to reposition the window to the wanted position. Fixes #6453
* cocoa-cb: notify vo when window is minimisedAkemi2019-04-021-0/+8
|
* cocoa-cb: remove empty elements from dropped URLsAkemi2019-02-101-1/+2
| | | | Fixes #6241
* cocoa-cb: fix side by side Split View againAkemi2019-01-231-3/+2
| | | | | | | | | | some safety mechanism for the async fs animation aren't needed anymore, due to possible improved logic and slightly different behaviour on new macOS versions. that safety fallback prevented the Split View because it always returned a rectangle of the whole screen, instead of just part/half of it. Fixes #6443
* cocoa-cb: add logging for CGL pixel format attributesAkemi2018-11-131-0/+19
| | | | | | | | depending on the capabilities of the system and testing of various attributes the resulting CGL pixel format can change. due to that probing it can be helpful to know which pixel format is used to create the CGL context. added some verbose logging that outputs final pixel format.
* cocoa-cb: use libmpv's advanced rendering control and timingAkemi2018-11-132-27/+19
| | | | | | | | 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: fix double clicking the title barAkemi2018-10-211-1/+29
| | | | | | | | | since we draw our own title bar we lose the standard functionality of the system provided title bar. because of that we have to reimplement the functionality of double clicking the title bar. depending on the system preferences we want to minimize, zoom or do nothing. Fixes #6223
* cocoa-cb: fix side by side Split ViewAkemi2018-10-021-1/+1
| | | | | | | | | | when entering a Split View a windowDidEnterFullScreen event happens without a previous toggleFullScreen call. in that case it tries to stop an animation that was never initiated by us and basically breaks the system initiated fullscreen, or in this case the Split View. immediately after entering the fullscreen it tries top stop the animation and resizes the window, which causes the window to exit fullscreen. only try to stop an animation that was initiated by us and is safe to stop.
* cocoa-cb: add Apple Software Renderer supportAkemi2018-09-301-2/+27
| | | | | | by default the pixel format creation falls back to software renderer when everything fails. this is mostly needed for VMs. additionally one can directly request an sw renderer or exclude it entirely.
* cocoa-cb: fix crash when no screen is availableAkemi2018-08-111-1/+1
| | | | | | | | instead of force unwrapping and chaining the optional vars in our containsMouseLocation function, safely unwrap and guard the resulting var. Fixes #6062
* cocoa-cb: fix building with Swift 4.2coverity_scanAkemi2018-06-121-1/+1
| | | | | | | | | 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-123-46/+63
| | | | | | | | | | | 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.
* cocoa-cb: render on a dedicated dispatch queueAkemi2018-03-252-25/+32
| | | | | | | | | | | 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-1/+1
| | | | | | | | 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: fix crash on startup with not initialised title barAkemi2018-03-141-1/+2
| | | | | | | the first mouse events, that try to hide the title bar, could happen before the title bar was actually initialised. that caused our hiding code to access a nil value. check for an available title bar before trying to hide it.
* cocoa-cb: fix crash with forced iGPU on some multi GPU systemsAkemi2018-03-141-3/+5
| | | | | | | | | | | | | there were actually a few small problems. the fatalError() function wasn't supposed to be called there and caused an "Illegal instruction". this was replaced by a print and exit() call. the second problem was that cocoa returns a kCGLBadPixelFormat instead of a kCGLBadAttribute error, which broke our check, immediately exited our loop and no working pixel format was ever created. the third problem was that macOS 10.12 didn't return any errors but also didn't return a pixel format, that also broke our check. now the code checks for both cases. Fixes #5631
* cocoa-cb: don't deactivate mouse events completely with input-cursor=noAkemi2018-03-111-7/+2
| | | | | | | | | | mouse events and the tracking area are needed for (un)hiding the new title bar, which was broken when input-cursor=no was set. no tracking area was ever created and set which completely deactivated any mouse events. the specific mouse event functions were already deactivated proactively and have the needed check. no events are being propagated to the mpv core when input-cursor=no is set, even with an active tracking area.
* cocoa-cb: fix wrong aspect ratio on live resize after reconfig resizeAkemi2018-03-041-1/+1
| | | | | | | on a file change and when the aspect ratio of the window changed, the first live resize state had a wrong aspect ratio because the new aspect ratio was only set after the first resize. just set the new content frame before the resize.
* cocoa-cb: change handling of window aspect ratio changesAkemi2018-03-042-34/+14
| | | | | | | | | | | | 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-042-8/+8
| | | | | a new replacement API was introduced with b037121 and the old one was deprecated. porting cocoa-cb to the new API.
* cocoa-cb: remove debug remnant (stray print)Akemi2018-03-041-1/+0
|
* cocoa-cb: fix building with SDK 10.12 and earlierAkemi2018-03-011-1/+1
| | | | | | | | | the NSWindowButton enum was moved to be a member of NSWindow and renamed to ButtonType in SDK 10.13. apparently that wasn't documented anywhere. not even in the SDK changes Document and the official Documentations makes it look like it was always like this. the old NSWindowButton enum though is still around on SDK 10.13 or at least got a typealias. so we will just use that.
* cocoa-cb: make fullscreen resize animation duration configurableAkemi2018-02-281-2/+11
|
* cocoa-cb: fix stretched gl surface on window aspect ratio changeAkemi2018-02-282-2/+48
| | | | | | | | when resizing async it's possible that the layer, and the underlying gl surface, is stretched on an aspect ratio change. to prevent that we do an atomic resize (resize and draw at the same time). usually max one unique frame should be dropped but it's possible, depending on the performance, that more are dropped.
* cocoa-cb: change border and borderless window stylingAkemi2018-02-282-15/+114
| | | | | | | | | | | 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-10/+18
| | | | | | | | | | | | | | | | | | | 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 wrong drawing size on resizeAkemi