mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
fix(input): release a mouse Back right click on focus loss and pass nav Back through
Address review: a navigation-bar Back that arrives while an injected mouse Back is held now stays Back instead of releasing the right button early. A held right button is released on pause, focus loss and input-device removal, like the other held Back handling. While the session is suspended or still loading, Back is no longer sent to the guest.
This commit is contained in:
1 parent
57b3623a9a
commit
abb28792e8
3 files changed
+32
-3
No files matched your search
@@ -15,7 +15,9 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
|
||||
fun onKeyEvent(event: KeyEvent, toGuest: Boolean): Boolean {
|
||||
if (event.keyCode != KeyEvent.KEYCODE_BACK) return false
|
||||
val device = event.deviceId
|
||||
if (device in held) {
|
||||
val fromMouse = isFromMouse(event)
|
||||
val injected = isInjectedBack(event)
|
||||
if (device in held && (fromMouse || injected)) {
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
held.remove(device)
|
||||
sendRight(false)
|
||||
@@ -23,12 +25,18 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
|
||||
return true
|
||||
}
|
||||
if (event.action != KeyEvent.ACTION_DOWN || event.repeatCount > 0 || !toGuest) return false
|
||||
if (!isFromMouse(event) && !(isInjectedBack(event) && mouseAttached())) return false
|
||||
if (!fromMouse && !(injected && mouseAttached())) return false
|
||||
held.add(device)
|
||||
sendRight(true)
|
||||
return true
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
if (held.isEmpty()) return
|
||||
held.clear()
|
||||
sendRight(false)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun isFromMouse(event: KeyEvent): Boolean =
|
||||
event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)
|
||||
|
||||
Reference in new issue
Block a user