mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
A pointer for the desktop: an arrow, touch gestures and a real mouse
The pointer moved but nothing drew it — the nested desktop asks its parent compositor for a cursor and ours ignores the request — and touch knew only move and tap. Now the app draws the arrow where it last sent the pointer, touch works like a remote desktop (tap clicks, hold then lift right-clicks, hold then drag drags, two fingers scroll), and a mouse arrives as itself: hover moves, every button presses, the wheel scrolls, with Android's own pointer hidden so there is one arrow.
This commit is contained in:
1 parent
d6789f7b61
commit
f5ca6d0053
3 files changed
+231
-15
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package com.steamdeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Path
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
|
||||
/**
|
||||
* The pointer, drawn by the app. The nested desktop asks its parent compositor to show a cursor
|
||||
* and ours does not, and the Steam session has none either; this is the arrow for both, at the
|
||||
* position the app last sent. Takes no touches.
|
||||
*/
|
||||
@Composable
|
||||
fun CursorOverlay(position: Offset, visible: Boolean, scale: Float) {
|
||||
if (!visible) return
|
||||
Canvas(modifier = Modifier.fillMaxSize()) {
|
||||
val s = 22f * scale
|
||||
val path = Path().apply {
|
||||
moveTo(position.x, position.y)
|
||||
lineTo(position.x, position.y + s * 1.45f)
|
||||
lineTo(position.x + s * 0.36f, position.y + s * 1.12f)
|
||||
lineTo(position.x + s * 0.62f, position.y + s * 1.62f)
|
||||
lineTo(position.x + s * 0.84f, position.y + s * 1.52f)
|
||||
lineTo(position.x + s * 0.58f, position.y + s * 1.02f)
|
||||
lineTo(position.x + s * 1.02f, position.y + s * 1.02f)
|
||||
close()
|
||||
}
|
||||
drawPath(path, Color.White)
|
||||
drawPath(path, Color(0xFF1B0730), style = Stroke(width = 1.5f * scale))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user