Will be used for the VO dragging deadzone.
Unified · Split
| @@ -120,6 +120,9 @@ struct input_ctx { · 119 unmodified lines | ||
| 120 | 120 | int last_doubleclick_key_down; |
| 121 | 121 | double last_doubleclick_time; |
| 122 | 122 | |
| 123 | + // VO dragging state | |
| 124 | + bool dragging_button_down; | |
| 125 | + | |
| 123 | 126 | // Mouse position on the consumer side (as command.c sees it) |
| 124 | 127 | int mouse_x, mouse_y; |
| 125 | 128 | int mouse_hover; // updated on mouse-enter/leave |
| @@ -733,6 +736,7 @@ static void feed_key(struct input_ctx *ictx, int code, double scale, · 607 unmodified lines | ||
| 733 | 736 | if (code == MP_INPUT_RELEASE_ALL) { |
| 734 | 737 | MP_TRACE(ictx, "release all\n"); |
| 735 | 738 | release_down_cmd(ictx, false); |
| 739 | + ictx->dragging_button_down = false; | |
| 736 | 740 | return; |
| 737 | 741 | } |
| 738 | 742 | if (code == MP_TOUCH_RELEASE_ALL) { |
| @@ -771,13 +775,19 @@ static void feed_key(struct input_ctx *ictx, int code, double scale, · 32 unmodified lines | ||
| 771 | 775 | 1, 1); |
| 772 | 776 | } else if (code == MP_MBTN_LEFT) { |
| 773 | 777 | // This is a mouse left botton down event which isn't part of a doubleclick. |
| 774 | − // Initialize vo dragging in this case. | |
| 775 | − mp_cmd_t *cmd = mp_input_parse_cmd(ictx, bstr0("begin-vo-dragging"), "<internal>"); | |
| 776 | − queue_cmd(ictx, cmd); | |
| 778 | + // Mark the dragging mouse button down in this case. | |
| 779 | + ictx->dragging_button_down = true; | |
| 777 | 780 | } |
| 778 | 781 | ictx->last_doubleclick_key_down = code; |
| 779 | 782 | ictx->last_doubleclick_time = now; |
| 780 | 783 | } |
| 784 | + if (code & MP_KEY_STATE_UP) { | |
| 785 | + code &= ~MP_KEY_STATE_UP; | |
| 786 | + if (code == MP_MBTN_LEFT) { | |
| 787 | + // This is a mouse left botton up event. Mark the dragging mouse button up. | |
| 788 | + ictx->dragging_button_down = false; | |
| 789 | + } | |
| 790 | + } | |
| 781 | 791 | } |
| 782 | 792 | |
| 783 | 793 | void mp_input_put_key(struct input_ctx *ictx, int code) |
| @@ -894,6 +904,13 @@ static void set_mouse_pos(struct input_ctx *ictx, int x, int y) · 110 unmodified lines | ||
| 894 | 904 | queue_cmd(ictx, cmd); |
| 895 | 905 | } |
| 896 | 906 | } |
| 907 | + | |
| 908 | + if (ictx->dragging_button_down) { | |
| 909 | + // Begin built-in VO dragging if the mouse moves while the dragging button is down. | |
| 910 | + ictx->dragging_button_down = false; | |
| 911 | + mp_cmd_t *drag_cmd = mp_input_parse_cmd(ictx, bstr0("begin-vo-dragging"), "<internal>"); | |
| 912 | + queue_cmd(ictx, drag_cmd); | |
| 913 | + } | |
| 897 | 914 | } |
| 898 | 915 | |
| 899 | 916 | void mp_input_set_mouse_pos_artificial(struct input_ctx *ictx, int x, int y) |