Commit Graph

53673 Commits

Author SHA1 Message Date
Guido Cella 3fdc5338cc DOCS/man/select: add this file
Also update console's documentation.
2025-01-27 18:53:36 +01:00
Guido Cella e2090533cf select.lua: select from the watch history with g-h
Implement selection of the entries in the watch history.

The last entry in the selector deletes the history file.
2025-01-27 18:53:28 +01:00
Guido Cella b75ed73f4f loadfile: optionally save the watch history
The history could be formatted as CSV, but this requires escaping the
separator in the fields and doesn't work with paths and titles with
newlines. Or as JSON, but it is inefficient to reread and rewrite the
whole history on each new file, and doing so overwrites the history with
an empty file when writing without disk space left. So this uses a
hybrid of one JSON object per line to get the best of both worlds. This
is called NDJSON or JSONL.

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2025-01-27 18:53:28 +01:00
Guido Cella a3cc06f754 misc: make json_append() non-static
This will be used to write json with a bstr in the next commit.

Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
2025-01-27 18:53:28 +01:00
Guido Cella 908dc02eb9 misc: extract mp_find_non_filename_media_title() from command.c
This will be used to write the title in the watch history.
2025-01-27 18:53:28 +01:00
nanahi 27db2e1d50 DOCS/man: add documentation of wayland backend and properties 2025-01-27 18:51:31 +01:00
nanahi ab461e0209 console.lua: use clipboard property for native Wayland backend
This backend does not require the window focus quirk handling,
and also supports primary selection.
2025-01-27 18:51:31 +01:00
nanahi 3be195e616 console.lua: autocomplete clipboard/text-primary property 2025-01-27 18:51:31 +01:00
nanahi 481646da37 command: add current-clipboard-backend property
Useful to know which clipboard backend is active.
2025-01-27 18:51:31 +01:00
nanahi b2165c263a clipboard: add function to get clipboard backend name
Some platforms like Wayland may have support for multiple backends,
so add this function to make it possible to determine the current
active backend.
2025-01-27 18:51:31 +01:00
nanahi 46e2f55338 command: add clipboard/text-primary property
This property contains the text in the primary selection.
2025-01-27 18:51:31 +01:00
nanahi 9f2ac08851 clipboard-wayland: add Wayland clipboard backend
This adds a "native" Wayland clipboard backend based on the
ext-data-control-v1 protocol.
This backend overcomes the limitation of the VO (Wayland core protocol)
backend, and does not require the presence of the VO window to receive clipboard
updates.
This backend also supports primary selection if supported by the compositor.

The backend runs in a separate thread, so clipboard reading
does not stall the player like the VO backend.
2025-01-27 18:51:31 +01:00
nanahi 589e34cebd clipboard-vo: use clipboard parent log context
This adds clipboard backend names to backend-specific logs,
e.g. clipboard/vo.
2025-01-27 18:51:31 +01:00
nanahi dc5c857f7b clipboard: don't store mpv_global context
It's only used for logging, and further creation of log contexts
can use the parenting feature instead, so there is no need to
store it.
2025-01-27 18:51:31 +01:00
Attila Fidan fbf366d124 video/out/wayland_common: create per-seat objects on seat hotplug
This is to allow data device and text input to be used on seats that are
hotplugged after vo init.
2025-01-27 18:51:10 +01:00
Kacper Michajłow a1424d5fe0 demux/ebml: fix ebml_read_length()
Fixes reading EMBL sizes in some files and makes this function readable
while at it.

Would be good to inline mp_log2(), but should be good enough.

Fixes: #15691
2025-01-27 18:50:59 +01:00
verygoodlee 57a8105f1a win32: fix menu click failure caused by excessive menu-data updates
basically a copy of tsl0922/mpv-menu-plugin#77

if you have 200+ menu items and update `menu-data` about 400 times,
clicking menu item will not execute any command, the reason is that the
menu identifier greater than the max value of 16-bit unsigned integer.

1. make menu id always less than 0xF000 as mpv-player/mpv@861908c7 said
2. old menu items are never reused, should delete by DeleteMenu()
   instead of RemoveMenu(), destroys the handle and frees the memory
2025-01-26 22:19:26 +01:00
Kacper Michajłow feef1bc02b ci/linux: enable leak detector
The leak detector has been disabled due to a libass leak that was
causing the test to fail. I initially expected this change to be
temporary until a patch release of libass became available and we could
update it. However, it has been a few months without a release. Instead
of waiting, re-enable the leak detector and add a suppression file for
this specific leak.

Fixes: d6eb85bb1a
2025-01-26 22:18:14 +01:00
nanahi 964017c06c stream_dvb: accept float timeout
Change the --dvbin-timeout type to float so that it
can now be set to less than 1 second.
2025-01-26 22:15:30 +01:00
nanahi c776f5f2c9 various: use mp_poll instead of poll
mp_poll supports higher time resolution than poll, so use it
when the timeout is not 0 or infinite. Also use time conversion
macros.
2025-01-26 22:15:30 +01:00
nanahi 90a84e97f3 misc/dispatch: remove mention of select
mpv code doesn't use select, only poll.
2025-01-26 22:15:30 +01:00
nanahi 88ee25da12 video/out/wayland_common: remove useless flag
POLLHUP is only returned in revents and ignored in events,
so there is no need for it to be here.
2025-01-26 22:15:30 +01:00
Kacper Michajłow d64095bd7e osdep/io: map ftell to int64_t version on win32
Note that all mpv code expects 64-bit offsets already. And we set
_FILE_OFFSET_BITS=64 unconditionally. Also this mirrors lseek() that we
already have wrapped in similar way.
2025-01-26 22:10:00 +01:00
Kacper Michajłow b01e1ab61a osdep/io: add ftruncate for win32
Trivial wrapper around _chsize_s() to return -1 on errors always.
_chsize_s() returns errno value. At the same time errno is set to the
same value.

FILE_WRITE_DATA has to be added in append mode, because _chsize_s()
requires write permissions, not only append. We lose atomic append, but
we follow POSIX here, so that's fine, I guess.
2025-01-26 22:10:00 +01:00
Attila Fidan 98627b027d video/out/wayland_common: fix crash with multi-seat drag and drop
If you have two seats connected, both with the pointer capability, and
use two hands to start a drag and drop operation with each pointer, then
move one pointer to the mpv window, then the other, mpv fails the
!wl->dnd_offer->offer assert in device.enter, because it expects that
the compositor wouldn't just call device.enter again before device.leave
or offer.finish.

The data device is per-seat, so this commit makes mpv track the data
device's offers per-seat rather than in vo_wayland_state, which makes
more sense and is easier to reason about when multi-seat is involved.
2025-01-26 16:32:30 +00:00
Kacper Michajłow 3550ec52cd Revert "ci/win32: restrict shaderc version to fix build errors"
This reverts commit ddba159b51.

Follow-up after: 3b586ba6c3
2025-01-25 18:34:28 +01:00
nanahi f1924988dc various: update license headers
Change MPlayer to mpv and the last sentence like all other files.
2025-01-25 18:33:43 +01:00
sfan5 3b586ba6c3 ci/mingw: update library versions
also moves shaderc to latest git again
2025-01-25 15:39:36 +01:00
Guido Cella 04c328f784 console.lua: use the same blur amount as --osd-blur
I have no idea why, but console's blur is smaller than in OSD messages
and stats (regardless of persistent_overlay). It's smaller regardless of
scale_with_window, or if using 0 PlayRes like stats with
persistent_overlay=yes.

With scale_with_window=yes, multiplying the blur by 2.5 seems to make it
the same. This is probably because 2.5 is 720 / 288, which are the base
height sizes scale from and the OSD's PlayResY. With
scale_with_window=no, we need to multiply by osd_h, which is always 720
with scale_with_window=yes.
2025-01-25 03:14:59 +00:00
Attila Fidan 51dc6286b6 video/out/wayland_common: support IME usage via text-input-v3
This is useful for text input in, for example, console.lua. Each
character in the commit string gets turned into an mpv key press.
Pre-edit strings are not handled, since there's currently no good way to
handle that or make it useful to text input scripts. Like win32, which I
tested in wine, another limitation is that the composition window is
always positioned at the top left of the window, since we cannot get
useful positioning hints from mpv scripts. It allows the composition
window to be within the window and avoids obstructing the console
prompt.

This can be enabled/disabled with --input-ime=<yes|no> (default: yes).
2025-01-25 03:14:44 +00:00
Kacper Michajłow 14520229da github/workflows/lint: add mypy linting
Not everything is typed in our scripts, but this is just to make sure
current code passes linting. More typing can be added in the future.
2025-01-25 02:35:54 +01:00
Kacper Michajłow e8fa2a7aaa TOOLS/osxbundle: fix inplace argument type 2025-01-25 02:35:54 +01:00
Kacper Michajłow 805793154d TOOLS/macos-sdk-version: check if xcodebuild is defined
Makes mypy happy.
2025-01-25 02:35:54 +01:00
Kacper Michajłow 37b513a760 TOOLS/file2string: use array of tuples to avoid unpacking strings 2025-01-25 02:35:54 +01:00
Kacper Michajłow da2880fb54 TOOLS/dylib_unhell: check regex search result 2025-01-25 02:35:54 +01:00
Kacper Michajłow 2d5c5030e5 TOOLS/stats-conv: typing fixes
To make mypy happy. PyQtGraph doesn't define types, so ignore those.
PyQt6 has types, but we use only one function from it, so to avoid
installing it, ignore it too.
2025-01-25 02:35:54 +01:00
Kacper Michajłow 59afdf2ef8 TOOLS/gen-mpv-desktop: don't overlap variable with different types 2025-01-25 02:35:54 +01:00
Kacper Michajłow 4cf914d44d TOOLS/gen-interface-changes: fix variable type mismatch 2025-01-25 02:35:54 +01:00
Guido Cella d87113fdc7 m_option: fix float option values <= 0
FLT_MIN is a small positive number (1.175494e-38), so the check v <
FLT_MIN introduced in 0e7f9c39dc made all 0 and negative float option
values error, e.g. panscan=0 or video-align-y=-1.

Fixes 0e7f9c39dc, fixes #15728.
2025-01-24 15:03:04 +00:00
Dudemanguy a23b11af5f github/workflows: print meson test log on failure on BSD
A build failure will output its error, but a test failure says nothing
other than what test failed. Print the meson test log as well.
2025-01-24 14:55:03 +00:00
Guido Cella 20375d1133 select.lua: show the ID of editions without title
MKV editions can have no title. Print "Edition" and their IDs instead of
showing an empty selection.
2025-01-24 04:35:36 +00:00
Guido Cella 5bbeabf450 console.lua: sort completions
With the previous commit, this sorts completions with the same score
alphabetically.
2025-01-24 04:35:27 +00:00
Guido Cella 8ae3beeb98 console.lua: preserve the order of items with equal score
table.sort() is unstable, meaning that it randomly reorders items with
the same score, so currently fuzzy_find() checks if the line is empty to
not change the original order of the unsorted items. But actually filled
lines have the same problem: e.g. searching foo with filenames like
foo_{1..99}, they are returned in random order.

To fix this sort by score only when 2 items have different score, else
sort by the original position.
2025-01-24 04:35:27 +00:00
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