mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-07-13 02:15:33 +00:00
@@ -116,6 +116,11 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i
|
||||
m_SpecialKeyCombos[KeyComboQuitAndExit].scanCode = SDL_SCANCODE_E;
|
||||
m_SpecialKeyCombos[KeyComboQuitAndExit].enabled = true;
|
||||
|
||||
m_SpecialKeyCombos[KeyComboToggleKeyboardGrab].keyCombo = KeyComboToggleKeyboardGrab;
|
||||
m_SpecialKeyCombos[KeyComboToggleKeyboardGrab].keyCode = SDLK_k;
|
||||
m_SpecialKeyCombos[KeyComboToggleKeyboardGrab].scanCode = SDL_SCANCODE_K;
|
||||
m_SpecialKeyCombos[KeyComboToggleKeyboardGrab].enabled = QGuiApplication::platformName() != "eglfs";
|
||||
|
||||
m_OldIgnoreDevices = SDL_GetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES);
|
||||
m_OldIgnoreDevicesExcept = SDL_GetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT);
|
||||
|
||||
@@ -319,16 +324,14 @@ bool SdlInputHandler::isCaptureActive()
|
||||
|
||||
void SdlInputHandler::updateKeyboardGrabState()
|
||||
{
|
||||
if (m_CaptureSystemKeysMode == StreamingPreferences::CSK_OFF) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool shouldGrab = isCaptureActive();
|
||||
Uint32 windowFlags = SDL_GetWindowFlags(m_Window);
|
||||
if (m_CaptureSystemKeysMode == StreamingPreferences::CSK_FULLSCREEN &&
|
||||
bool shouldGrab = m_CaptureSystemKeysMode != StreamingPreferences::CSK_OFF && isCaptureActive();
|
||||
if (shouldGrab) {
|
||||
Uint32 windowFlags = SDL_GetWindowFlags(m_Window);
|
||||
if (m_CaptureSystemKeysMode == StreamingPreferences::CSK_FULLSCREEN &&
|
||||
!(windowFlags & SDL_WINDOW_FULLSCREEN)) {
|
||||
// Ungrab if it's fullscreen only and we left fullscreen
|
||||
shouldGrab = false;
|
||||
// Ungrab if it's fullscreen only and we left fullscreen
|
||||
shouldGrab = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't close the window on Alt+F4 when keyboard grab is enabled
|
||||
|
||||
@@ -167,6 +167,7 @@ private:
|
||||
KeyComboPasteText,
|
||||
KeyComboTogglePointerRegionLock,
|
||||
KeyComboQuitAndExit,
|
||||
KeyComboToggleKeyboardGrab,
|
||||
KeyComboMax
|
||||
};
|
||||
|
||||
|
||||
@@ -153,6 +153,21 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
|
||||
SDL_PushEvent(&quitExitEvent);
|
||||
break;
|
||||
|
||||
case KeyComboToggleKeyboardGrab:
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected keyboard grab toggle combo");
|
||||
|
||||
// Toggle the system key capture mode
|
||||
if (isSystemKeyCaptureActive()) {
|
||||
m_CaptureSystemKeysMode = StreamingPreferences::CSK_OFF;
|
||||
}
|
||||
else {
|
||||
m_CaptureSystemKeysMode = StreamingPreferences::CSK_ALWAYS;
|
||||
}
|
||||
|
||||
updateKeyboardGrabState();
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user