mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-04 11:59:07 +08:00
[FancyZones] Shift + StickyKeys behavior fix (#6039)
This commit is contained in:
parent
f64df97652
commit
845bb466c6
@ -17,7 +17,6 @@
|
|||||||
#include "MonitorWorkAreaHandler.h"
|
#include "MonitorWorkAreaHandler.h"
|
||||||
|
|
||||||
#include <lib/SecondaryMouseButtonsHook.h>
|
#include <lib/SecondaryMouseButtonsHook.h>
|
||||||
#include <lib/GenericKeyHook.h>
|
|
||||||
|
|
||||||
enum class DisplayChangeType
|
enum class DisplayChangeType
|
||||||
{
|
{
|
||||||
@ -46,10 +45,9 @@ public:
|
|||||||
FancyZones(HINSTANCE hinstance, const winrt::com_ptr<IFancyZonesSettings>& settings) noexcept :
|
FancyZones(HINSTANCE hinstance, const winrt::com_ptr<IFancyZonesSettings>& settings) noexcept :
|
||||||
m_hinstance(hinstance),
|
m_hinstance(hinstance),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
m_mouseHook(std::bind(&FancyZones::OnMouseDown, this)),
|
m_windowMoveHandler(settings, [this]() {
|
||||||
m_shiftHook(std::bind(&FancyZones::OnShiftChangeState, this, std::placeholders::_1)),
|
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
|
||||||
m_ctrlHook(std::bind(&FancyZones::OnCtrlChangeState, this, std::placeholders::_1)),
|
})
|
||||||
m_windowMoveHandler(settings, &m_mouseHook, &m_shiftHook, &m_ctrlHook)
|
|
||||||
{
|
{
|
||||||
m_settings->SetCallback(this);
|
m_settings->SetCallback(this);
|
||||||
}
|
}
|
||||||
@ -60,27 +58,6 @@ public:
|
|||||||
IFACEMETHODIMP_(void)
|
IFACEMETHODIMP_(void)
|
||||||
Destroy() noexcept;
|
Destroy() noexcept;
|
||||||
|
|
||||||
void OnMouseDown() noexcept
|
|
||||||
{
|
|
||||||
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 OnCtrlChangeState(bool state) noexcept
|
|
||||||
{
|
|
||||||
m_windowMoveHandler.OnCtrlChangeState(state);
|
|
||||||
|
|
||||||
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen) noexcept
|
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen) noexcept
|
||||||
{
|
{
|
||||||
std::unique_lock writeLock(m_lock);
|
std::unique_lock writeLock(m_lock);
|
||||||
@ -267,9 +244,6 @@ private:
|
|||||||
HWND m_window{};
|
HWND m_window{};
|
||||||
WindowMoveHandler m_windowMoveHandler;
|
WindowMoveHandler m_windowMoveHandler;
|
||||||
MonitorWorkAreaHandler m_workAreaHandler;
|
MonitorWorkAreaHandler m_workAreaHandler;
|
||||||
SecondaryMouseButtonsHook m_mouseHook;
|
|
||||||
ShiftKeyHook m_shiftHook;
|
|
||||||
CtrlKeyHook m_ctrlHook;
|
|
||||||
|
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings{};
|
winrt::com_ptr<IFancyZonesSettings> m_settings{};
|
||||||
GUID m_previousDesktopId{}; // UUID of previously active virtual desktop.
|
GUID m_previousDesktopId{}; // UUID of previously active virtual desktop.
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
<ClInclude Include="GenericKeyHook.h" />
|
<ClInclude Include="GenericKeyHook.h" />
|
||||||
<ClInclude Include="FancyZonesData.h" />
|
<ClInclude Include="FancyZonesData.h" />
|
||||||
<ClInclude Include="JsonHelpers.h" />
|
<ClInclude Include="JsonHelpers.h" />
|
||||||
|
<ClInclude Include="KeyState.h" />
|
||||||
<ClInclude Include="MonitorWorkAreaHandler.h" />
|
<ClInclude Include="MonitorWorkAreaHandler.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
@ -123,7 +124,6 @@
|
|||||||
<ClCompile Include="FancyZones.cpp" />
|
<ClCompile Include="FancyZones.cpp" />
|
||||||
<ClCompile Include="FancyZonesDataTypes.cpp" />
|
<ClCompile Include="FancyZonesDataTypes.cpp" />
|
||||||
<ClCompile Include="FancyZonesWinHookEventIDs.cpp" />
|
<ClCompile Include="FancyZonesWinHookEventIDs.cpp" />
|
||||||
<ClCompile Include="GenericKeyHook.cpp" />
|
|
||||||
<ClCompile Include="FancyZonesData.cpp" />
|
<ClCompile Include="FancyZonesData.cpp" />
|
||||||
<ClCompile Include="JsonHelpers.cpp" />
|
<ClCompile Include="JsonHelpers.cpp" />
|
||||||
<ClCompile Include="MonitorWorkAreaHandler.cpp" />
|
<ClCompile Include="MonitorWorkAreaHandler.cpp" />
|
||||||
|
@ -69,6 +69,9 @@
|
|||||||
<ClInclude Include="FancyZonesDataTypes.h">
|
<ClInclude Include="FancyZonesDataTypes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="KeyState.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="pch.cpp">
|
<ClCompile Include="pch.cpp">
|
||||||
@ -110,9 +113,6 @@
|
|||||||
<ClCompile Include="MonitorWorkAreaHandler.cpp">
|
<ClCompile Include="MonitorWorkAreaHandler.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="GenericKeyHook.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="FancyZonesData.cpp">
|
<ClCompile Include="FancyZonesData.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#include "pch.h"
|
|
||||||
#include "GenericKeyHook.h"
|
|
||||||
|
|
||||||
HHOOK ShiftKeyHook::hHook{};
|
|
||||||
std::function<void(bool)> ShiftKeyHook::callback{};
|
|
||||||
|
|
||||||
HHOOK CtrlKeyHook::hHook{};
|
|
||||||
std::function<void(bool)> CtrlKeyHook::callback{};
|
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
template<int... keys>
|
template<int... keys>
|
||||||
class GenericKeyHook
|
class GenericKeyHook
|
||||||
@ -38,8 +38,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HHOOK hHook;
|
inline static HHOOK hHook;
|
||||||
static std::function<void(bool)> callback;
|
inline static std::function<void(bool)> callback;
|
||||||
|
|
||||||
static LRESULT CALLBACK GenericKeyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK GenericKeyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@ -57,6 +57,3 @@ private:
|
|||||||
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
return CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef GenericKeyHook<VK_LSHIFT, VK_RSHIFT> ShiftKeyHook;
|
|
||||||
typedef GenericKeyHook<VK_LCONTROL, VK_RCONTROL> CtrlKeyHook;
|
|
||||||
|
52
src/modules/fancyzones/lib/KeyState.h
Normal file
52
src/modules/fancyzones/lib/KeyState.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GenericKeyHook.h"
|
||||||
|
|
||||||
|
template<int... keys>
|
||||||
|
class KeyState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyState(const std::function<void()>& callback) :
|
||||||
|
m_state(false),
|
||||||
|
m_hook(std::bind(&KeyState::onChangeState, this, std::placeholders::_1)),
|
||||||
|
m_updateCallback(callback)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool state() const noexcept { return m_state; }
|
||||||
|
|
||||||
|
inline void enable()
|
||||||
|
{
|
||||||
|
m_hook.enable();
|
||||||
|
m_state = (((GetAsyncKeyState(keys) & 0x8000) || ...));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void disable()
|
||||||
|
{
|
||||||
|
m_hook.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setState(bool state) noexcept
|
||||||
|
{
|
||||||
|
if (m_state != state)
|
||||||
|
{
|
||||||
|
m_state = state;
|
||||||
|
if (m_updateCallback)
|
||||||
|
{
|
||||||
|
m_updateCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline void onChangeState(bool state) noexcept
|
||||||
|
{
|
||||||
|
setState(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::atomic<bool> m_state;
|
||||||
|
GenericKeyHook<keys...> m_hook;
|
||||||
|
std::function<void()> m_updateCallback;
|
||||||
|
};
|
@ -13,6 +13,7 @@
|
|||||||
#include "lib/SecondaryMouseButtonsHook.h"
|
#include "lib/SecondaryMouseButtonsHook.h"
|
||||||
#include "lib/GenericKeyHook.h"
|
#include "lib/GenericKeyHook.h"
|
||||||
#include "lib/FancyZonesData.h"
|
#include "lib/FancyZonesData.h"
|
||||||
|
#include "lib/KeyState.h"
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@ -56,11 +57,13 @@ namespace WindowMoveHandlerUtils
|
|||||||
class WindowMoveHandlerPrivate
|
class WindowMoveHandlerPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindowMoveHandlerPrivate(const winrt::com_ptr<IFancyZonesSettings>& settings, SecondaryMouseButtonsHook* mouseHook, ShiftKeyHook* shiftHook, CtrlKeyHook* ctrlHook) :
|
WindowMoveHandlerPrivate(const winrt::com_ptr<IFancyZonesSettings>& settings, const std::function<void()>& keyUpdateCallback) :
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
m_mouseHook(mouseHook),
|
m_mouseState(false),
|
||||||
m_shiftHook(shiftHook),
|
m_mouseHook(std::bind(&WindowMoveHandlerPrivate::OnMouseDown, this)),
|
||||||
m_ctrlHook(ctrlHook)
|
m_shiftKeyState(keyUpdateCallback),
|
||||||
|
m_ctrlKeyState(keyUpdateCallback),
|
||||||
|
m_keyUpdateCallback(keyUpdateCallback)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +77,6 @@ public:
|
|||||||
return m_inMoveSize;
|
return m_inMoveSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMouseDown() noexcept;
|
|
||||||
void OnShiftChangeState(bool state) noexcept;
|
|
||||||
void OnCtrlChangeState(bool state) noexcept;
|
|
||||||
|
|
||||||
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
||||||
void MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
void MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
||||||
void MoveSizeEnd(HWND window, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
void MoveSizeEnd(HWND window, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
||||||
@ -93,19 +92,25 @@ private:
|
|||||||
void SetWindowTransparency(HWND window) noexcept;
|
void SetWindowTransparency(HWND window) noexcept;
|
||||||
void ResetWindowTransparency() noexcept;
|
void ResetWindowTransparency() noexcept;
|
||||||
|
|
||||||
|
inline void OnMouseDown() noexcept
|
||||||
|
{
|
||||||
|
m_mouseState = !m_mouseState;
|
||||||
|
m_keyUpdateCallback();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
winrt::com_ptr<IFancyZonesSettings> m_settings{};
|
winrt::com_ptr<IFancyZonesSettings> m_settings{};
|
||||||
SecondaryMouseButtonsHook* m_mouseHook{};
|
|
||||||
ShiftKeyHook* m_shiftHook{};
|
|
||||||
CtrlKeyHook* m_ctrlHook{};
|
|
||||||
|
|
||||||
HWND m_windowMoveSize{}; // The window that is being moved/sized
|
HWND m_windowMoveSize{}; // The window that is being moved/sized
|
||||||
bool m_inMoveSize{}; // Whether or not a move/size operation is currently active
|
bool m_inMoveSize{}; // Whether or not a move/size operation is currently active
|
||||||
winrt::com_ptr<IZoneWindow> m_zoneWindowMoveSize; // "Active" ZoneWindow, where the move/size is happening. Will update as drag moves between monitors.
|
winrt::com_ptr<IZoneWindow> m_zoneWindowMoveSize; // "Active" ZoneWindow, where the move/size is happening. Will update as drag moves between monitors.
|
||||||
bool m_dragEnabled{}; // True if we should be showing zone hints while dragging
|
bool m_dragEnabled{}; // True if we should be showing zone hints while dragging
|
||||||
bool m_secondaryMouseButtonState{}; // True when secondary mouse button was clicked after window was moved
|
|
||||||
bool m_shiftKeyState{}; // True when shift key was pressed after window was moved
|
std::atomic<bool> m_mouseState;
|
||||||
bool m_ctrlKeyState{}; // True when ctrl key was pressed after window was moved
|
SecondaryMouseButtonsHook m_mouseHook;
|
||||||
|
KeyState<VK_LSHIFT, VK_RSHIFT> m_shiftKeyState;
|
||||||
|
KeyState<VK_LCONTROL, VK_RCONTROL> m_ctrlKeyState;
|
||||||
|
std::function<void()> m_keyUpdateCallback;
|
||||||
|
|
||||||
struct WindowTransparencyProperties
|
struct WindowTransparencyProperties
|
||||||
{
|
{
|
||||||
@ -117,8 +122,8 @@ private:
|
|||||||
} m_windowTransparencyProperties;
|
} m_windowTransparencyProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
WindowMoveHandler::WindowMoveHandler(const winrt::com_ptr<IFancyZonesSettings>& settings, SecondaryMouseButtonsHook* mouseHook, ShiftKeyHook* shiftHook, CtrlKeyHook* ctrlHook) :
|
WindowMoveHandler::WindowMoveHandler(const winrt::com_ptr<IFancyZonesSettings>& settings, const std::function<void()>& keyUpdateCallback) :
|
||||||
pimpl(new WindowMoveHandlerPrivate(settings, mouseHook, shiftHook, ctrlHook)) {}
|
pimpl(new WindowMoveHandlerPrivate(settings, keyUpdateCallback)) {}
|
||||||
|
|
||||||
WindowMoveHandler::~WindowMoveHandler()
|
WindowMoveHandler::~WindowMoveHandler()
|
||||||
{
|
{
|
||||||
@ -135,21 +140,6 @@ bool WindowMoveHandler::IsDragEnabled() const noexcept
|
|||||||
return pimpl->IsDragEnabled();
|
return pimpl->IsDragEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowMoveHandler::OnMouseDown() noexcept
|
|
||||||
{
|
|
||||||
pimpl->OnMouseDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowMoveHandler::OnShiftChangeState(bool state) noexcept
|
|
||||||
{
|
|
||||||
pimpl->OnShiftChangeState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowMoveHandler::OnCtrlChangeState(bool state) noexcept
|
|
||||||
{
|
|
||||||
pimpl->OnCtrlChangeState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept
|
void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept
|
||||||
{
|
{
|
||||||
pimpl->MoveSizeStart(window, monitor, ptScreen, zoneWindowMap);
|
pimpl->MoveSizeStart(window, monitor, ptScreen, zoneWindowMap);
|
||||||
@ -180,21 +170,6 @@ bool WindowMoveHandler::MoveWindowIntoZoneByDirectionAndPosition(HWND window, DW
|
|||||||
return pimpl->MoveWindowIntoZoneByDirectionAndPosition(window, vkCode, cycle, zoneWindow);
|
return pimpl->MoveWindowIntoZoneByDirectionAndPosition(window, vkCode, cycle, zoneWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowMoveHandlerPrivate::OnMouseDown() noexcept
|
|
||||||
{
|
|
||||||
m_secondaryMouseButtonState = !m_secondaryMouseButtonState;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowMoveHandlerPrivate::OnShiftChangeState(bool state) noexcept
|
|
||||||
{
|
|
||||||
m_shiftKeyState = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowMoveHandlerPrivate::OnCtrlChangeState(bool state) noexcept
|
|
||||||
{
|
|
||||||
m_ctrlKeyState = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowMoveHandlerPrivate::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept
|
void WindowMoveHandlerPrivate::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept
|
||||||
{
|
{
|
||||||
if (!IsInterestingWindow(window, m_settings->GetSettings()->excludedAppsArray) || WindowMoveHandlerUtils::IsCursorTypeIndicatingSizeEvent())
|
if (!IsInterestingWindow(window, m_settings->GetSettings()->excludedAppsArray) || WindowMoveHandlerUtils::IsCursorTypeIndicatingSizeEvent())
|
||||||
@ -214,11 +189,11 @@ void WindowMoveHandlerPrivate::MoveSizeStart(HWND window, HMONITOR monitor, POIN
|
|||||||
|
|
||||||
if (m_settings->GetSettings()->mouseSwitch)
|
if (m_settings->GetSettings()->mouseSwitch)
|
||||||
{
|
{
|
||||||
m_mouseHook->enable();
|
m_mouseHook.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_shiftHook->enable();
|
m_shiftKeyState.enable();
|
||||||
m_ctrlHook->enable();
|
m_ctrlKeyState.enable();
|
||||||
|
|
||||||
// This updates m_dragEnabled depending on if the shift key is being held down
|
// This updates m_dragEnabled depending on if the shift key is being held down
|
||||||
UpdateDragState();
|
UpdateDragState();
|
||||||
@ -306,7 +281,7 @@ void WindowMoveHandlerPrivate::MoveSizeUpdate(HMONITOR monitor, POINT const& ptS
|
|||||||
|
|
||||||
for (auto [keyMonitor, zoneWindow] : zoneWindowMap)
|
for (auto [keyMonitor, zoneWindow] : zoneWindowMap)
|
||||||
{
|
{
|
||||||
zoneWindow->MoveSizeUpdate(ptScreen, m_dragEnabled, m_ctrlKeyState);
|
zoneWindow->MoveSizeUpdate(ptScreen, m_dragEnabled, m_ctrlKeyState.state());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,9 +302,9 @@ void WindowMoveHandlerPrivate::MoveSizeEnd(HWND window, POINT const& ptScreen, c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mouseHook->disable();
|
m_mouseHook.disable();
|
||||||
m_shiftHook->disable();
|
m_shiftKeyState.disable();
|
||||||
m_ctrlHook->disable();
|
m_ctrlKeyState.disable();
|
||||||
|
|
||||||
if (m_zoneWindowMoveSize)
|
if (m_zoneWindowMoveSize)
|
||||||
{
|
{
|
||||||
@ -374,7 +349,7 @@ void WindowMoveHandlerPrivate::MoveSizeEnd(HWND window, POINT const& ptScreen, c
|
|||||||
|
|
||||||
m_inMoveSize = false;
|
m_inMoveSize = false;
|
||||||
m_dragEnabled = false;
|
m_dragEnabled = false;
|
||||||
m_secondaryMouseButtonState = false;
|
m_mouseState = false;
|
||||||
m_windowMoveSize = nullptr;
|
m_windowMoveSize = nullptr;
|
||||||
|
|
||||||
// Also, hide all windows (regardless of settings)
|
// Also, hide all windows (regardless of settings)
|
||||||
@ -430,11 +405,11 @@ void WindowMoveHandlerPrivate::UpdateDragState() noexcept
|
|||||||
{
|
{
|
||||||
if (m_settings->GetSettings()->shiftDrag)
|
if (m_settings->GetSettings()->shiftDrag)
|
||||||
{
|
{
|
||||||
m_dragEnabled = (m_shiftKeyState ^ m_secondaryMouseButtonState);
|
m_dragEnabled = (m_shiftKeyState.state() ^ m_mouseState);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_dragEnabled = !(m_shiftKeyState ^ m_secondaryMouseButtonState);
|
m_dragEnabled = !(m_shiftKeyState.state() ^ m_mouseState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SecondaryMouseButtonsHook.h"
|
#include "SecondaryMouseButtonsHook.h"
|
||||||
#include "GenericKeyHook.h"
|
|
||||||
|
|
||||||
interface IFancyZonesSettings;
|
interface IFancyZonesSettings;
|
||||||
interface IZoneWindow;
|
interface IZoneWindow;
|
||||||
@ -9,16 +8,12 @@ interface IZoneWindow;
|
|||||||
class WindowMoveHandler
|
class WindowMoveHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindowMoveHandler(const winrt::com_ptr<IFancyZonesSettings>& settings, SecondaryMouseButtonsHook* mouseHook, ShiftKeyHook* shiftHook, CtrlKeyHook* ctrlHook);
|
WindowMoveHandler(const winrt::com_ptr<IFancyZonesSettings>& settings, const std::function<void()>& keyUpdateCallback);
|
||||||
~WindowMoveHandler();
|
~WindowMoveHandler();
|
||||||
|
|
||||||
bool InMoveSize() const noexcept;
|
bool InMoveSize() const noexcept;
|
||||||
bool IsDragEnabled() const noexcept;
|
bool IsDragEnabled() const noexcept;
|
||||||
|
|
||||||
void OnMouseDown() noexcept;
|
|
||||||
void OnShiftChangeState(bool state) noexcept; //True for shift down event false for shift up
|
|
||||||
void OnCtrlChangeState(bool state) noexcept; //True for ctrl down event false for ctrl up
|
|
||||||
|
|
||||||
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
||||||
void MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
void MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
||||||
void MoveSizeEnd(HWND window, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
void MoveSizeEnd(HWND window, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IZoneWindow>>& zoneWindowMap) noexcept;
|
||||||
|
Loading…
Reference in New Issue
Block a user