Commit Graph

950 Commits

Author SHA1 Message Date
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 16ea688115 mac/menu: make menu creation recursive to allow nested submenus
also makes menu creation cleaner and more obvious.
2024-03-07 01:03:52 +01:00
der richter 4eb58f6ea7 mac/menu: move conditional Bundle menu items into config
only add the "Show log File…" menu item config when invoked from the
bundle, instead of testing on menu item creation. this is similar to the
touch bar menu items now.
2024-03-07 01:03:52 +01:00
der richter 73e494a237 mac/menu: keep track of menu items with dynamic actions
keeping track of the dynamic menu items lets us directly access them by
key. we don't need to search in the config array for the right config
and menu item.
2024-03-07 01:03:52 +01:00
der richter 8d4329a710 mac/menu: merge file and url config properties
a file path is basically an URL. both are also handled as URL objects
in our code.
2024-03-07 01:03:52 +01:00
der richter 46a9e8c130 mac/menu: properly guard playlist array access 2024-03-07 01:03:52 +01:00
der richter 30eab4b933 mac/menu: attach menu config to menu item for direct access
add a config property to the menu items, so we don't need to search in
the config array for the right config.
2024-03-07 01:03:52 +01:00
der richter 95d08df7a7 mac/menu: replace app.command usage with event.command 2024-03-07 01:03:52 +01:00
der richter 37990597c7 mac/menu: fix touch bar menu item
the check broke when the runtime check was removed, eg the menu item was
never added to the menu. since we only add the menu item to the config
when touch bar support is available the check is completely unnecessary.
2024-03-07 01:03:52 +01:00
der richter 035906dad5 mac/menu: rename Preferences to Settings for consistency with macOS 2024-03-07 01:03:52 +01:00
der richter ad0573ff8e mac/menu: remove duplicate key assignment Undo/Zoom
this key is already assigned to Undo.
2024-03-07 01:03:52 +01:00
der richter eadd85a6ac mac/menu: optimise loading files function
don't save files in a temporary array and use an in place mapping.
2024-03-07 01:03:52 +01:00
der richter cb807ff063 mac/menu: replace deprecated openFile() usage 2024-03-07 01:03:52 +01:00
der richter 996ec6feca mac/menu: remove unnecessary alert config fields and alert
the config folder is created by mpv if it does not exist, so the last
alert is unnecessary.

also change config path priority.
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 bbbd6e272c mac/app: remove unused function 2024-03-07 01:03:52 +01:00
der richter 86fa9b18a3 osdep/mac: make mac naming of files, folders and function consistent
rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to
make naming consistent.
2024-02-28 15:52:47 +01:00
der richter c7ff037fdd build: fix build when disabling cocoa-cb
the swift obj-c bridging header is only included when cocoa-cb is
enabled. cocoa-cb is not the only swift feature anymore and disabling
cocoa-cb leads to a runtime error that specific swift classes could not
be found.

include the swift obj-c bridging header in the case swift features are
enabled.
2024-02-27 14:04:30 +01:00
der richter a7c4a113b8 cocoa-cb: remove pre-allocation and initialise only when used
cocoa-cb was always pre-allocated in the Application itself because
libmpv needs to be set up before usage, an opengl context has to be set
and because it was decided mac specific code should be kept out of
libmpv.

this means that a completely working libmpv and opengl renderer was set
up even if it wasn't used. leading to unnecessary log message, resources
being used or reserved on the system that might not be used, triggering
of dedicated GPU unnecessarily and many other things.

even if not optimal, this wasn't the biggest problem since we only had
that one working vo on macOS. though now that we have a vulkan
gpu(-next) backend on macOS that was made the default, we always have
that dangling cocoa-cb instance, which is completely unnecessary.

move the cocoa-cb initialisation into libmpv preinit function and only
init cocoa-cb when we are a standalone App and cocoa-cb support is build
into.
2024-02-27 14:01:38 +01:00
nanahi ab3a63285a osdep/io: add mp_unlink()
unlink() was never wrapped in win32, so all usages of it were referring
the ANSI version of the function. This doesn't work properly for Windows
versions before 1903 (where the UTF-8 codepage is requested).

Fix this by adding mp_unlink() which wraps over _wunlink().
2024-02-25 14:30:20 +01:00
der richter 06ee5e9344 mac: code consistency changes 2024-02-24 20:04:16 +01:00
nanahi 84015959cc osdep/io: move I/O utility functions to misc/io_utils
The purpose of osdep/io is to provide a wrapper for POSIX I/O functions
on Windows. The last 2 functions are utility functions which don't serve
this purpose.
Move them to a separate file.
2024-02-23 21:35:57 +01:00
nanahi c36e051470 osdep/io: ignore 'x' mode for mp_fopen
fopen() with 'x' mode is a non-portable glibc extension, is currently
unused, and should not be used in order to maintain POSIX compatibility.
Thus there is no need for the Windows wrapper mp_fopen() to support it.
2024-02-23 21:35:43 +01:00
der richter d954646d29 various: make mentions of macOS consistent
change all mentions and variations of OSX, OS X, MacOSX, MacOS X, etc
consistent. use the official naming macOS.
2024-02-21 20:46:53 +01:00
Jose Maldonado aka Yukiteru 293532057e osdep/threads-posix: fix headers for OpenBSD build
In OpenBSD the compilation fail because osdep/threads-posix.h
need include pthread_np.h
2024-02-15 16:46:12 +00:00
der richter bba3d28781 mac/remote: simplify cover retrieval 2024-02-15 00:11:55 +01:00
der richter 45192d94d3 mac/remote: remove unnecessary nowPlayingInfo variable
no need to keep track of the nowPlayingInfo, MPNowPlayingInfoCenter
already provides the current info.
2024-02-15 00:11:55 +01:00
der richter e457cc260c mac/remote: add album and artist info 2024-02-15 00:11:55 +01:00
der richter c56be84675 mac/remote: add seek support
Fixes #11233
2024-02-15 00:11:55 +01:00
der richter 00efaeb428 mac/remote: add chapter title info 2024-02-15 00:11:55 +01:00
der richter ca8c61838e mac/remote: add media-title info
Fixes #11233
2024-02-15 00:11:55 +01:00
der richter 0a343369ba mac/remote: add playback rate info
also rate limit the position to update at max once per second.
2024-02-15 00:11:55 +01:00
der richter e23e158481 mac/remote: add duration and current position info
Fixes #11233
2024-02-15 00:11:55 +01:00
der richter 07a3bf0365 mac/remote: remove make current observer when stopped
the observer is registered on every call of the start function. this
could lead to several registered observers for the same event and
several calls to the make current function, even though we only need it
once per event.

properly remove the observer on stop, so we only ever have one observer
registered.
2024-02-15 00:11:55 +01:00
der richter de36f11fa8 mac/remote: replace command handler with generic handler function config
preparation for the upcoming changes for new functionality not related
to key handling.
2024-02-15 00:11:55 +01:00
der richter 05d0252a30 mac/remote: simplify repeatable key logic 2024-02-15 00:11:55 +01:00
der richter 0e556674dc mac/remote: move configs to initialiser for new MediaPlayer shorthands 2024-02-15 00:11:55 +01:00
der richter 1883f2f7a0 mac/remote: move class local struct and enum definition to extension
the class local struct and enum are moved to an extension to separate
their definition and usage.
2024-02-15 00:11:55 +01:00
der richter 80cde2671c mac/remote: use explicit struct instead of generic array for configs
making the config explicit gets rid of some optional unwrapping. also
rename some variables to better represent their values.
2024-02-15 00:11:55 +01:00
sfan5 ca5f7d2b4b osdep: fix infinite loop when cancelling subprocess
Due to the state of the other fds/pipes it cannot safely be assumed
that the loop breaks on its own.
2024-02-11 14:13:22 +01:00
nanahi 71598ca07e various: replace dead links in comments
Replace various dead links with live replacements or archives.
Less friction for anyone who wants to look up these references.
2024-02-11 04:01:24 +00:00
Kacper Michajłow e2e75906da io: add mp_save_file
Move from vo_gpu_next.c to io.c and return result.
2024-01-31 15:38:21 +00:00
Kacper Michajłow 19a6b84915 osdep/timer: update documentation and test for mp_time_ns
No longer true after 8bbcc87fee.
2024-01-26 03:28:55 +00:00
Kacper Michajłow 52cabca4e5 osdep/io: expand path before LoadLibrary
Fixes compatibility with loading scripts from relative config paths.

Fixes #13212
2024-01-22 14:41:46 +00:00
Kacper Michajłow 13ed292ab0 terminal: don't print escape sequence if not tty 2024-01-15 10:39:42 +01:00
NRK ab60ad8619 terminal-unix: don't install handler before pipe 2024-01-15 10:39:42 +01:00
NRK b75b56f910 terminal-unix: move all processing out of sighandler
commit fa9e1f06f tried to move signal unsafe operations out of
signal handlers but mistakenly introduced a race. before,
sigtstop would process the following in order:

0. do_deactivate_getch2();
1. raise(SIGTSTP)

that commit moved 0 out of the signal handler (due to it being
unsafe) but kept 1 in there. this may mess up the ordering of
these operations. this commit moves everything out of the
handler so that things happen in proper order.

since things are now moved out of the handler, SA_RESETHAND is
no longer being applied to SIGTSTP. since that can result in
races if multiple signals are delivered faster than we can
respond to them.
2024-01-15 10:39:42 +01:00
llyyr f33a4d2fd9 terminal-unix: don't set `SA_RESETHAND` for SIGTERM/SIGQUIT
This can cause mpv to abruptly quit without following the proper uninit
process when a second `SIGTERM` or `SIGQUIT` is sent and mpv
didn't quit on the first one already. This is because the default action
for these signals is to terminate the program immediately, similar to
`SIGKILL`, and `SA_RESETHAND` resets the `quit_request_sighandler` to
`SIG_DFL` for the default action.

Also keep the `SA_RESETHAND` flag for SIGINT because the current
behavior is to quit after receiving two Ctrl+C no matter what, this is
probably convenient and worth keeping.

This change is because some tools (e.g. GNU timeout) send SIGTERM twice
after the timeout period.

An easy way to reproduce is with `timeout 1 mpv [...]` where mpv would
quit abruptly anywhere from half the time to once every 50 attempts
depending on your luck.
2024-01-14 23:10:50 +01:00
sfan5 9565675488 various: use correct PATH_MAX for win32
In commit c09245cdf2
long-path support was enabled for mpv without actually
making sure that there was no code left that used the
old limit (260 Unicode chars) for buffer sizes.
This commit fixes all but one case.
2023-12-27 22:55:56 +01:00
sfan5 f57ec94d9f osdep: clarify and rename a constant on win32
This is about the maximum filename not path length.
2023-12-27 22:55:56 +01:00