diff --git a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp index f97baf20ec..4f73ec44cf 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp @@ -53,7 +53,8 @@ namespace WindowMoveHandlerUtils WindowMoveHandler::WindowMoveHandler(const std::function& keyUpdateCallback) : m_mouseState(false), m_mouseHook(std::bind(&WindowMoveHandler::OnMouseDown, this)), - m_shiftKeyState(keyUpdateCallback), + m_leftShiftKeyState(keyUpdateCallback), + m_rightShiftKeyState(keyUpdateCallback), m_ctrlKeyState(keyUpdateCallback), m_keyUpdateCallback(keyUpdateCallback) { @@ -88,7 +89,8 @@ void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const m_mouseHook.enable(); } - m_shiftKeyState.enable(); + m_leftShiftKeyState.enable(); + m_rightShiftKeyState.enable(); m_ctrlKeyState.enable(); // This updates m_dragEnabled depending on if the shift key is being held down @@ -214,8 +216,12 @@ void WindowMoveHandler::MoveSizeEnd(HWND window, const std::unordered_mapMoveSizeEnd(m_draggedWindow); } } @@ -360,11 +379,11 @@ void WindowMoveHandler::UpdateDragState() noexcept { if (FancyZonesSettings::settings().shiftDrag) { - m_dragEnabled = (m_shiftKeyState.state() ^ m_mouseState); + m_dragEnabled = ((m_leftShiftKeyState.state() || m_rightShiftKeyState.state()) ^ m_mouseState); } else { - m_dragEnabled = !(m_shiftKeyState.state() ^ m_mouseState); + m_dragEnabled = !((m_leftShiftKeyState.state() || m_rightShiftKeyState.state()) ^ m_mouseState); } } @@ -410,3 +429,12 @@ void WindowMoveHandler::ResetWindowTransparency() noexcept m_windowTransparencyProperties.draggedWindow = nullptr; } } + +void WindowMoveHandler::SwallowKey(const WORD key) noexcept +{ + INPUT inputKey[1] = {}; + inputKey[0].type = INPUT_KEYBOARD; + inputKey[0].ki.wVk = key; + inputKey[0].ki.dwFlags = KEYEVENTF_KEYUP; + SendInput(1, inputKey, sizeof(INPUT)); +} diff --git a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h index 1e3c2a1baa..29a8f0488e 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h +++ b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h @@ -65,6 +65,7 @@ private: void SetWindowTransparency(HWND window) noexcept; void ResetWindowTransparency() noexcept; + void SwallowKey(const WORD key) noexcept; bool m_inDragging{}; // Whether or not a move/size operation is currently active HWND m_draggedWindow{}; // The window that is being moved/sized @@ -76,7 +77,8 @@ private: std::atomic m_mouseState; SecondaryMouseButtonsHook m_mouseHook; - KeyState m_shiftKeyState; + KeyState m_leftShiftKeyState; + KeyState m_rightShiftKeyState; KeyState m_ctrlKeyState; std::function m_keyUpdateCallback; };