fix(input): retry the relative mouse mode gamescope did not take

The drawer state moved before the request ran, so a failed request left
the two out of step and the next focus change skipped the resend.
This commit is contained in:
kingokksa committed 2026-11-01 00:37:25 +08:00
1 parent 7ff8c5d568
commit cf0f82d8cd
1 file changed
+5 -5
@@ -219,6 +219,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private var steamImportAnswered: String? = null private var steamImportAnswered: String? = null
private var directHoldBehavior by mutableStateOf(com.droiddeck.launcher.input.TouchGestureConfig.MOUSE_BEHAVIOR_CLICK) private var directHoldBehavior by mutableStateOf(com.droiddeck.launcher.input.TouchGestureConfig.MOUSE_BEHAVIOR_CLICK)
private var relativeMouseMode by mutableIntStateOf(0) private var relativeMouseMode by mutableIntStateOf(0)
@Volatile private var appliedRelativeMouseMode: Int? = null
private var screenKeyPickerOpen by mutableStateOf(false) private var screenKeyPickerOpen by mutableStateOf(false)
private var screenKeyBind: List<Int>? = null private var screenKeyBind: List<Int>? = null
private var screenKeyDir: Int? = null private var screenKeyDir: Int? = null
@@ -2793,17 +2794,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
relativeMouseRequests.execute { relativeMouseRequests.execute {
val result = runCatching { AgentGuest.call(this, request, 8_000, trusted = true) } val result = runCatching { AgentGuest.call(this, request, 8_000, trusted = true) }
val ok = result.getOrNull()?.optBoolean("ok") == true val ok = result.getOrNull()?.optBoolean("ok") == true
if (!ok) Log.w(TAG, "gamescope did not take relative mouse: ${result.exceptionOrNull() ?: result.getOrNull()}") if (ok) appliedRelativeMouseMode = mode
else Log.w(TAG, "gamescope did not take relative mouse: ${result.exceptionOrNull() ?: result.getOrNull()}")
} }
} }
private fun refreshGestureConfig() { private fun refreshGestureConfig() {
gestureConfig = com.droiddeck.launcher.input.GesturePrefs.read(this, gestureGame) gestureConfig = com.droiddeck.launcher.input.GesturePrefs.read(this, gestureGame)
directHoldBehavior = gestureConfig.directHoldBehavior directHoldBehavior = gestureConfig.directHoldBehavior
if (relativeMouseMode != gestureConfig.relativeMouseMode) { relativeMouseMode = gestureConfig.relativeMouseMode
relativeMouseMode = gestureConfig.relativeMouseMode if (appliedRelativeMouseMode != relativeMouseMode) setRelativeMouse(relativeMouseMode)
setRelativeMouse(relativeMouseMode)
}
gestureTouchStreamGate.reset() gestureTouchStreamGate.reset()
if (::touchscreenGestures.isInitialized) touchscreenGestures.configure(gestureConfig) if (::touchscreenGestures.isInitialized) touchscreenGestures.configure(gestureConfig)
if (::directTouchHold.isInitialized) directTouchHold.configure(gestureConfig) if (::directTouchHold.isInitialized) directTouchHold.configure(gestureConfig)