-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FancyZones] Secondary mouse buttons click to toggle zones activation (…
…#3989) * Changed option name in settings, changed behaviour of zones activation by mouse to switch * Removed IsDragEnabled from ZoneWindow
- Loading branch information
1 parent
e6408a0
commit 8410d7b
Showing
12 changed files
with
134 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "pch.h" | ||
#include "SecondaryMouseButtonsHook.h" | ||
|
||
#pragma region public | ||
|
||
HHOOK SecondaryMouseButtonsHook::hHook = {}; | ||
std::function<void()> SecondaryMouseButtonsHook::callback = {}; | ||
|
||
SecondaryMouseButtonsHook::SecondaryMouseButtonsHook(std::function<void()> extCallback) | ||
{ | ||
callback = std::move(extCallback); | ||
hHook = SetWindowsHookEx(WH_MOUSE_LL, SecondaryMouseButtonsProc, GetModuleHandle(NULL), 0); | ||
} | ||
|
||
void SecondaryMouseButtonsHook::enable() | ||
{ | ||
if (!hHook) | ||
{ | ||
hHook = SetWindowsHookEx(WH_MOUSE_LL, SecondaryMouseButtonsProc, GetModuleHandle(NULL), 0); | ||
} | ||
} | ||
|
||
void SecondaryMouseButtonsHook::disable() | ||
{ | ||
if (hHook) | ||
{ | ||
UnhookWindowsHookEx(hHook); | ||
hHook = NULL; | ||
} | ||
} | ||
|
||
#pragma endregion | ||
|
||
#pragma region private | ||
|
||
LRESULT CALLBACK SecondaryMouseButtonsHook::SecondaryMouseButtonsProc(int nCode, WPARAM wParam, LPARAM lParam) | ||
{ | ||
if (nCode == HC_ACTION) | ||
{ | ||
if (wParam == (GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONDOWN : WM_RBUTTONDOWN) || wParam == WM_MBUTTONDOWN || wParam == WM_XBUTTONDOWN) | ||
{ | ||
callback(); | ||
} | ||
} | ||
return CallNextHookEx(hHook, nCode, wParam, lParam); | ||
} | ||
|
||
#pragma endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
|
||
class SecondaryMouseButtonsHook | ||
{ | ||
public: | ||
SecondaryMouseButtonsHook(std::function<void()>); | ||
void enable(); | ||
void disable(); | ||
|
||
private: | ||
static HHOOK hHook; | ||
static std::function<void()> callback; | ||
static LRESULT CALLBACK SecondaryMouseButtonsProc(int, WPARAM, LPARAM); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.