Skip to content

Commit a8befca

Browse files
committed
Add One-Hand mice wheel scroll diff and merge (WinMerge#2435) (8). Remove CMouseHook::TimerProc()
1 parent 054a341 commit a8befca

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

Src/DirView.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include "SyntaxColors.h"
5050
#include "Shell.h"
5151
#include "DirTravel.h"
52-
#include "MouseHook.h"
5352
#include <numeric>
5453
#include <functional>
5554

@@ -639,8 +638,6 @@ void CDirView::Redisplay()
639638
*/
640639
void CDirView::OnContextMenu(CWnd*, CPoint point)
641640
{
642-
if (CMouseHook::IsRightWheelScrolling())
643-
return;
644641
if (GetListCtrl().GetItemCount() == 0)
645642
return;
646643
// Make sure window is active

Src/MergeEditView.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "Shell.h"
3434
#include "SelectPluginDlg.h"
3535
#include "Constants.h"
36-
#include "MouseHook.h"
3736

3837
#ifdef _DEBUG
3938
#define new DEBUG_NEW
@@ -2869,9 +2868,6 @@ void CMergeEditView::OnUpdateEditReplace(CCmdUI* pCmdUI)
28692868
*/
28702869
void CMergeEditView::OnContextMenu(CWnd* pWnd, CPoint point)
28712870
{
2872-
if (CMouseHook::IsRightWheelScrolling())
2873-
return;
2874-
28752871
CRect rect;
28762872
GetClientRect(rect);
28772873
ClientToScreen(rect);

Src/MouseHook.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#include <StdAfx.h>
22
#include "MouseHook.h"
33

4-
void CALLBACK CMouseHook::TimerProc(HWND unnamedParam1, UINT unnamedParam2, UINT_PTR id, DWORD unnamedParam4HWND)
5-
{
6-
KillTimer(nullptr, id);
7-
EndMenu();
8-
m_bIgnoreRBUp = false;
9-
}
10-
114
LRESULT CALLBACK CMouseHook::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
125
{
136
if (nCode < 0)
147
return CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);
158

16-
if (wParam == WM_RBUTTONDOWN)
9+
if (wParam == WM_LBUTTONDOWN)
10+
{
11+
m_bIgnoreRBUp = false;
12+
}
13+
else if (wParam == WM_RBUTTONDOWN)
1714
{
1815
m_bRButtonDown = true;
1916
}
@@ -22,9 +19,8 @@ LRESULT CALLBACK CMouseHook::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
2219
m_bRButtonDown = false;
2320
if (m_bIgnoreRBUp)
2421
{
25-
LRESULT result = CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);
26-
SetTimer(nullptr, 0, USER_TIMER_MINIMUM, TimerProc);
27-
return result;
22+
m_bIgnoreRBUp = false;
23+
return 1;
2824
}
2925
}
3026
else if (wParam == WM_MOUSEWHEEL)
@@ -172,7 +168,7 @@ LRESULT CALLBACK CMouseHook::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
172168

173169
void CMouseHook::SetMouseHook()
174170
{
175-
m_hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, GetModuleHandle(nullptr), GetCurrentThreadId());
171+
m_hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, AfxGetInstanceHandle(), GetCurrentThreadId());
176172
}
177173

178174
void CMouseHook::UnhookMouseHook()

Src/MouseHook.h

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class CMouseHook
66
static bool IsRightWheelScrolling() { return m_bIgnoreRBUp; }
77
private:
88
static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
9-
static void CALLBACK TimerProc(HWND unnamedParam1, UINT unnamedParam2, UINT_PTR id, DWORD unnamedParam4HWND);
109
inline static HHOOK m_hMouseHook;
1110
inline static bool m_bIgnoreRBUp;
1211
inline static bool m_bRButtonDown;

0 commit comments

Comments
 (0)