summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/window.swift
Commit message (Collapse)AuthorAgeFilesLines
* cocoa-cb: generalisation of backend independent partsder richter2020-08-221-543/+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: report actual unfs window size for current window scaleder richter2020-04-251-0/+4
|
* cocoa-cb: remove unnecessary semicolonsder richter2020-02-221-1/+1
|
* cocoa-cb: simplify cursor hiding and make it less greedyder richter2020-02-081-2/+3
| | | | | | | | | | | | | | | | | | 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-261-0/+6
| | | | | | | 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 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-151-1/+1
| | | | | | | | | | | | | | | 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-061-30/+18
| | | | | | | | | | 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-14/+14
| | | | | | | | | | | | | 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: remove all force unwrappings of optionalsder richter2019-04-251-57/+71
| | | | | | 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: move all title bar related functionality in its own fileder richter2019-04-021-150/+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: 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: 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: use libmpv's advanced rendering control and timingAkemi2018-11-131-0/+6
| | | | | | | | 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: remove pre-allocation of window, view and layerAkemi2018-06-121-26/+48
| | | | | | | | | | | 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-251-3/+3
| | | | | | | | | | | 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 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-041-19/+6
| | | | | | | | | | | | 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: 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-281-0/+15
| | | | | | | | 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-281-12/+106
| | | | | | | | | | | 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: initial implementation via opengl-cb APIAkemi2018-02-121-0/+456
this is meant to replace the old and not properly working vo_gpu/opengl cocoa backend in the future. the problems are various shortcomings of Apple's opengl implementation and buggy behaviour in certain circumstances that couldn't be properly worked around. there are also certain regressions on newer macOS versions from 10.11 onwards. - awful opengl performance with a none layer backed context - huge amount of dropped frames with an early context flush - flickering of system elements like the dock or volume indicator - double buffering not properly working with a none layer backed context - bad performance in fullscreen because of system optimisations all the problems were caused by using a normal opengl context, that seems somewhat abandoned by apple, and are fixed by using a layer backed opengl context instead. problems that couldn't be fixed could be properly worked around. this has all features our old backend has sans the wid embedding, the possibility to disable the automatic GPU switching and taking screenshots of the window content. the first was deemed unnecessary by me for now, since i just use the libmpv API that others can use anyway. second is technically not possible atm because we have to pre-allocate our opengl context at a time the config isn't read yet, so we can't get the needed property. third one is a bit tricky because of deadlocking and it needed to be in sync, hopefully i can work around that in the future. this also has at least one additional feature or eye-candy. a properly working fullscreen animation with the native fs. also since this is a direct port of the old backend of the parts that could be used, though with adaptions and improvements, this looks a lot cleaner and easier to understand. some credit goes to @pigoz for the initial swift build support which i could improve upon. Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739, #2392, #2217