Skip to content

Commit 9d6218d

Browse files
committed
Don't capture the cursor by default in windowed mode
Closes moonlight-stream#1872
1 parent 8cc3b30 commit 9d6218d

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

app/streaming/session.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,17 +1888,23 @@ void Session::exec()
18881888
bool needsFirstEnterCapture = false;
18891889
bool needsPostDecoderCreationCapture = false;
18901890

1891-
// HACK: For Wayland, we wait until we get the first SDL_WINDOWEVENT_ENTER
1892-
// event where it seems to work consistently on GNOME. For other platforms,
1893-
// especially where SDL may call SDL_RecreateWindow(), we must only capture
1894-
// after the decoder is created.
1895-
if (strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
1896-
// Native Wayland: Capture on SDL_WINDOWEVENT_ENTER
1897-
needsFirstEnterCapture = true;
1898-
}
1899-
else {
1900-
// X11/XWayland: Capture after decoder creation
1901-
needsPostDecoderCreationCapture = true;
1891+
// Avoid capturing the mouse initially for windowed relative mode.
1892+
// We still capture in windowed absolute mode because it doesn't
1893+
// constrain the motion of the cursor. This allows the user to
1894+
// easily reposition or resize the window.
1895+
if (m_IsFullScreen || m_Preferences->absoluteMouseMode) {
1896+
// HACK: For Wayland, we wait until we get the first SDL_WINDOWEVENT_ENTER
1897+
// event where it seems to work consistently on GNOME. For other platforms,
1898+
// especially where SDL may call SDL_RecreateWindow(), we must only capture
1899+
// after the decoder is created.
1900+
if (strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
1901+
// Native Wayland: Capture on SDL_WINDOWEVENT_ENTER
1902+
needsFirstEnterCapture = true;
1903+
}
1904+
else {
1905+
// X11/XWayland: Capture after decoder creation
1906+
needsPostDecoderCreationCapture = true;
1907+
}
19021908
}
19031909

19041910
// Stop text input. SDL enables it by default

0 commit comments

Comments
 (0)