mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
feat(dual-screen): swap screens - game on the bottom screen, panel on top (#2006)
Swap screens for dual-screen handhelds: the game moves to the built-in bottom screen while the top screen shows the Dashboard or the KDE desktop. Swap button in the Dashboard and Desktop bars and a Show the game on row in the session menu. The desktop resizes to the screen it is on, Follow screen and Match screen sessions take the bottom screen's shape, the keyboard opens on the top screen, and the game swaps back on session end, picture-in-picture, glasses, or when the bottom screen is taken. Review follow-ups cover desktop restart, refresh pacing, key and pointer ownership, touch cancellation and bottom surface recovery.
This commit is contained in:
1 parent
3fbd86c89d
commit
8d3616eccd
14 files changed
+515
-71
No files matched your search
@@ -20,12 +20,15 @@ class BottomDesktopCompositorService : Service() {
|
||||
private var client: Messenger? = null
|
||||
/** Echoed in every reply, so the session process can tell replies to an earlier attach apart. */
|
||||
@Volatile private var attachTag = 0
|
||||
private var outputWidth = 0
|
||||
private var outputHeight = 0
|
||||
|
||||
private val handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
when (msg.what) {
|
||||
MSG_ATTACH -> attach(msg)
|
||||
MSG_DETACH -> CompositorHost.detach(null)
|
||||
MSG_RESIZE -> resize(msg.arg1, msg.arg2)
|
||||
MSG_TOUCH -> WaylandCompositor.nativeSendTouch(msg.arg1 and 0xff, msg.arg1 shr 8,
|
||||
msg.arg2 ushr 16, msg.arg2 and 0xffff)
|
||||
MSG_KEY -> WaylandCompositor.nativeSendKey(msg.arg1, msg.arg2)
|
||||
@@ -75,15 +78,26 @@ class BottomDesktopCompositorService : Service() {
|
||||
}
|
||||
val turnip = com.droiddeck.launcher.gpu.TurnipDriver(this)
|
||||
val driverId = if (CompositorHost.isStarted) null else turnip.install()
|
||||
val resized = CompositorHost.isStarted && (width != outputWidth || height != outputHeight)
|
||||
val started = CompositorHost.startOrAttach(
|
||||
this, surface, runtimeDir.path, driverId?.let { turnip.driverPath(it) }, driverId?.let { turnip.libraryName(it) },
|
||||
applicationInfo.nativeLibraryDir,
|
||||
width, height, data.getFloat(KEY_REFRESH, 60f), 0,
|
||||
)
|
||||
outputWidth = width
|
||||
outputHeight = height
|
||||
if (resized) WaylandCompositor.nativeResizeOutput(width, height)
|
||||
Log.i(TAG, (if (started) "compositor started" else "compositor attached") + " at ${width}x$height in ${runtimeDir.path}")
|
||||
reply(MSG_ATTACHED)
|
||||
}
|
||||
|
||||
private fun resize(width: Int, height: Int) {
|
||||
if (width <= 0 || height <= 0 || !CompositorHost.isStarted || (width == outputWidth && height == outputHeight)) return
|
||||
outputWidth = width
|
||||
outputHeight = height
|
||||
WaylandCompositor.nativeResizeOutput(width, height)
|
||||
}
|
||||
|
||||
private fun reply(what: Int) {
|
||||
val target = client ?: return
|
||||
runCatching { target.send(Message.obtain(null, what, attachTag, 0)) }
|
||||
@@ -102,6 +116,7 @@ class BottomDesktopCompositorService : Service() {
|
||||
const val MSG_POINTER = 8
|
||||
const val MSG_SCENE = 9
|
||||
const val MSG_CURSOR = 10
|
||||
const val MSG_RESIZE = 11
|
||||
const val MSG_ATTACHED = 101
|
||||
const val MSG_FIRST_FRAME = 102
|
||||
const val KEY_RUNTIME_DIR = "runtimeDir"
|
||||
|
||||
Reference in new issue
Block a user