History

input: begin VO dragging when moving mouse while left button is down

Will be used for the VO dragging deadzone.

nanahi committed 2 years ago

Commit 82c8a981 parent 23d9c8d1 file · +20 −3Browse files

Unified · Split

input/input.c+20−3
@@ -120,6 +120,9 @@ struct input_ctx { · 119 unmodified lines
120 int last_doubleclick_key_down;120 int last_doubleclick_key_down;
121 double last_doubleclick_time;121 double last_doubleclick_time;
122 122
123 // VO dragging state
124 bool dragging_button_down;
125
123 // Mouse position on the consumer side (as command.c sees it)126 // Mouse position on the consumer side (as command.c sees it)
124 int mouse_x, mouse_y;127 int mouse_x, mouse_y;
125 int mouse_hover; // updated on mouse-enter/leave128 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 if (code == MP_INPUT_RELEASE_ALL) {736 if (code == MP_INPUT_RELEASE_ALL) {
734 MP_TRACE(ictx, "release all\n");737 MP_TRACE(ictx, "release all\n");
735 release_down_cmd(ictx, false);738 release_down_cmd(ictx, false);
739 ictx->dragging_button_down = false;
736 return;740 return;
737 }741 }
738 if (code == MP_TOUCH_RELEASE_ALL) {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 1, 1);775 1, 1);
772 } else if (code == MP_MBTN_LEFT) {776 } else if (code == MP_MBTN_LEFT) {
773 // This is a mouse left botton down event which isn't part of a doubleclick.777 // This is a mouse left botton down event which isn't part of a doubleclick.
774 // Initialize vo dragging in this case.778 // Mark the dragging mouse button down in this case.
775 mp_cmd_t *cmd = mp_input_parse_cmd(ictx, bstr0("begin-vo-dragging"), "<internal>");779 ictx->dragging_button_down = true;
776 queue_cmd(ictx, cmd);
777 }780 }
778 ictx->last_doubleclick_key_down = code;781 ictx->last_doubleclick_key_down = code;
779 ictx->last_doubleclick_time = now;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
783void mp_input_put_key(struct input_ctx *ictx, int code)793void 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 queue_cmd(ictx, cmd);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
899void mp_input_set_mouse_pos_artificial(struct input_ctx *ictx, int x, int y)916void mp_input_set_mouse_pos_artificial(struct input_ctx *ictx, int x, int y)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t