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.
This commit is contained in:
nanahi
2025-03-11 18:35:49 -04:00
committed by Kacper Michajłow
parent f676a9ff20
commit ca6e26399f
2 changed files with 6 additions and 0 deletions

View File

@@ -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;

View File

@@ -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"), "<internal>");
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"), "<internal>");
if (cmd)
cmd->notify_event = true;
queue_cmd(ictx, cmd);
}