diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index cec9da49..2597f998 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -270,45 +270,6 @@ void SdlInputHandler::setWindow(SDL_Window *window) m_Window = window; } -void SdlInputHandler::raiseAllKeys() -{ - if (m_KeysDown.isEmpty()) { - return; - } - - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Raising %d keys", - (int)m_KeysDown.count()); - - for (auto keyDown : std::as_const(m_KeysDown)) { - LiSendKeyboardEvent(keyDown, KEY_ACTION_UP, 0); - } - - m_KeysDown.clear(); -} - -void SdlInputHandler::notifyMouseLeave() -{ - if (m_NeedsManualCaptureOnLeave) { - // SDL on Windows doesn't send the mouse button up until the mouse re-enters the window - // after leaving it. This breaks some of the Aero snap gestures, so we'll capture it to - // allow us to receive the mouse button up events later. - // - // On macOS and X11, capturing the mouse allows us to receive mouse motion outside the - // window (button up already worked without capture). - if (m_AbsoluteMouseMode && isCaptureActive()) { - // NB: Not using SDL_GetGlobalMouseState() because we want our state not the system's - Uint32 mouseState = SDL_GetMouseState(nullptr, nullptr); - for (Uint32 button = SDL_BUTTON_LEFT; button <= SDL_BUTTON_X2; button++) { - if (mouseState & SDL_BUTTON(button)) { - SDL_CaptureMouse(SDL_TRUE); - break; - } - } - } - } -} - void SdlInputHandler::notifyFocusLost() { // Release mouse cursor when another window is activated (e.g. by using ALT+TAB). diff --git a/app/streaming/input/keyboard.cpp b/app/streaming/input/keyboard.cpp index b195f73b..c0a0df41 100644 --- a/app/streaming/input/keyboard.cpp +++ b/app/streaming/input/keyboard.cpp @@ -478,3 +478,20 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event) modifiers, shouldNotConvertToScanCodeOnServer ? SS_KBE_FLAG_NON_NORMALIZED : 0); } + +void SdlInputHandler::raiseAllKeys() +{ + if (m_KeysDown.isEmpty()) { + return; + } + + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Raising %d keys", + (int)m_KeysDown.count()); + + for (auto keyDown : std::as_const(m_KeysDown)) { + LiSendKeyboardEvent(keyDown, KEY_ACTION_UP, 0); + } + + m_KeysDown.clear(); +} diff --git a/app/streaming/input/mouse.cpp b/app/streaming/input/mouse.cpp index 85169d1c..c5bd1fdd 100644 --- a/app/streaming/input/mouse.cpp +++ b/app/streaming/input/mouse.cpp @@ -4,6 +4,28 @@ #include "SDL_compat.h" #include "streaming/streamutils.h" +void SdlInputHandler::notifyMouseLeave() +{ + if (m_NeedsManualCaptureOnLeave) { + // SDL on Windows doesn't send the mouse button up until the mouse re-enters the window + // after leaving it. This breaks some of the Aero snap gestures, so we'll capture it to + // allow us to receive the mouse button up events later. + // + // On macOS and X11, capturing the mouse allows us to receive mouse motion outside the + // window (button up already worked without capture). + if (m_AbsoluteMouseMode && isCaptureActive()) { + // NB: Not using SDL_GetGlobalMouseState() because we want our state not the system's + Uint32 mouseState = SDL_GetMouseState(nullptr, nullptr); + for (Uint32 button = SDL_BUTTON_LEFT; button <= SDL_BUTTON_X2; button++) { + if (mouseState & SDL_BUTTON(button)) { + SDL_CaptureMouse(SDL_TRUE); + break; + } + } + } + } +} + void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event) { int button;