Commit Graph
653 Commits
Author SHA1 Message Date
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 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
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
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
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
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 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 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 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
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
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 65fef73c2b input: don't resolve double clicks on the active mouse section
Normally, key bindings are resolved in the input section stack order.
However, mouse key bindings have a special "active mouse section" feature
(which is a section with MOUSE_MOVE bound and mouse button is down in the
section) which lets the section to be selected instead, with a fallback
to the "default" section. The intention of the feature is for mouse
dragging which should "stick" to the section where the mouse is down.

This causes a problem with scripts which bind mouse double clicks:
since double clicks are triggered on mouse down, it's resolved with the
"active mouse section" feature instead of the section stack order.
If the section which has the double click bound doesn't also have
MOUSE_MOVE bound, the "default" section will be used instead.
If it's already bound there, it will be triggered.

Fix this by not resolving double clicks on the active mouse section, which
is not the intention of the feature.
2024-06-08 23:13:15 +02:00
nanahi de97cb0964 input: mark a command as canceled if it is explicitly dropped
In certain situations (including but not limited to begin window dragging),
it is desired to cancel the current command completely. However, commands
which have on_updown flag set require the command to be invoked in this
situation. There is currently no way to know if the command is triggered
normally or triggered because it is dropped.

This adds a canceled state to mp_cmd which indicates this.
2024-06-06 23:38:39 +03:00
nanahi 16612672fd input: fix grammar errors and typo 2024-06-05 13:35:33 +00:00
nanahi 0509e5b2ed input: only begin VO dragging if the section allows
Otherwise, on sections which don't allow VO dragging, the mouse button
is force released and dragging events won't be generated.

Fixes: 349aac462e
2024-06-05 11:11:00 +02:00
nanahi 7e82108bec input: reset doubleclick timer when dragging begins
This prevents doubleclick from activation if a second mouse click comes
quickly after a click which begins dragging.
2024-06-04 12:41:51 +02:00
nanahi 49b5e6d042 input: un-hardcode VO dragging
This adds the --input-builtin-dragging option, which allows the built-in
dragging behavior to be disabled. This allows scripts to implement custom
dragging behavior with left button down events and begin-vo-dragging
command, which could only be done for other mouse buttons before.
2024-06-04 12:41:51 +02:00
nanahi 349aac462e input: prevent MBTN_LEFT conflict with VO dragging
Currently, the built-in VO dragging conflicts with the MBTN_LEFT binding,
so the binding is activated even though the VO dragging begins. Fix this
by releasing the currently down command so that MBTN_LEFT can be bound to
a useful action (such as play/pause).
2024-06-04 12:41:51 +02:00
nanahi a6683ea3c9 input: implement VO dragging deadzone
This adds the --input-dragging-deadzone option, which adds a deadzone
for the built-in VO deagging. This prevents accidental VO dragging.
2024-06-04 12:41:51 +02:00
nanahi a23098b555 input: fix mouse position equality check
The stored mouse position mouse_vo_x/y are scaled (currently only for
vo_xv), but the position equality check compares between raw position
and scaled position.

Fix this by storing and checking the raw position instead. The raw
position is useful for the next commit.
2024-06-04 12:41:51 +02:00
nanahi 82c8a98884 input: begin VO dragging when moving mouse while left button is down
Will be used for the VO dragging deadzone.
2024-06-04 12:41:51 +02:00
Guido Cella 3f83671f20 input: prioritize builtin bindings matching longer key sequences
This fixes 2 different bugs:

- mp.add_key_binding('c', ...) taking priority over the builtin g-c
  binding.

This follows up 994a08f5a7 which fixed this within the same input
section. This fixes it across different input sections.

- mp.add_key_binding('g-c', ...) not taking priority over a c binding
  defined in input.conf.

This happened because is_builtin of bindings added with
mp.add_key_binding is true though they're not actually builtin.
2024-05-20 17:57:12 +02:00
sfan5 54c755b08d various: add missing checks for directory streams
All of this code opens a stream and expects to read stuff from a file.
But streams can also be directories and that has to be handled.
2024-05-15 22:45:18 +02:00
Guido Cella 994a08f5a7 input: fix builtin sequence bindings
If g-p is a builtin binding and p is bound in input.conf, pressing g-p
triggers the p binding. Fix this by searching for builtin bindings that
match a longer key sequence even after a user-defined binding has been
found.

Even after changing the condition from >= to > bindings of the same key
defined later in input.conf are still preferred over earlier ones,
because bind_keys() overwrites duplicate bindings. Bindings defined by
later mp.add_key_binding calls are also still preferred.
2024-05-12 23:13:48 +02:00
Kacper Michajłow 5cf0da2a6a various: remove unused sys/time.h include 2024-05-06 22:01:17 +02:00
Kacper Michajłow 18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
nanahi 89aa10de24 input: add MP_TOUCH_RELEASE_ALL
Release all touch points. Used by some VOs like Wayland touch cancel
event.
2024-05-03 16:14:03 +02:00
nanahi 77809faea1 input: add --input-touch-emulate-mouse option
This adds --input-touch-emulate-mouse option, which controls whether to
enable legacy touch handling where touch inputs are emulated as mouse
inputs. This establishes a primary touch point (the one with the lowest
index) as the emulated mouse position, and MBTN_LEFT up/down with the
appearance of the first touch point and the disappearance of the last
touch point.

This fixes some problems with touch handling on Wayland, for example
attempting to pinch results in a double click.
2024-05-03 16:14:03 +02:00
nanahi 28a4fb8e4e input: add multitouch support functions
The goal of multitouch support is to interpret as little as possible:
mpv just stores the touch point information and makes the position
available for query. Does not participate in the deprecated input section
system.

The API is modeled after the common part of the touch input APIs of
Win32, X11, and Wayland, to make sure the platform-specific implementations
are as simple as possible.
2024-05-03 16:14:03 +02:00