From ca6e26399fd6d6e9b6a0e324cc9a8d18d5358bd4 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Tue, 11 Mar 2025 18:35:49 -0400 Subject: [PATCH] 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. --- input/cmd.h | 1 + input/input.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/input/cmd.h b/input/cmd.h index 239404725a..71635939a0 100644 --- a/input/cmd.h +++ b/input/cmd.h @@ -113,6 +113,7 @@ typedef struct mp_cmd { bool is_mouse_button : 1; bool repeated : 1; bool mouse_move : 1; + bool notify_event : 1; bool canceled : 1; bool coalesce : 1; int mouse_x, mouse_y; diff --git a/input/input.c b/input/input.c index cffe8ccca8..4cf7c43acd 100644 --- a/input/input.c +++ b/input/input.c @@ -775,6 +775,8 @@ static void feed_key(struct input_ctx *ictx, int code, double scale, mp_cmd_t *cmd = get_cmd_from_keys(ictx, (bstr){0}, code); if (!cmd) // queue dummy cmd so that mouse-pos can notify observers cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), ""); + if (cmd) + cmd->notify_event = true; queue_cmd(ictx, cmd); return; } @@ -921,6 +923,7 @@ static void set_mouse_pos(struct input_ctx *ictx, int x, int y, bool quiet) if (cmd) { cmd->mouse_move = true; + cmd->notify_event = true; cmd->mouse_x = x; cmd->mouse_y = y; if (should_drop_cmd(ictx, cmd)) { @@ -981,6 +984,8 @@ static void notify_touch_update(struct input_ctx *ictx) { // queue dummy cmd so that touch-pos can notify observers mp_cmd_t *cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), ""); + if (cmd) + cmd->notify_event = true; queue_cmd(ictx, cmd); }