951 Commits

Author SHA1 Message Date
nanahi 675fb1229b input/dnd: move --drag-and-drop handling to dnd client
This unifies --drag-and-drop handling to a single place. All platforms
currently only support normal drop (mapped to "replace") and shift click
drop (mapped to "append").
2026-05-01 13:42:57 +02:00
nanahi 81611b4a4e input/dnd: move built-in drag and drop handling to mpv client
This moves the drag and drop handling to an internal mpv client,
removing the hardcoded handling from core.
2026-05-01 13:42:57 +02:00
nanahi 87ccb6022c command: add dropped-file property
This adds dropped-file property which contains a list of dropped files
and the type of the drop. This allows clients to implement custom drag
and drop handling.
2026-05-01 13:42:57 +02:00
nanahi e12ab84571 input: add --input-builtin-drag-and-drop option
This allows disabling the built-in drag and drop handler, while still
allowing VO to announce dropped files.
2026-05-01 13:42:57 +02:00
nanahi 544a56a148 input: rename notify_touch_update to notify_event_update
Will also be used to notify dnd updates.
2026-05-01 13:42:57 +02:00
nanahi 5e0932e785 input: rename mp_event_drop_files to mp_input_drop_files
Move it to input.c. Will be used in next commit.
2026-05-01 13:42:57 +02:00
nanahi 80582efca5 input/cmd: use _name for command name in mpv_command_node
Some commands have named arguments named "name", which conflict with
the "name" entry used to specify command name in mpv_command_node, so
they cannot be used with mpv_command_node.

These commands include:
set, del, change-list, add, cycle, multiply, enable-section,
disable-section, define-section, script-binding, keybind, keypress,
keydown, keyup, apply-profile.

This makes mpv_command_node accept command name as key "_name", so
"name" can be used to specify command arguments. For compatibility,
if "_name" entry does not exist, then "name" is used as fallback.
2026-04-06 18:33:20 +02:00
nanahi b11ae04f37 input/ipc-unix: don't delete file for abstract sockets
If --input-ipc-server path name starts with "@", then "@" is replaced
with a null character, which represents the abstract socket namespace
on Linux. Because abstract sockets have no file system presence, it
should not delete the file with the same name starting with "@".
2026-04-06 18:31:27 +02:00
nanahi e0fe1a45d2 command: fix race in reading pad_buttons_pressed
mp_input_get_tablet_pos stores the address to an array that is protected
by lock, and the content is accessed without acquiring lock.

Fix this by writing the values to an array inside mp_input_get_tablet_pos.

Fixes: 0fbf20f057
2026-04-06 18:28:04 +02:00
nanahi b67a5b4cd8 input: fix out of bound read/write in pad_buttons_pressed
When buttons > MP_MAX_TABLET_PAD_BUTTONS and the value is stored in
ictx->tablet_pad_buttons, the next mp_input_set_tablet_pad_focus call
will cause out of bound write, and mp_property_tablet_pos will cause
out of bound read.

Fix this by limiting ictx->tablet_pad_buttons range.

Fixes: 0fbf20f057
2026-04-06 18:28:04 +02:00
llyyr 7b1ee864b8 input: only allocate key name if we've printing trace level messages 2026-03-19 20:45:55 +01:00
llyyr 520faac68d input: fix leaking tablet tool key name 2026-03-19 20:45:55 +01:00
nanahi 34b6439dc6 input/keycodes: fix combo key handling for - key
The current handling tries to handle the edge case where the current key
in a combo key is -, but when the current key is not - and the next key
is -, it misdetects - as separator and fails to parse correctly.

Fix this by restricting the handling to situations where the current key
is -.

Fixes: ce2367725e
2025-09-14 01:25:38 +02:00
Dudemanguy 2b74582fcb Revert "various: remove unneeded option path expansion handling"
Fixes #16573.

This reverts commit 137d5374bd.
2025-08-08 01:07:00 +00:00
Dudemanguy 137d5374bd various: remove unneeded option path expansion handling
Same reasoning as the previous commits. This is now handled by the
option system so we can remove the redundancy.
2025-07-22 17:52:41 +00:00
Dudemanguy 2763390c15 input/cmd: use m_option_set_node_or_string
Like the previous commit, this has a conditional that matches exactly
what this helper function is supposed to do. For logging reasons, we
can't completely remove the val->format comparison, but it can be
simplified to be cleaner.
2025-07-15 18:06:14 +00:00
Jens Peters 0fbf20f057 wayland: expose tablet pad buttons to input system
Expose all buttons state to the Client-API for usage in e.g. lua.
2025-07-14 22:07:24 +00:00
Jens Peters db60145c2d wayland: move tablet tool handling to mpv input system
Upgrade tablet input to first class citizen similar like
touch input, but more simple since use case for now is
mouse emulation only.

Keep state for coordinates and in-proximity.
Introduce property for disabling tablet input.
Introduce Client-API property `tablet-pos`.
2025-07-14 22:07:24 +00:00
Kacper Michajłow 07571859ac player/scripting: fix race condition when destroying clients
Clients run in detached threads and are waited to signal when they are
finished with self mpv_destroy() call. Problem is that after detached
thread calls this function, mpv consider this client to be done and can
do whatever. One example is when mpv exits and wait for scripts to
finish we got race condition, because mpv (main thread) can exit first
and the detached thread calls ta_free() which crashes, because we may
have already destroyed things that the thread depends on.

I've seen this crash on FreeBSD CI job (libmpv-lifetime test), where the
libmpv.so has been unloaded while the thread was still doing ta_free()

```
==5081==ERROR: AddressSanitizer: SEGV on unknoun address 0x000001111806 (pc 0x000001111806 bp 0x7fffdedf4e40 sp 0x7fffdedf4e08 T40)
==5081==The signal is caused by a READ memory access.
    #0 0x1111806  (<unknown module>)
    #1 0x803cd6900 in ta_free /home/runner/work/mpv/mpv/build/../ta/ta.c:243:5
    #2 0x803a2fc87 in run_script /home/runner/work/mpv/mpv/build/../player/scripting.c:93:5
    #3 0x803a2ffe0 in script_thread /home/runner/work/mpv/mpv/build/../player/scripting.c:99:5
    #4 0x2c451a in asan_thread_start(void*) /usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
    #5 0x80034fb04  (/lib/libthr.so.3+0x10b04)
```

Note the 0x1111806 jump which is completelly bogus.

Fix this by doing mpv_destroy() as a last step in detached threads.
2025-04-02 23:46:11 +02:00
nanahi ca6e26399f input: mark mouse and touch position update in mp_cmd
This makes it possible to distinguish these dummy commands
for position update notification from other commands.
2025-03-26 01:33:21 +01:00
Dudemanguy 533a684381 player: only coalesce callbacks from parsed config files
This relaxes what bbac628a1b introduced.
Although it is rare, there may be scripts out there that depend on the
old timing. We'd still like to process config files in a sane manner and
not cause OOMs so keep the general coalescing mechanism in place but use
it selectively. There is one special case with the --input-commands
option. We want this coalesced as well so some special handling needs to
be added for that.
2025-03-07 14:35:52 +00:00
Kacper Michajłow 1c49cfdb97 various: use mp_assert macro 2025-03-04 20:07:29 +01:00
Dudemanguy ee07dcf4c7 input: add quiet arg to mp_input_set_mouse_pos for wayland
Setting the mouse position always updates the cursor visibility state in
the core, but that's not always desired by the caller. Make it optional.
In practice, this is for wayland. Fixes #15967.
2025-03-01 16:38:06 +00:00
Kacper Michajłow d759e26fd0 libmpv: use correct header directory name
libmpv headers are installed to `mpv/`, so why are we pretending it is
`libmpv`?

Fixes documentation, libmpv meson dependency, tests.
2025-02-23 01:40:12 +01:00
Kacper Michajłow 77313f73a2 various: reduce the include scope of some public headers 2025-02-23 01:40:12 +01:00
Kacper Michajłow 59d1dc43b9 various: fix typos 2025-01-04 15:59:49 +02:00
nanahi 62e434ac7f input/cmd: add comment for scalable and is_ignore 2024-11-27 20:40:41 +01:00
Guido Cella da82c0428e input/cmd: increase the command length for --input-cmdlist
--input-cmdlist crops playlist-next-playlist, playlist-prev-playlist,
write-watch-later-config and delete-watch-later-config, so increase the
string length to that of the longest command.

Also stop specifying both the minimum and maximum length since they are
the same.
2024-11-16 16:58:38 +01:00
nanahi 1c9d066c9e input: fix memory leak with scalable input and nonscalable commands
With scalable input source, scale_units can be 0, and cmd is not
freed. Fix this by freeing cmd when scale_units is 0.

Fixes: 937128697f
2024-11-16 16:58:21 +01:00
nanahi 081fc7e317 input: fix style 2024-11-02 01:39:15 +01:00
nanahi 1b9d070786 command: fix keybind command with sequence keys
The command is documented to use the same syntax as input.conf, but
it doesn't work with sequence keys because it uses
mp_input_get_key_from_name for checking key names, when it should
use mp_input_get_keys_from_string instead.

Fix this by using the correct function.
2024-11-02 01:39:15 +01:00
nanahi 56e2689894 command: add the ability to set comment for keybind command
This allows the keybind to have a comment field which can be
read from input-bindings, and displayed by e.g. stats.lua.
2024-11-02 01:39:15 +01:00
nanahi d97ba359d2 input: deduplicate mp_input_bind_key
It's just a copypaste of bind_keys with some params set to
hard coded values, so use bind_keys instead.
2024-11-02 01:39:15 +01:00
nanahi 8c3fd2cd38 input: use stream_read_file2 for reading config
The existing logic already duplicates stream_read_file other than
the flags. With stream_read_file2, this duplication can be removed.
2024-10-20 19:31:49 +02:00
nanahi da0160b0ee input/cmd: add nonscalable prefix
Some keys like WHEEL_UP are "scaled" if the input source is high
resolution, like touchpad. However, sometimes it's desirable to
disable this scaling and only active the key binding in discrete
steps, such as relative keyframe seeking which interacts poorly
if the command is scaled.

This adds the nonscalable prefix to disable this scaling.
2024-10-14 01:55:49 +02:00
nanahi 3863221246 input: skip BOM properly
Key names are already required be UTF-8 like everything else
in mpv other than media file formats which support other encodings.
stream_skip_bom is the wrong function for this, since it also skips
UTF-16 BOM.
2024-09-24 19:22:47 +02:00
Kacper Michajłow 71f2220991 meson: use relative file paths for file2string
This fixes "Generated from" comments to not include local source path in
generated files.
2024-09-21 23:39:10 +02:00
Kacper Michajłow 5edc8973eb various: use talloc_replace 2024-09-08 17:33:27 +02:00
nanahi c4ff675198 input: add MP_KEY_STATE_SET_ONLY
Trivial.
2024-09-07 18:14:56 +00:00
nanahi 4295141703 input/keycodes: fix typo 2024-09-07 18:14:56 +00:00
Kacper Michajłow ad7976c33e input: fix use of bstr like null terminated one
It has been changed in one of the iterations of the patch during review,
but bstr doesn't have to be null terminated. Fix it by adding dedicated
node_map helper.

Fixes: 1a27f3c
2024-09-04 03:52:09 +02:00
nanahi ab0aaaad39 input/keycodes: add KP_ADD/SUBTRACT/MULTIPLY/DIVIDE keycodes
In general, mpv treats numpad keys as separate inputs. The +-*/ keys
however are exceptions so it's not possible to distinguish them from
non-numpad keys.

This adds keycodes corresponding to these keys so that they can be
handled differently.
2024-08-11 15:08:42 +02:00
llyyr 67bd00f163 input: fix inverted condition
I don't know if this broke anything but the the condition was inverted
as a result of the recent commit.

Fixes: 1a27f3caf7 ("input: use bstr for section name")
2024-08-06 20:26:49 +02:00
llyyr d766fc0914 input: don't mutate 'section' variable inside a loop
This fixes broken input-section parsing

Fixes: 1a27f3caf7 ("input: use bstr for section name")
2024-08-06 20:26:49 +02:00
Kacper Michajłow 1a27f3caf7 input: use bstr for section name
Resolves mixed use of bstr in internal processing and char* for storage.
Also makes faster comparision when searching for section and resolves
comparision when name contains null chars.
2024-08-04 21:33:36 +02:00
nanahi 40f1a89e40 input/ipc: use bstr for fd parsing
Also rejects the case of "fd://" without any number which was
silently accepted as 0.
2024-07-29 21:00:48 +02:00
nanahi bb0932a3ad input/ipc-win: support fd:// for --input-ipc-client
This makes --input-ipc-client work on Windows.

To use this feature, a parent process needs to create a connected named pipe,
wrap the server handle in a CRT fd, and then spawn mpv as a child process
with the fd as the --input-ipc-client parameter.
The process can then communicate through the client handle.

The named pipe must be created duplex with overlapped IO and inheritable
handles.
2024-07-29 21:00:48 +02:00
nanahi 7c70df0934 input/cmd: move m_option_type_cycle_dir to m_option.c
A relic when commands lived in input.c. Move them to where other option
types live. Also remove the redundant copy_opt.
2024-07-01 10:02:13 +02:00
Kacper Michajłow b4123826e5 input/keycodes: validate parsed value to avoid overflow 2024-06-23 02:33:04 +02:00
Kacper Michajłow b4bbc27d9c input: map Num 5 to distinct value when numlock is off
Until now both numlock on and off were mapped to KP5.
2024-06-13 20:42:24 +02:00