From bacd06a1eb26a7d9d890bd6fd640efec2d20a094 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Wed, 15 Jan 2025 23:20:16 -0500
Subject: [PATCH] Don't enter the drag start on a move event unless drag is
 enabled.

Likely fixes difficulties pasting in SyncTERM.
Probably want to define some minimum amount you need to move to
trigger dragging.
---
 src/conio/mouse.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/conio/mouse.c b/src/conio/mouse.c
index fc5added62..640aa00cac 100644
--- a/src/conio/mouse.c
+++ b/src/conio/mouse.c
@@ -329,12 +329,16 @@ void ciolib_mouse_thread(void *data)
 						switch(state.button_state[but-1]) {
 							case MOUSE_NOSTATE:
 								if(state.buttonstate & CIOLIB_BUTTON(but)) {
+									if(!(mouse_events & UINT64_C(1)<<CIOLIB_BUTTON_DRAG_START(but)))
+										break;
 									add_outevent(CIOLIB_BUTTON_DRAG_START(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 									add_outevent(CIOLIB_BUTTON_DRAG_MOVE(but),in->x,in->y, in->x_res, in->y_res);
 									state.button_state[but-1]=MOUSE_DRAGSTARTED;
 								}
 								break;
 							case MOUSE_SINGLEPRESSED:
+								if(!(mouse_events & UINT64_C(1)<<CIOLIB_BUTTON_DRAG_START(but)))
+									break;
 								add_outevent(CIOLIB_BUTTON_DRAG_START(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_MOVE(but),in->x,in->y, in->x_res, in->y_res);
 								state.button_state[but-1]=MOUSE_DRAGSTARTED;
@@ -344,6 +348,8 @@ void ciolib_mouse_thread(void *data)
 								state.button_state[but-1]=MOUSE_NOSTATE;
 								break;
 							case MOUSE_DOUBLEPRESSED:
+								if(!(mouse_events & UINT64_C(1)<<CIOLIB_BUTTON_DRAG_START(but)))
+									break;
 								add_outevent(CIOLIB_BUTTON_CLICK(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_START(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_MOVE(but),in->x,in->y, in->x_res, in->y_res);
@@ -354,6 +360,8 @@ void ciolib_mouse_thread(void *data)
 								state.button_state[but-1]=MOUSE_NOSTATE;
 								break;
 							case MOUSE_TRIPLEPRESSED:
+								if(!(mouse_events & UINT64_C(1)<<CIOLIB_BUTTON_DRAG_START(but)))
+									break;
 								add_outevent(CIOLIB_BUTTON_DBL_CLICK(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_START(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_MOVE(but),in->x,in->y, in->x_res, in->y_res);
@@ -364,6 +372,8 @@ void ciolib_mouse_thread(void *data)
 								state.button_state[but-1]=MOUSE_NOSTATE;
 								break;
 							case MOUSE_QUADPRESSED:
+								if(!(mouse_events & UINT64_C(1)<<CIOLIB_BUTTON_DRAG_START(but)))
+									break;
 								add_outevent(CIOLIB_BUTTON_TRPL_CLICK(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_START(but),state.button_x[but-1],state.button_y[but-1],state.button_x_res[but-1],state.button_y_res[but-1]);
 								add_outevent(CIOLIB_BUTTON_DRAG_MOVE(but),in->x,in->y, in->x_res, in->y_res);
-- 
GitLab