Compare commits

...
Author SHA1 Message Date
maxjivi05 1525dcfb52 fix(input): the controls editor uses the same screen area as the game, so edited controls stay where they were placed
On screens with a cutout the editor window stopped at the cutout while the
session drew across it, so controls on the cutout side moved over by the
cutout's width in game and could overlap. Both windows now lay out into the
cutout through one shared helper and see the same safe insets.
2026-11-29 14:14:07 -05:00
3 changed files with 30 additions and 7 deletions

No files matched your search

@@ -54,6 +54,7 @@ import com.droiddeck.launcher.stores.StoreAchievements
import com.droiddeck.launcher.stores.StoreGameSidecar
import com.droiddeck.launcher.stores.StoreLaunchRequests
import com.droiddeck.launcher.stores.epic.EpicClient
import com.droiddeck.launcher.ui.extendIntoCutout
import com.droiddeck.launcher.ui.SessionAchievements
import com.droiddeck.launcher.ui.screenIsOff
import com.droiddeck.launcher.gpu.Cardboard
@@ -7097,13 +7098,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
if (Build.VERSION.SDK_INT >= 28) {
window.attributes = window.attributes.apply {
layoutInDisplayCutoutMode = if (Build.VERSION.SDK_INT >= 30)
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
else WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
}
window.extendIntoCutout()
}
private val endListener: (Int) -> Unit = { status -> onSessionEnded(status) }
@@ -7,6 +7,7 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.Display
import android.os.Build
import android.view.View
import android.view.Window
import android.view.WindowManager
@@ -480,6 +481,15 @@ private class SurfaceEditorPresentation(private val host: ComponentActivity, dis
internal fun Window.prepareInputEditor() {
addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or WindowManager.LayoutParams.FLAG_FULLSCREEN)
setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)
extendIntoCutout()
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
internal fun Window.extendIntoCutout() {
if (Build.VERSION.SDK_INT < 28) return
attributes = attributes.apply {
layoutInDisplayCutoutMode = if (Build.VERSION.SDK_INT >= 30) WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
else WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
}
@@ -5,6 +5,7 @@ import android.view.InputDevice
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import com.droiddeck.launcher.input.InputControl
import com.droiddeck.launcher.input.InputLibraries
import com.droiddeck.launcher.input.InputSurfaceElement
@@ -22,6 +23,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.Robolectric
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
@@ -90,6 +92,22 @@ class InputSurfaceEditorViewTest {
private fun InputSurfaceEditorView.centre(id: String) = rendered().first { it.id == id }.let { (it.x + it.width / 2) * width to (it.y + it.height / 2) * height }
private fun editorCutoutMode(): Int {
val activity = Robolectric.buildActivity(android.app.Activity::class.java).setup().get()
val dialog = android.app.Dialog(activity)
dialog.window!!.prepareInputEditor()
return dialog.window!!.attributes.layoutInDisplayCutoutMode
}
@Test fun theEditorLaysOutIntoTheCutoutLikeTheSession() {
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS, editorCutoutMode())
}
@Config(sdk = [29])
@Test fun theEditorLaysOutIntoShortEdgeCutoutsOnOlderAndroid() {
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, editorCutoutMode())
}
@Test fun editingStartsInTheDisplayedFrame() {
val view = view()
var started: Pair<List<InputSurfaceElement>, Float>? = null