Add Ctrl+Alt+Shift+K combo to toggle system key grab

Fixes #1637
This commit is contained in:
Cameron Gutman
2026-05-24 15:13:23 -05:00
parent 97240cd5f2
commit 29294553bb
3 changed files with 28 additions and 9 deletions
+12 -9
View File
@@ -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
+1
View File
@@ -167,6 +167,7 @@ private:
KeyComboPasteText,
KeyComboTogglePointerRegionLock,
KeyComboQuitAndExit,
KeyComboToggleKeyboardGrab,
KeyComboMax
};
+15
View File
@@ -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();
}