[FancyZones] Changed Shift key capture method (#4274)

* Used windows hook to capture shift key instead of getting state of key on window move
This commit is contained in:
Yevhenii Holovachov
2020-06-17 16:06:16 +03:00
committed by GitHub
parent 698e5ec6ea
commit da38e6a23d
7 changed files with 127 additions and 13 deletions

View File

@@ -18,6 +18,7 @@
#include <interface/win_hook_event_data.h>
#include <lib/SecondaryMouseButtonsHook.h>
#include <lib/ShiftKeyHook.h>
enum class DisplayChangeType
{
@@ -34,7 +35,8 @@ public:
m_hinstance(hinstance),
m_settings(settings),
m_mouseHook(std::bind(&FancyZones::OnMouseDown, this)),
m_windowMoveHandler(settings, &m_mouseHook)
m_shiftHook(std::bind(&FancyZones::OnShiftChangeState, this, std::placeholders::_1)),
m_windowMoveHandler(settings, &m_mouseHook, &m_shiftHook)
{
m_settings->SetCallback(this);
}
@@ -47,12 +49,18 @@ public:
void OnMouseDown() noexcept
{
std::unique_lock writeLock(m_lock);
m_windowMoveHandler.OnMouseDown();
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
}
void OnShiftChangeState(bool state) noexcept
{
m_windowMoveHandler.OnShiftChangeState(state);
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
}
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen) noexcept
{
std::unique_lock writeLock(m_lock);
@@ -230,6 +238,7 @@ private:
WindowMoveHandler m_windowMoveHandler;
MonitorWorkAreaHandler m_workAreaHandler;
SecondaryMouseButtonsHook m_mouseHook;
ShiftKeyHook m_shiftHook;
winrt::com_ptr<IFancyZonesSettings> m_settings{};
GUID m_previousDesktopId{}; // UUID of previously active virtual desktop.