0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

70 Commits

Author SHA1 Message Date
der richter
5178c5b7d1 mac/window: cleanup unfsContentFrame usage and make it none optional 2024-04-04 19:39:27 +02:00
der richter
fc36e5d71e mac/window: fix unfs window size retrieval
the unfsContentFrame wasn't updated when externally resized leading to
a wrong unfs window size afterwards. update it on windowDidResize event
when not in fs, not animating and not live resizing.
2024-04-04 19:39:27 +02:00
der richter
92cb47338f mac/view: fix cursor visibility when toggling fullscreen
this broke with the recent refactor of the input handling. one of the
edge cases was not considered, where not every mouse down event has a
corresponding mouse up event, eg all double clicks or more only have one
up event after the first down event.

this was handled correctly previously.

Fixes #13777
2024-03-29 14:20:40 +01:00
der richter
ba45f2004f mac: cleanup swift bridge header imports and unify them 2024-03-29 14:20:40 +01:00
der richter
ed0587692f mac/log: rename log functions and cleanup class 2024-03-29 14:20:40 +01:00
der richter
ceaabb7b98 mac: use LogHelper directly instead of mp_log 2024-03-29 14:20:40 +01:00
der richter
1bc680d32a mac/apphub: move menu bar into AppHub 2024-03-29 14:20:40 +01:00
der richter
1acca1d3c4 mac/apphub: move app icon into AppHub
split up AppHub header in obj-c and c parts and make it a bidirectional
bridging.
2024-03-29 14:20:40 +01:00
der richter
12782aad6c mac: optimise and shorten some code 2024-03-21 18:33:15 +01:00
der richter
9e03ab5e1e mac/option: remove now unused computed option variables 2024-03-21 18:33:15 +01:00
der richter
204e3f0df6 mac/option: rename option structs to properly represent their content
also optimise option cache setup.
2024-03-21 18:33:15 +01:00
der richter
f72dfd48d0 mac/libmpv: remove mac option handling in favour of option handler
since the option handler is not optional anymore and available on init
in cocoa-cb we don't need to duplicate this functionality in libmpv
anymore.
2024-03-21 18:33:15 +01:00
der richter
b480daad88 mac/option: make option helper none optional
gets rid of some unwrapping boilerplate and nil coalescing operators.
2024-03-21 18:33:15 +01:00
der richter
6defd49aa1 mac/option: make option helper vo struct independent 2024-03-21 18:33:15 +01:00
der richter
dc5059d027 mac/option: move option functionality from mpv helper to option helper
delete now empty mpv helper
2024-03-21 18:33:15 +01:00
der richter
283d0877c4 mac/type: move c<>swift type bridging into a dedicated type helper 2024-03-21 18:33:15 +01:00
der richter
3afcaeb71a mac/view: optimise drag and drop event handling 2024-03-16 15:29:27 +01:00
der richter
a4eddf742d mac/input: move scroll wheel event handling into input helper 2024-03-16 15:29:27 +01:00
der richter
9a4c673dd7 mac/input: optimise mouse movement enabled check 2024-03-16 15:29:27 +01:00
der richter
db4eac140d mac/input: move mouse event handling into input helper 2024-03-16 15:29:27 +01:00
der richter
3ef3bbf93d mac/event: move key event handling to input helper and optimise it 2024-03-14 23:33:15 +01:00
der richter
18fb71498b mac/events: remove redundant functions and optimise input helper usage
some redundant functions that jump through hoops.
2024-03-14 23:33:15 +01:00
der richter
055e9cd93e mac/helper: move input ctx related functionality into new input helper
also make functions thread safe.
2024-03-14 23:33:15 +01:00
der richter
0ec385bc76 options: remove --focus-on-open and add --focus-on
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
2024-03-10 14:53:07 +01:00
der richter
8a37f0f693 mac/menu: add explicit menu type instead of an inferred type
with the use of an explicit type we can removed inferred type checks
like separators/services menu by name or menus by sub configs.
2024-03-07 01:03:52 +01:00
der richter
fe35baa88e mac/menu: rewrite menu bar in swift 2024-03-07 01:03:52 +01:00
der richter
68c61fd89f mac/vulkan: directly retrieve current render size without caching
the render size cached in ctx->vo->dwidth/dheight can be outdated in
some circumstances at the time the context needs resizing. instead use
the current render size.
2024-03-06 23:37:32 +02:00
der richter
6016423427 mac/vulkan: workaround for MoltenVK problem that causes flicker
MoltenVK itself tries to work around a supposedly Metal problem that
itself causes flicker, black screens or broken rendering. it sets the
drawableSize to 1x1 to forcefully complete the presentation. though if
1x1 resolution frame is presented it causes a visual flicker or rather
a solid coloured frame. it causes even more problems since sometimes it
does not reset the drawableSize to the proper resolution and keeps
rendering everything in 1x1.

work around this workaround by discarding drawableSize that are <=1 in
any direction.

Fixes #13505
2024-03-06 23:37:32 +02:00
der richter
15c48f3dc1 cocoa-cb: render on main queue instead of dedicated queue
initially we drew on a dedicated render queue to circumvent certain
bottlenecks on the main queue, like concurrent events that could lead
to late drawing.

though due to the way cocoa works we need to draw an the main queue
otherwise we get undefined behaviour that could lead to crashes.

Fixes #10276
2024-02-29 16:40:52 +01:00
der richter
7758f6f50e mac/vulkan: set NSView as layer delegate like recommended by MoltenVK 2024-02-29 16:38:10 +01:00
der richter
7a1b387aa9 mac: set layer content scale on init
usually the content scale updates automatically, though on init it is
possible the wrong scale is used for the initial rendering leading to a
wrongly sized surface.

properly set the initial content scale of the layer.
2024-02-27 14:02:08 +01:00
der richter
ac275a823d cocoa-cb: lock CGLContext on uninit and manual redraw
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
2024-02-18 17:25:05 +01:00
der richter
4d7763e6a6 mac: add support for --input-cursor-passthrough option 2023-12-25 13:59:48 +01:00
der richter
fa4ca16f66 mac: update geometry/autofit opts on runtime 2023-12-23 01:15:53 +01:00
der richter
c661435648 mac: add support for drag-and-drop option 2023-12-15 16:59:52 +01:00
der richter
f805b180d0 mac: add support for window-id property
returns the NSWindow
2023-12-15 09:20:10 +01:00
der richter
f551a9da34 mac: report modifier keys on precise scrolling
modifier keys weren't reported when using the trackpad to scroll.

Fixes #11195
2023-12-02 14:59:59 +01:00
der richter
aaff9edf57 mac: fix initial window size and position when already maximized
in the case the window was already set to a maximized size via geometry
or related options (100%x100%) the maximize function would try to
maximize the window again. this reset the position and slightly
increased the size further.

to prevent this only maximize on init if we really want to maximize. in
the reverse case make a noop call by passing the current zoom state.

Fixes #11193
2023-12-02 14:58:01 +01:00
der richter
cc09a28d96 mac: fix a race condition when updating the window title
the title is updated on the main thread (mandatory with cocoa)
asynchronously, because otherwise it would either deadlock when done
synchronously, lead to undefined behaviour or just crashes. the problem
here is that the c string was only copied to an NSString within that
asynchronous call, which potentially would access the pointer when it
is accessed, modified or freed by another thread. it is only safe to
access this pointer as long as the control callback wasn't returned yet.

to fix this we move the copying and creation of the String from the
c string pointer outside of the asynchronous call where the conversion
of an untyped pointer to a typed pointer is done too. since the
resulting String is a copy it's safe to be used in the asynchronous
call.

also reverting ee6ad40, since the problem was most likely an SDK problem
or the very same problem as mentioned here. i retested the crash case
again und can't reproduce it anymore. using a swift String again instead
of an NSSstring.

Fixes #12935
2023-11-25 19:31:26 +01:00
der richter
5aac4c1aee mac: cleanup some unused and unneeded code 2023-11-25 19:04:07 +01:00
der richter
48455a9403 mac: title bar fix 1px none covered video at top
there is 1px border at the top of the window that is not covered by our
title bar and the video below is visible. this broke in some newer macOS
version even so the calculation of size and position of the title bar is
still correct. add 1px the the height of the title bar to cover up the
unwanted border.
2023-11-20 23:16:43 +01:00
der richter
947800ceb8 mac: fix reporting of left wheel and right wheel scrolling
left wheel and right wheel was swapped. this was copied from the old
cocoa backend. a delta <0 is a right scroll, >0 is a left scroll.

Fixes #12899
2023-11-20 23:16:43 +01:00
der richter
a54cc02341 mac: change display name retrieval to localizedName NSScreen property
the old displayName property via the IODisplay API is not working
anymore on ARM based macs and was broken in at least one other case.

instead we use the new localizedName property introduced in 10.15 of the
NSScreen. we don't need any backwards compatibility since 10.15 is the
oldest version we support now.

configs and scripts that use the options and properties fs-screen-name,
screen-name or display-names need to be adjusted since the names could
differ from the previous implementation via the IODisplay API.

Fixes #9697
2023-11-10 14:30:32 +01:00
der richter
23de1deaaa mac: remove runtime checks and compatibility for macOS older than 10.15
we stopped supporting macOS older than 10.15 and hence can remove all
the unnecessary runtime checks and compatibility layers.
2023-11-09 18:12:25 +00:00
Dudemanguy
a5bf211e12 meson: remove several macos-10-* build options
These have been build options since the waf build, but that doesn't
really make sense. The build can detect whatever macOS sdk version is
available and then use that information to determine whether to enable
the features or not. Potentially disabling multiple sdk versions doesn't
really make any sense. Because f5ca11e12b
effectively made macOS 10.15 the minimum supported version, we can drop
all of these checks and bump the required sdk version to 10.15. The rest
of the build simplifies from there.
2023-11-09 18:12:25 +00:00
der richter
78d43740f5 vo_gpu/vo_gpu_next: add vulkan support for macOS
add support for vulkan through metal and a translation layer like
MoltenVK. also add the possibility to use different render timing modes
for testing.

i still consider this experimental atm.
2023-10-14 18:39:56 +02:00
der richter
bc66de2834 mac: add a window animation lock to wait for animations to finish
add an animation lock to the window to prevent the window from closing
while animating. if this is done while the fs animation is running the
dock will stay hidden. this is not used yet, because it's unnecessary
for cocoa-cb but will be for new vo backends.
2023-10-14 18:39:56 +02:00
Christoph Heinrich
91cc0d8cf6 options: transition options from OPT_FLAG to OPT_BOOL
c784820454 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.
2023-02-21 17:15:17 +00:00
rcombs
588cb9a977 mac: avoid unnecessary unsafe conversions; fixes crash in debug builds
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.
2022-09-14 16:28:12 -05:00
Cœur
bb5b4b1ba6 various: fix typos 2022-04-25 09:07:18 -04:00