Trivial.
Showing the changes to input (2 of 2 files). Show all
Unified · Split
| @@ -598,7 +598,8 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, · 597 unmodified lines | ||
| 598 | 598 | int scale_units) |
| 599 | 599 | { |
| 600 | 600 | int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP); |
| 601 | − code = code & ~(unsigned)state; | |
| 601 | + bool no_emit = code & MP_KEY_STATE_SET_ONLY; | |
| 602 | + code = code & ~(unsigned)(state | MP_KEY_STATE_SET_ONLY); | |
| 602 | 603 | |
| 603 | 604 | if (mp_msg_test(ictx->log, MSGL_TRACE)) { |
| 604 | 605 | char *key = mp_input_get_key_name(code); |
| @@ -648,9 +649,10 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, · 43 unmodified lines | ||
| 648 | 649 | return; |
| 649 | 650 | |
| 650 | 651 | // Don't emit a command on key-down if the key is designed to emit commands |
| 651 | − // on key-up (like mouse buttons). Also, if the command specifically should | |
| 652 | − // be sent both on key down and key up, still emit the command. | |
| 653 | − if (cmd->emit_on_up && !cmd->def->on_updown) { | |
| 652 | + // on key-up (like mouse buttons), or setting key state only without emitting commands. | |
| 653 | + // Also, if the command specifically should be sent both on key down and key up, | |
| 654 | + // still emit the command. | |
| 655 | + if ((cmd->emit_on_up && !cmd->def->on_updown) || no_emit) { | |
| 654 | 656 | talloc_free(cmd); |
| 655 | 657 | return; |
| 656 | 658 | } |
| @@ -251,6 +251,9 @@ · 250 unmodified lines | ||
| 251 | 251 | // or don't use MP_KEY_STATE_DOWN in the first place. |
| 252 | 252 | #define MP_KEY_STATE_UP (1u<<29) |
| 253 | 253 | |
| 254 | +// Only set the key state without triggering key bindings. | |
| 255 | +#define MP_KEY_STATE_SET_ONLY (1u<<30) | |
| 256 | + | |
| 254 | 257 | #define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \ |
| 255 | 258 | MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \ |
| 256 | 259 | MP_KEY_STATE_DOWN | MP_KEY_STATE_UP) |