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
120120 int last_doubleclick_key_down;
121121 double last_doubleclick_time;
122122
123+ // VO dragging state
124+ bool dragging_button_down;
125+
123126 // Mouse position on the consumer side (as command.c sees it)
124127 int mouse_x, mouse_y;
125128 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
733736 if (code == MP_INPUT_RELEASE_ALL) {
734737 MP_TRACE(ictx, "release all\n");
735738 release_down_cmd(ictx, false);
739+ ictx->dragging_button_down = false;
736740 return;
737741 }
738742 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
771775 1, 1);
772776 } else if (code == MP_MBTN_LEFT) {
773777 // 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;
777780 }
778781 ictx->last_doubleclick_key_down = code;
779782 ictx->last_doubleclick_time = now;
780783 }
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+ }
781791 }
782792
783793 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
894904 queue_cmd(ictx, cmd);
895905 }
896906 }
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+ }
897914 }
898915
899916 void 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