mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-04 00:36:36 +00:00
Don't confine the cursor to the full-screen window when not capturing input
This commit is contained in:
parent
dbafd05a4e
commit
96e6750f9c
@ -1415,20 +1415,31 @@ bool SdlInputHandler::isCaptureActive()
|
|||||||
void SdlInputHandler::setCaptureActive(bool active)
|
void SdlInputHandler::setCaptureActive(bool active)
|
||||||
{
|
{
|
||||||
if (active) {
|
if (active) {
|
||||||
|
// If we're in full-screen exclusive mode, grab the cursor so it can't accidentally leave our window.
|
||||||
|
if ((SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
|
||||||
|
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
// If we're in relative mode, try to activate SDL's relative mouse mode
|
// If we're in relative mode, try to activate SDL's relative mouse mode
|
||||||
if (m_AbsoluteMouseMode || SDL_SetRelativeMouseMode(SDL_TRUE) < 0) {
|
if (m_AbsoluteMouseMode || SDL_SetRelativeMouseMode(SDL_TRUE) < 0) {
|
||||||
// Relative mouse mode didn't work, so we'll use fake capture
|
// Relative mouse mode didn't work or was disabled, so we'll just hide the cursor
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
m_FakeCaptureActive = true;
|
m_FakeCaptureActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_FakeCaptureActive) {
|
else {
|
||||||
|
if (m_FakeCaptureActive) {
|
||||||
|
// Display the cursor again
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
m_FakeCaptureActive = false;
|
m_FakeCaptureActive = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow the cursor to leave the bounds of our window again.
|
||||||
|
SDL_SetWindowGrab(m_Window, SDL_FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SdlInputHandler::getUnmappedGamepads()
|
QString SdlInputHandler::getUnmappedGamepads()
|
||||||
|
@ -867,8 +867,8 @@ void Session::toggleFullscreen()
|
|||||||
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
|
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
|
||||||
|
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
if (m_FullScreenFlag == SDL_WINDOW_FULLSCREEN) {
|
if (m_FullScreenFlag == SDL_WINDOW_FULLSCREEN && m_InputHandler->isCaptureActive()) {
|
||||||
// Confine the cursor to the window
|
// Confine the cursor to the window if we're capturing input
|
||||||
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,11 +1120,6 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
|||||||
SDL_SetWindowResizable(m_Window, SDL_TRUE);
|
SDL_SetWindowResizable(m_Window, SDL_TRUE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m_FullScreenFlag == SDL_WINDOW_FULLSCREEN) {
|
|
||||||
// Confine the cursor to the window
|
|
||||||
SDL_SetWindowGrab(m_Window, SDL_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the window display mode based on our current monitor
|
// Update the window display mode based on our current monitor
|
||||||
updateOptimalWindowDisplayMode();
|
updateOptimalWindowDisplayMode();
|
||||||
|
|
||||||
@ -1360,7 +1355,6 @@ DispatchDeferredCleanup:
|
|||||||
// Uncapture the mouse and hide the window immediately,
|
// Uncapture the mouse and hide the window immediately,
|
||||||
// so we can return to the Qt GUI ASAP.
|
// so we can return to the Qt GUI ASAP.
|
||||||
m_InputHandler->setCaptureActive(false);
|
m_InputHandler->setCaptureActive(false);
|
||||||
SDL_SetWindowGrab(m_Window, SDL_FALSE);
|
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
||||||
if (QGuiApplication::platformName() == "eglfs") {
|
if (QGuiApplication::platformName() == "eglfs") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user