@@ -69,30 +69,6 @@ LRESULT inline MouseCatcherThread::MouseCallBackProc(int nCode, WPARAM wParam, L
6969 bool isRight = wParam==WM_RBUTTONDOWN;
7070 int iMSecs = m_ClickTimer.elapsed ();
7171 m_ClickTimer.restart ();
72-
73-
74- if (isMouseHoldAutoSelectionMode ())
75- {
76- QTimer *t = new QTimer ();
77- t->setSingleShot (true );
78- t->setInterval (getMouseHoldingDelay ());
79- t->moveToThread (this );
80- connect (this , SIGNAL (mouse_up ()), t, SLOT (stop ()));
81- connect (this , SIGNAL (mouse_up ()), t, SLOT (deleteLater ()));
82-
83- connect (this , SIGNAL (finished ()), t, SLOT (stop ()));
84- connect (this , SIGNAL (finished ()), t, SLOT (deleteLater ()));
85-
86-
87- connect (t, &QTimer::timeout, [this ](){
88-
89- setSelectionMode (true );
90- m_iToggled=true ;
91- });
92-
93-
94- t->start ();
95- }
9672 bool needLog = isLoggingStarted ();
9773
9874 if (getDelay ()>=iMSecs)
@@ -106,25 +82,50 @@ LRESULT inline MouseCatcherThread::MouseCallBackProc(int nCode, WPARAM wParam, L
10682 emit delay (iMSecs, false , isRight);
10783 }
10884
109- if (m_iToggled && wParam==WM_LBUTTONDOWN)
110- {
111- m_iToggled=!m_iToggled;
112-
113- POINT p;
114- GetCursorPos (&p);
115- INPUT ip;
116- memset (&ip, 0 , sizeof (INPUT));
117- ip.type = INPUT_MOUSE;
118- ip.mi .dx = p.x ;
119- ip.mi .dy = p.y ;
120- ip.mi .dwFlags = MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE;
121- SendInput (1 , &ip, sizeof (INPUT));
122- setSelectionMode (false );
123- return BLOCK_CALL;
124- }
125- else if (isSelectionMode ())
85+ if (!isRight)
12686 {
127- m_iToggled=!m_iToggled;
87+ if (m_iToggled)
88+ {
89+ m_iToggled=false ;
90+
91+ POINT p;
92+ GetCursorPos (&p);
93+ INPUT ip;
94+ memset (&ip, 0 , sizeof (INPUT));
95+ ip.type = INPUT_MOUSE;
96+ ip.mi .dx = p.x ;
97+ ip.mi .dy = p.y ;
98+ ip.mi .dwFlags = MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE;
99+ SendInput (1 , &ip, sizeof (INPUT));
100+ setSelectionMode (false );
101+ return BLOCK_CALL;
102+ }
103+ else if (isSelectionMode ())
104+ {
105+ m_iToggled=true ;
106+ }
107+ else if (isMouseHoldAutoSelectionMode ())
108+ {
109+
110+ QTimer *t = new QTimer ();
111+ t->setSingleShot (true );
112+ t->setInterval (getMouseHoldingDelay ());
113+ t->moveToThread (this );
114+ connect (this , SIGNAL (mouse_up ()), t, SLOT (stop ()));
115+ connect (this , SIGNAL (mouse_up ()), t, SLOT (deleteLater ()));
116+
117+ connect (this , SIGNAL (finished ()), t, SLOT (stop ()));
118+ connect (this , SIGNAL (finished ()), t, SLOT (deleteLater ()));
119+
120+
121+ connect (t, &QTimer::timeout, [this ](){
122+ setSelectionMode (true );
123+ m_iToggled=true ;
124+ });
125+
126+
127+ t->start ();
128+ }
128129 }
129130 }
130131 break ;
@@ -133,16 +134,20 @@ LRESULT inline MouseCatcherThread::MouseCallBackProc(int nCode, WPARAM wParam, L
133134 {
134135 if (isStarted ())
135136 {
136- if (m_iToggled && wParam==WM_LBUTTONUP)
137+ short index = short (wParam==WM_RBUTTONUP);
138+ if ((m_iToggled || isSelectionMode ()) && index==0 )
137139 {
140+ if (iBlockMouseButtonUps[index]>0 )
141+ {
142+ --iBlockMouseButtonUps[index];
143+ }
138144 return BLOCK_CALL;
139145 }
140146 else
141147 {
142- int index = (int )wParam==WM_RBUTTONUP;
143148 if (iBlockMouseButtonUps[index]>0 )
144149 {
145- iBlockMouseButtonUps[index]-- ;
150+ -- iBlockMouseButtonUps[index];
146151 return BLOCK_CALL;
147152 }
148153 else if (isMouseHoldAutoSelectionMode ())
0 commit comments