Commit Graph

53530 Commits

Author SHA1 Message Date
Guido Cella
7ded290e2c console.lua: rename format_table() to format_grid()
Since there is no table header or predetermined columns.
2025-01-24 04:34:49 +00:00
Guido Cella
0c5d966f47 console.lua: always say completions instead of suggestions
Both completions and suggestions were being used inconsistently. Just
always use completions which is much more common.
2025-01-24 04:34:49 +00:00
Guido Cella
a2ce811b28 console.lua: rename update() to render()
It is not clear what update() updates, in fact this rename allows
removing the comment explaining it. render() is clearer and is the same
term used by the OSC.
2025-01-24 04:34:49 +00:00
nanahi
afd5a741c1 m_option: use VAL macro for double type 2025-01-24 04:25:15 +00:00
nanahi
cbe2b0b4fe m_option: fix max/min range comment
The float type is now correctly clamped, so correct the
outdated comment.
2025-01-24 04:25:15 +00:00
nanahi
0e7f9c39dc m_option: correctly clamp OPT_FLOAT values
OPT_FLOAT values currently reuses OPT_DOUBLE handling, but if a
finite double value is produced which is out of the float range,
it results in UB.

If the floating point implementation is IEEE-754, then the value is
converted to infinity and stored in the float. However, this still
does not work as intended, as infinity is rejected for OPT_DOUBLE
unless infinity is explicitly specified as the min/max range.

Fix this by adding another clamping stage after operating the values
as double. Finite double values are clamped between FLT_MIN and
FLT_MAX, and out of range error is signaled when suitable.
2025-01-24 04:25:15 +00:00
nanahi
0903e9fbd4 various: fix range for float options
The range of these options should be capped to FLT_MAX
instead of DBL_MAX.
2025-01-24 04:25:15 +00:00
Guido Cella
df3872e318 loadfile: fix --loop-playlist + --shuffle + --prefetch-playlist
With this combination of options, the playlist is shuffled every time
the last playlist is reached, instead of when restarting from the first
playlist entry. Abort prefetching in this case, as we can't predict
which file to prefetch until the playlist is shuffled when actually
going to the first file again.
2025-01-22 14:01:11 +00:00
Guido Cella
304a620b0b loadfile: return earlier if prefetch already started
There is no need to call mp_next_file() if prefetching already started,
so return earlier.
2025-01-22 14:01:11 +00:00
Guido Cella
e7a253614c loadfile: fix --loop-playlist=N with --prefetch-playlist
With --prefetch-playlist and --loop-playlist, mp_next_file() is called
continously since the last second of playback or when viewing an image,
which decreases --loop-playlist=N to 1.

Fix this by adding a flag to mp_next_file() to specify whether to
decrement --loop-playlist=N. The first playlist entry is still
prefetched when it's the next one, but without decrementing
--loop-playlist=N.
2025-01-22 14:01:11 +00:00
Guido Cella
effa81eb6e console.lua: set a high z in select mode
Give console's overlay a high z only in select mode, since in this case
you want to click it so it should be above other overlays. In particular
console should be above the OSC's box layout with visibility=always when
you show it by clicking its buttons.

Keep using z=0 otherwise when it doesn't handle clicks, to avoid
unintuitive behavior of overlays handling clicks like the OSC being
drawn below console.

Since the legacy mp.set_osd_ass() doesn't accept z, we need to repeat
its caching logic, like 490b3ba007 and 86d24b069b did for the OSC.
2025-01-22 12:55:24 +02:00
Guido Cella
2ecfe3ecf7 Revert "osc.lua: draw box layout below console"
This reverts commit 2dd5bd4cd1.

Instead of drawing the box layout below any other overlay with z >= 0
which may not be wanted, the next commit will increase console's z only
in select mode instead.
2025-01-22 12:55:24 +02:00
llyyr
4c083f130d DOCS/interface-changes: change rst exts to txt
gen-interface-changes.py only looks for .txt files.
2025-01-21 17:44:16 +01:00
Guido Cella
c438732b23 console.lua: improve the hovered item calculation
Currently determine_hovered_item() assumes that each item is
opts.font_size pixels tall, which usually works well. This breaks with
fonts that get drawn taller than that, such as Japanese text, which
makes the calculation inaccurate for the top items and clips the
counter. A couple of users reported that it is inaccurate for them for
the top items even with ASCII characters in track selectors, presumably
because the circles are taken from a different font and make all lines
taller.

To fix this place each selectable item in its own ASS event positioned
like determine_hovered_item() expects.

Unfortunately this breaks --profile=box, so keep placing every item in
one ASS event with it.
2025-01-18 12:52:02 +01:00
Guido Cella
89c42e4481 console.lua: deduplicate y position calculation in update()
This deduplicates the calculation of the y position by assigning it to a
y variable, which will also be used in the next commit. margin_x is also
renamed to x for consistency.
2025-01-18 12:52:02 +01:00
Guido Cella
a06883f79a console.lua: refactor some log code
Rename lines_max to max_lines which is the name used in other functions,
and inline the log_messages variable because its name was confusing.

The math.max(0, lines_max) call was not necessary because console
doesn't crash with 0 or negative max lines.
2025-01-18 12:52:02 +01:00
Attila Fidan
c9412b4721 video/out/wayland_common: ignore clipboard offers w/o wanted MIME type
Some Wayland clients not offering text/plain will send their non-text
data regardless of the MIME type requested in wl_data_offer.receive. We
should just not call receive if they haven't offered a MIME type we
want.
2025-01-18 12:51:05 +01:00
Guido Cella
ca211b5b88 ytdl_hook.lua: fix start and end conditions
Fixes #13358, fixes fcc67cc6c1.
2025-01-10 14:06:16 +01:00
llyyr
f049a1e91c m_option: fix scientific notation timestamp parsing
Fixes: a173b47748
2025-01-09 23:54:59 +01:00
Guido Cella
7a59a12b76 select.lua: select files with watch later files with g-w
Implement selection of files to resume playing from watch later config
files. Requires --write-filename-in-watch-later-config.
2025-01-05 23:21:50 +01:00
Guido Cella
b530b402bf command: add current-watch-later-dir property
It will be used in the next commit.
2025-01-05 23:21:50 +01:00
Guido Cella
0c3c4a315b select.lua: use mp.msg.warn for unavailable messages 2025-01-05 23:21:50 +01:00
Kacper Michajłow
d66047589a ao_pulse: remove unnecessary casts and use the proper print specifier 2025-01-05 22:32:40 +01:00
Guido Cella
31d4515157 osc.lua: extract icon_font and icons variables
Define the icon font and icons in variables instead of scattering them
throughout the code to make it easy to change them in the future, or for
forks to change them. Also put the hex values in comments to easily
compare which icons in the font are unused, and explain how to get the
decimal values of the bytes.

Copied from ModernX.
2025-01-05 22:31:59 +01:00
Guido Cella
ff518ee6f0 DOCS/interface-changes: add slim*bar layouts to interface changes 2025-01-05 22:03:36 +01:00
nanahi
c42b19b806 video/out/gpu/video: allow taking transparent screenshots
Use RGBA format to take transparent screenshots when the video has
an alpha channel.
2025-01-05 21:32:55 +01:00
nanahi
72550aa7df console.lua: complete screenshot-raw format parameter 2025-01-05 21:28:57 +01:00
nanahi
ab47e95197 player/screenshot: support more formats for screenshot-raw command
This adds a format parameter to screenshot-raw command which controls
the format of the returned image data. In addition to the bgr0 format,
this adds support for 3 other formats: bgra, rgba, rgba64.

bgra is used by overlay-add command and several window systems.
rgba and rgba64 are used by several GPU APIs and are the formats
returned by the gpu and gpu-next screenshot code, which avoid the need
for further format conversion (see convert_image function).
rgba64 also adds the ability to acquire high bit depth screenshots
for screenshot-raw command.
2025-01-05 21:28:57 +01:00
nanahi
c1237c1d48 player/screenshot: add high depth and format parameters
Add the ability for screenshot_get_rgb to request high depth and other
formats. Will be used for the next commit.
2025-01-05 21:28:57 +01:00
Guido Cella
8ed672ffc8 osc.lua: add slimbottombar and slimtopbar layouts
Add layouts with only the top line of bottombar to be used with images.
2025-01-05 21:24:02 +01:00
Tim Lodemann
31d1defb7a ao_openal: fix null pointer dereference when creating OpenAL context
When the monitor goes to sleep, the OpenAL context was not properly
handled, resulting in a null pointer dereference and a crash. This
fix ensures that the OpenAL context is created and set correctly,
avoiding crashes under these conditions.

Fixes: #15648
2025-01-05 21:22:35 +01:00
Barnabás Pőcze
55f41fd8fa ao/pulse: only print server protocol after connection
The server's protocol version is not available until a connection is
properly established. Currently the value of `PA_INVALID_INDEX` is printed
due to calling `pa_context_get_server_protocol_version()` before connecting.

Fix this by doing the call after the connection has been set up.

Fixes: f744aadb77 ("ao_pulse: dump library version etc.")
2025-01-05 21:21:52 +01:00
Guido Cella
850e03d29f console.lua: add pause_on_open script-opt
Add a script-opt to pause when console opens and unpause when it closes,
disabled by default.

This is particularly useful for selectors that take several seconds to
open so you don't have to guess when to pause, like the subtitle line
selector with embedded subtitles, or my script which lets you select
which lyrics to download after requesting them with curl.
2025-01-05 21:21:32 +01:00
Kacper Michajłow
44384aad73 github/workflows/lint: add pre-commit hooks
Tests some basic errors in files like trailing white-spaces.
Additionally check the spelling with codespell.
2025-01-05 01:18:28 +01:00
llyyr
baecbb12fa sub: add sub-scale-signs
Allows --sub-scale to alow scale typesetting
2025-01-05 01:14:42 +01:00
Guido Cella
996e58a738 stats.lua: only reprint stats on video-reconfig when toggled
Make this behave like the comment says it should, because currently when
you show oneshot stats and change file, stats are printed again and hide
--osd-playing-msg. This happens even if you hide the stats by
show-texting something else and change file before the timer expires.
2025-01-05 00:52:49 +01:00
Guido Cella
2e1bc3cf26 osc.lua: allow adding custom buttons 2025-01-05 00:50:35 +01:00
Guido Cella
9db941ff8f osc.lua: add cache_enabled() helper 2025-01-05 00:50:35 +01:00
Filip Hejsek
0a0ceb7439 vulkan/context_display: implement display fps and resolution info
Implement VOCTRL_GET_DISPLAY_FPS and VOCTRL_GET_DISPLAY_RES by returning
values obtained from Vulkan.

Currently, display fps and resolution info is not available in the
displayvk context. Display fps is needed for display sync to work
properly. The information is also used as the value of a few properties.

This slightly improves parity with the drm context.
2025-01-04 22:40:03 +00:00
Kacper Michajłow
297c8cccf3 ci/win32: bump test timeout to 240 seconds
Avoids timeout of libplacebo/d3d11.c test that takes ~120s on Microsoft
software implementation.
2025-01-04 21:45:25 +01:00
Guido Cella
0d9763872c stats.lua: fix page 2 and 0 layout
Fixes d84e1b3582.
2025-01-04 20:45:31 +01:00
Guido Cella
d84e1b3582 stats.lua: inherit --osd-shadow-offset
Unlike font and border sizes, the default stats shadow offset is 0 like
--osd-shadow-offset, so it can be inherited from it by default to not
make users configure it in 2 places.

Since 0 and negative numbers are valid offsets, use infinity as the
placeholder for unconfigured values.
2025-01-04 20:07:49 +01:00
Kacper Michajłow
fc6ce44221 github/workflows/lint: remove -lint suffix from lint workflow job names 2025-01-04 20:03:46 +01:00
nanahi
221f54d1f9 DOCS/man/input.rst: mark flags as optional
They are not required but the current documentation only indicates
this to some commands but not for others.
2025-01-04 20:01:25 +01:00
der richter
64aeb4273d mac/app: make const char pointers to const pointers
they were meant to be immutable. imported in swift as mutable pointer,
which leads to errors with the strict concurrency in swift 6.

make the pointers const.
2025-01-04 17:04:21 +01:00
der richter
d03ce00127 mac/app: make re-assignment of complex macros const
they were never meant to be mutable and are imported as mutable vars
in swift. that causes errors with the strict concurrency in swift 6.

make them const/lets and immutable.
2025-01-04 17:04:21 +01:00
Guido Cella
2dcf69655a console.lua: complete playlist-play-index none 2025-01-04 16:52:01 +01:00
Guido Cella
6f8d8a38c4 console.lua: apply --osd-selected-color to selected completions 2025-01-04 16:22:20 +01:00
Kacper Michajłow
497310a235 Revert "demux_edl: disallow nested edl to avoid infinite loop"
Apparently there are some scripts that use nested edls instead of
flattening them first, so let's live with this.

This reverts commit de42e11662.
2025-01-04 16:13:07 +01:00
Kacper Michajłow
96da0cbcbd options: remove the player argument from --media-controls
It is now handled internally by the libmpv profile.

Since `player` was the default option, the impact should be minimal, as it
is uncommon to override the default option with the same value.
yes/no args will function the same way as before this commit.
2025-01-04 15:16:40 +01:00