mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix: "DroidDeck isn't responding" on dual-screen handhelds when input reaches the bottom screen (#1806)
This commit is contained in:
1 parent
ed661d7007
commit
d4fd7ac5c3
1 file changed
+22
-4
@@ -159,6 +159,18 @@ object DualScreenPanel {
|
||||
runCatching { (context.getSystemService(Context.ACTIVITY_SERVICE) as android.app.ActivityManager).moveTaskToFront(task, 0) }
|
||||
}
|
||||
|
||||
internal fun reclaimFocus(context: Context) {
|
||||
if (ownerYielded) return
|
||||
val task = ownerTask.takeIf { it >= 0 } ?: return
|
||||
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as android.app.ActivityManager
|
||||
runCatching {
|
||||
manager.appTasks.firstOrNull {
|
||||
@Suppress("DEPRECATION")
|
||||
(if (android.os.Build.VERSION.SDK_INT >= 29) it.taskInfo.taskId else it.taskInfo.persistentId) == task
|
||||
}?.moveToFront() ?: manager.moveTaskToFront(task, 0)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun detach(host: DualScreenActivity) {
|
||||
if (activity === host) {
|
||||
activity = null
|
||||
@@ -174,7 +186,7 @@ class DualScreenActivity : ComponentActivity() {
|
||||
finishAndRemoveTask()
|
||||
return
|
||||
}
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
applyImmersiveMode()
|
||||
setContent {
|
||||
val model = DualScreenPanel.model
|
||||
@@ -209,7 +221,6 @@ class DualScreenActivity : ComponentActivity() {
|
||||
|
||||
private fun dropFocus() {
|
||||
unfocusPending = false
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -217,10 +228,17 @@ class DualScreenActivity : ComponentActivity() {
|
||||
if (!DualScreenPanel.typingShown) DualScreenPanel.returnFocus(this)
|
||||
}
|
||||
|
||||
override fun onTopResumedActivityChanged(isTopResumedActivity: Boolean) {
|
||||
super.onTopResumedActivityChanged(isTopResumedActivity)
|
||||
if (isTopResumedActivity && !DualScreenPanel.typingShown) DualScreenPanel.returnFocus(this)
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (hasFocus) applyImmersiveMode()
|
||||
else if (unfocusPending && !DualScreenPanel.typingShown) dropFocus()
|
||||
if (hasFocus) {
|
||||
applyImmersiveMode()
|
||||
if (!DualScreenPanel.typingShown) DualScreenPanel.reclaimFocus(this)
|
||||
} else if (unfocusPending && !DualScreenPanel.typingShown) dropFocus()
|
||||
}
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
|
||||
Reference in new issue
Block a user