From 2fdabe37aa42ec4957d97801f12a2108e000ec64 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 1 May 2020 18:44:22 -0700 Subject: [PATCH] Raise the window before capturing in relative mode --- app/streaming/input/input.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index 9a2b2515..6a230bd5 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -247,6 +247,14 @@ void SdlInputHandler::setCaptureActive(bool active) SDL_SetWindowGrab(m_Window, SDL_TRUE); } + if (!m_AbsoluteMouseMode) { + // If our window is occluded when mouse is captured, the mouse may + // get stuck on top of the occluding window and not be properly + // captured. We can avoid this by raising our window before we + // capture the mouse. + SDL_RaiseWindow(m_Window); + } + // If we're in relative mode, try to activate SDL's relative mouse mode if (m_AbsoluteMouseMode || SDL_SetRelativeMouseMode(SDL_TRUE) < 0) { // Relative mouse mode didn't work or was disabled, so we'll just hide the cursor