Skip to content

Commit

Permalink
Optimize mouse hook function
Browse files Browse the repository at this point in the history
  • Loading branch information
In-line committed Jul 3, 2016
1 parent e7ca2f6 commit 507d0e0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
4 changes: 2 additions & 2 deletions DoubleClickFix.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.6.1, 2016-06-30T14:46:45. -->
<!-- Written by QtCreator 3.6.1, 2016-07-03T11:11:18. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -61,7 +61,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.6.0 MSVC2013 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.6.0 MSVC2013 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.56.win32_msvc2013_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<enum>Qt::NoFocus</enum>
</property>
<property name="windowTitle">
<string>QDoubleClickFix Beta 0.7.1</string>
<string>QDoubleClickFix Beta 0.7.2</string>
</property>
<property name="windowIcon">
<iconset resource="basic_resources.qrc">
Expand Down
8 changes: 4 additions & 4 deletions meta_data.rc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ IDI_ICON1 ICON "icon.ico"

#include <windows.h>

#define VER_FILEVERSION 0,7,1
#define VER_FILEVERSION_STR "0.7.1.0\0"
#define VER_PRODUCTVERSION 0,7,1
#define VER_PRODUCTVERSION_STR "0.7.1\0"
#define VER_FILEVERSION 0,7,2
#define VER_FILEVERSION_STR "0.7.2.0\0"
#define VER_PRODUCTVERSION 0,7,2
#define VER_PRODUCTVERSION_STR "0.7.2\0"
#define VER_FILEDESCRIPTION_STR "Double Click Problem Fixer Tool"
#define VER_INTERNALNAME_STR "DoubleClickFix"
#define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2016 Alik Aslanyan"
Expand Down
95 changes: 50 additions & 45 deletions mousecatcherthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,6 @@ LRESULT inline MouseCatcherThread::MouseCallBackProc(int nCode, WPARAM wParam, L
bool isRight = wParam==WM_RBUTTONDOWN;
int iMSecs = m_ClickTimer.elapsed();
m_ClickTimer.restart();


if(isMouseHoldAutoSelectionMode())
{
QTimer *t = new QTimer();
t->setSingleShot(true);
t->setInterval(getMouseHoldingDelay());
t->moveToThread(this);
connect(this, SIGNAL(mouse_up()), t, SLOT(stop()));
connect(this, SIGNAL(mouse_up()), t, SLOT(deleteLater()));

connect(this, SIGNAL(finished()), t, SLOT(stop()));
connect(this, SIGNAL(finished()), t, SLOT(deleteLater()));


connect(t, &QTimer::timeout, [this](){

setSelectionMode(true);
m_iToggled=true;
});


t->start();
}
bool needLog = isLoggingStarted();

if(getDelay()>=iMSecs)
Expand All @@ -106,25 +82,50 @@ LRESULT inline MouseCatcherThread::MouseCallBackProc(int nCode, WPARAM wParam, L
emit delay(iMSecs, false, isRight);
}

if(m_iToggled && wParam==WM_LBUTTONDOWN)
{
m_iToggled=!m_iToggled;

POINT p;
GetCursorPos(&p);
INPUT ip;
memset(&ip, 0, sizeof(INPUT));
ip.type = INPUT_MOUSE;
ip.mi.dx = p.x;
ip.mi.dy = p.y;
ip.mi.dwFlags = MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE;
SendInput(1, &ip, sizeof(INPUT));
setSelectionMode(false);
return BLOCK_CALL;
}
else if(isSelectionMode())
if(!isRight)
{
m_iToggled=!m_iToggled;
if(m_iToggled)
{
m_iToggled=false;

POINT p;
GetCursorPos(&p);
INPUT ip;
memset(&ip, 0, sizeof(INPUT));
ip.type = INPUT_MOUSE;
ip.mi.dx = p.x;
ip.mi.dy = p.y;
ip.mi.dwFlags = MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE;
SendInput(1, &ip, sizeof(INPUT));
setSelectionMode(false);
return BLOCK_CALL;
}
else if(isSelectionMode())
{
m_iToggled=true;
}
else if(isMouseHoldAutoSelectionMode())
{

QTimer *t = new QTimer();
t->setSingleShot(true);
t->setInterval(getMouseHoldingDelay());
t->moveToThread(this);
connect(this, SIGNAL(mouse_up()), t, SLOT(stop()));
connect(this, SIGNAL(mouse_up()), t, SLOT(deleteLater()));

connect(this, SIGNAL(finished()), t, SLOT(stop()));
connect(this, SIGNAL(finished()), t, SLOT(deleteLater()));


connect(t, &QTimer::timeout, [this](){
setSelectionMode(true);
m_iToggled=true;
});


t->start();
}
}
}
break;
Expand All @@ -133,16 +134,20 @@ LRESULT inline MouseCatcherThread::MouseCallBackProc(int nCode, WPARAM wParam, L
{
if(isStarted())
{
if(m_iToggled && wParam==WM_LBUTTONUP)
short index = short(wParam==WM_RBUTTONUP);
if((m_iToggled || isSelectionMode()) && index==0)
{
if(iBlockMouseButtonUps[index]>0)
{
--iBlockMouseButtonUps[index];
}
return BLOCK_CALL;
}
else
{
int index = (int)wParam==WM_RBUTTONUP;
if(iBlockMouseButtonUps[index]>0)
{
iBlockMouseButtonUps[index]--;
--iBlockMouseButtonUps[index];
return BLOCK_CALL;
}
else if(isMouseHoldAutoSelectionMode())
Expand Down

0 comments on commit 507d0e0

Please sign in to comment.