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.
This commit is contained in:
nanahi 2024-05-27 23:16:25 -04:00 committed by Kacper Michajłow
parent 349aac462e
commit 49b5e6d042
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1 @@
add `--input-builtin-dragging` option

View File

@ -4139,6 +4139,12 @@ Input
option is applied only during (lib)mpv initialization, and if disabled then it option is applied only during (lib)mpv initialization, and if disabled then it
will not be not possible to enable them later. May be useful to libmpv clients. will not be not possible to enable them later. May be useful to libmpv clients.
``--input-builtin-dragging=<yes|no>``
Enable the built-in window-dragging behavior (default: yes). Setting it to no
disables the built-in dragging behavior. Note that unlike the ``window-dragging``
option, this option only affects VOs which support the ``begin-vo-dragging``
command, and does not disable window dragging initialized with the command.
``--input-cmdlist`` ``--input-cmdlist``
Prints all commands that can be bound to keys. Prints all commands that can be bound to keys.

View File

@ -187,6 +187,7 @@ struct input_opts {
bool use_media_keys; bool use_media_keys;
bool default_bindings; bool default_bindings;
bool builtin_bindings; bool builtin_bindings;
bool builtin_dragging;
bool enable_mouse_movements; bool enable_mouse_movements;
bool vo_key_input; bool vo_key_input;
bool test; bool test;
@ -204,6 +205,7 @@ const struct m_sub_options input_config = {
{"input-cmdlist", OPT_PRINT(mp_print_cmd_list)}, {"input-cmdlist", OPT_PRINT(mp_print_cmd_list)},
{"input-default-bindings", OPT_BOOL(default_bindings)}, {"input-default-bindings", OPT_BOOL(default_bindings)},
{"input-builtin-bindings", OPT_BOOL(builtin_bindings)}, {"input-builtin-bindings", OPT_BOOL(builtin_bindings)},
{"input-builtin-dragging", OPT_BOOL(builtin_dragging)},
{"input-test", OPT_BOOL(test)}, {"input-test", OPT_BOOL(test)},
{"input-doubleclick-time", OPT_INT(doubleclick_time), {"input-doubleclick-time", OPT_INT(doubleclick_time),
M_RANGE(0, 1000)}, M_RANGE(0, 1000)},
@ -233,6 +235,7 @@ const struct m_sub_options input_config = {
.use_media_keys = true, .use_media_keys = true,
.default_bindings = true, .default_bindings = true,
.builtin_bindings = true, .builtin_bindings = true,
.builtin_dragging = true,
.vo_key_input = true, .vo_key_input = true,
.allow_win_drag = true, .allow_win_drag = true,
.preprocess_wheel = true, .preprocess_wheel = true,
@ -919,7 +922,9 @@ static void set_mouse_pos(struct input_ctx *ictx, int x, int y)
bool mouse_outside_dragging_deadzone = bool mouse_outside_dragging_deadzone =
abs(ictx->mouse_raw_x - ictx->mouse_drag_x) >= ictx->opts->dragging_deadzone || abs(ictx->mouse_raw_x - ictx->mouse_drag_x) >= ictx->opts->dragging_deadzone ||
abs(ictx->mouse_raw_y - ictx->mouse_drag_y) >= ictx->opts->dragging_deadzone; abs(ictx->mouse_raw_y - ictx->mouse_drag_y) >= ictx->opts->dragging_deadzone;
if (ictx->dragging_button_down && mouse_outside_dragging_deadzone) { if (ictx->dragging_button_down && mouse_outside_dragging_deadzone &&
ictx->opts->builtin_dragging)
{
// Begin built-in VO dragging if the mouse moves while the dragging button is down. // Begin built-in VO dragging if the mouse moves while the dragging button is down.
ictx->dragging_button_down = false; ictx->dragging_button_down = false;
// Prevent activation of MBTN_LEFT key binding if VO dragging begins. // Prevent activation of MBTN_LEFT key binding if VO dragging begins.