mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
a8d95fd51a
commit
de97cb0964
|
@ -112,6 +112,7 @@ typedef struct mp_cmd {
|
||||||
bool is_mouse_button : 1;
|
bool is_mouse_button : 1;
|
||||||
bool repeated : 1;
|
bool repeated : 1;
|
||||||
bool mouse_move : 1;
|
bool mouse_move : 1;
|
||||||
|
bool canceled : 1;
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
struct mp_cmd *queue_next;
|
struct mp_cmd *queue_next;
|
||||||
double scale; // for scaling numeric arguments
|
double scale; // for scaling numeric arguments
|
||||||
|
|
|
@ -551,7 +551,8 @@ static void update_mouse_section(struct input_ctx *ictx)
|
||||||
// If the drop_current parameter is set to true, then don't send the key-up
|
// If the drop_current parameter is set to true, then don't send the key-up
|
||||||
// command. Unless we've already sent a key-down event, in which case the
|
// command. Unless we've already sent a key-down event, in which case the
|
||||||
// input receiver (the player) must get a key-up event, or it would get stuck
|
// input receiver (the player) must get a key-up event, or it would get stuck
|
||||||
// thinking a key is still held down.
|
// thinking a key is still held down. In this case, mark the command as
|
||||||
|
// canceled so that it can be distinguished from a normally triggered command.
|
||||||
static void release_down_cmd(struct input_ctx *ictx, bool drop_current)
|
static void release_down_cmd(struct input_ctx *ictx, bool drop_current)
|
||||||
{
|
{
|
||||||
if (ictx->current_down_cmd && ictx->current_down_cmd->emit_on_up &&
|
if (ictx->current_down_cmd && ictx->current_down_cmd->emit_on_up &&
|
||||||
|
@ -559,6 +560,8 @@ static void release_down_cmd(struct input_ctx *ictx, bool drop_current)
|
||||||
{
|
{
|
||||||
memset(ictx->key_history, 0, sizeof(ictx->key_history));
|
memset(ictx->key_history, 0, sizeof(ictx->key_history));
|
||||||
ictx->current_down_cmd->is_up = true;
|
ictx->current_down_cmd->is_up = true;
|
||||||
|
if (drop_current)
|
||||||
|
ictx->current_down_cmd->canceled = true;
|
||||||
queue_cmd(ictx, ictx->current_down_cmd);
|
queue_cmd(ictx, ictx->current_down_cmd);
|
||||||
} else {
|
} else {
|
||||||
talloc_free(ictx->current_down_cmd);
|
talloc_free(ictx->current_down_cmd);
|
||||||
|
|
Loading…
Reference in New Issue