mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-23 06:46:02 +00:00
Make the desktop a proper Arch desktop: pacman, sudo, utilities and touch right-click
The KDE desktop package now records every package it ships in pacman's database and carries a pinned droiddeck repository built from the same Arch Linux ARM snapshot, so pacman installs software that matches the desktop's Qt and KDE versions and never upgrades what DroidDeck ships. sudo, su and sudoedit run commands as root through a small preload, and pacman hooks refuse to remove or replace DroidDeck's own packages and remember user installs so they come back after runtime updates. Adds zip, 7zip, unrar, less, man pages, htop, git, wget, wl-clipboard, xclip, KCalc, Okular, Filelight, KFind, System Monitor, Elisa and Discover, pins Kate to the panel, and hides technical menu entries. Updates KWin to 6.8.1 to match the repository. A two-finger tap now right-clicks on the desktop, and the Android clipboard is only pushed into the session when it changed, so files copied in Dolphin stay pasteable after leaving the app.
This commit is contained in:
1 parent
c9044a27e3
commit
49201e1afa
50 files changed
+1051
-15
No files matched your search
@@ -198,6 +198,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private var watching = true
|
||||
private lateinit var touchpad: TouchpadGestures
|
||||
private lateinit var directTouchHold: DirectTouchHold
|
||||
private lateinit var twoFingerTap: com.droiddeck.launcher.input.TwoFingerTap
|
||||
private lateinit var threeFingerTap: com.droiddeck.launcher.input.ThreeFingerTap
|
||||
private lateinit var touchscreenGestures: TouchscreenGestures
|
||||
private var gestureConfig = com.droiddeck.launcher.input.TouchGestureConfig()
|
||||
@@ -591,6 +592,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
}
|
||||
threeFingerTap = com.droiddeck.launcher.input.ThreeFingerTap(PointerGestures.slop(this) * 2)
|
||||
twoFingerTap = com.droiddeck.launcher.input.TwoFingerTap(PointerGestures.slop(this) * 2)
|
||||
touchscreenGestures = TouchscreenGestures(
|
||||
ViewConfiguration.get(this).scaledTouchSlop.toFloat(), gestureOutput,
|
||||
)
|
||||
@@ -2890,6 +2892,25 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) ignoreGameTouch = false
|
||||
return true
|
||||
}
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP) {
|
||||
when (twoFingerTap.onTouch(event)) {
|
||||
com.droiddeck.launcher.input.TwoFingerTap.Result.SWALLOW -> return true
|
||||
com.droiddeck.launcher.input.TwoFingerTap.Result.CANCEL -> {
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
return true
|
||||
}
|
||||
com.droiddeck.launcher.input.TwoFingerTap.Result.TAP -> {
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
directTouchHold.cancel()
|
||||
val tapX = twoFingerTap.x
|
||||
val tapY = twoFingerTap.y
|
||||
pointerListener.onButton(PointerGestures.BTN_RIGHT, true, tapX, tapY)
|
||||
surfaceView.postDelayed({ pointerListener.onButton(PointerGestures.BTN_RIGHT, false, tapX, tapY) }, 50L)
|
||||
return true
|
||||
}
|
||||
com.droiddeck.launcher.input.TwoFingerTap.Result.PASS -> Unit
|
||||
}
|
||||
}
|
||||
if (directTouchHold.onTouch(event)) return true
|
||||
fun sendTouch(action: Int, index: Int) {
|
||||
val x = event.getX(index).coerceIn(rect.left, rect.right)
|
||||
|
||||
@@ -16,13 +16,19 @@ class SessionClipboard(context: Context, private val hasFocus: () -> Boolean) {
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private val hostFile = File(context.filesDir, "session/android-clipboard")
|
||||
private var active = false
|
||||
private val androidListener = ClipboardManager.OnPrimaryClipChangedListener { refresh() }
|
||||
private var published = false
|
||||
private var shared: String? = null
|
||||
private var echo: String? = null
|
||||
private val androidListener = ClipboardManager.OnPrimaryClipChangedListener { refresh(changed = true) }
|
||||
private val guestListener = object : WaylandCompositor.ClipboardListener {
|
||||
override fun onGuestClipboardText(text: String) {
|
||||
handler.post {
|
||||
if (active && hasFocus() && WaylandCompositor.isClipboardListener(this)) {
|
||||
val current = clipboard.primaryClip?.takeIf { it.itemCount > 0 }?.getItemAt(0)?.text
|
||||
shared = text
|
||||
published = true
|
||||
if (current?.toString() != text) {
|
||||
echo = text
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText("DroidDeck", text))
|
||||
}
|
||||
}
|
||||
@@ -46,17 +52,23 @@ class SessionClipboard(context: Context, private val hasFocus: () -> Boolean) {
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
fun refresh() {
|
||||
fun refresh(changed: Boolean = false) {
|
||||
if (!active || !hasFocus()) return
|
||||
val clip = clipboard.primaryClip
|
||||
if (clip == null) {
|
||||
publish(null)
|
||||
} else if (clip.itemCount > 0) {
|
||||
publish(clip.getItemAt(0).text?.toString())
|
||||
if (clip != null && clip.itemCount == 0) return
|
||||
val text = clip?.getItemAt(0)?.text?.toString()
|
||||
if (echo != null && text == echo) {
|
||||
echo = null
|
||||
return
|
||||
}
|
||||
echo = null
|
||||
if (!changed && published && text == shared) return
|
||||
publish(text)
|
||||
}
|
||||
|
||||
private fun publish(text: String?) {
|
||||
published = true
|
||||
shared = text
|
||||
WaylandCompositor.setClipboardText(text)
|
||||
val pending = File(hostFile.parentFile, "android-clipboard.pending")
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.view.MotionEvent
|
||||
import kotlin.math.hypot
|
||||
|
||||
class TwoFingerTap(private val slopPx: Float) {
|
||||
enum class Result { PASS, SWALLOW, TAP, CANCEL }
|
||||
|
||||
var x = 0f
|
||||
private set
|
||||
var y = 0f
|
||||
private set
|
||||
|
||||
private val starts = HashMap<Int, Pair<Float, Float>>()
|
||||
private var downAt = 0L
|
||||
private var twoAt = 0L
|
||||
private var candidate = false
|
||||
private var swallowed = false
|
||||
|
||||
fun onTouch(event: MotionEvent): Result {
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
starts.clear()
|
||||
candidate = false
|
||||
swallowed = false
|
||||
downAt = event.eventTime
|
||||
x = event.x
|
||||
y = event.y
|
||||
note(event, event.actionIndex)
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||
note(event, event.actionIndex)
|
||||
candidate = event.pointerCount == 2 && !swallowed && event.eventTime - downAt < LAND_MS
|
||||
if (candidate) twoAt = event.eventTime
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> for (i in 0 until event.pointerCount) {
|
||||
val start = starts[event.getPointerId(i)] ?: continue
|
||||
if (hypot(event.getX(i) - start.first, event.getY(i) - start.second) > slopPx) candidate = false
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_UP -> {
|
||||
if (candidate && event.eventTime - twoAt < TAP_MS) {
|
||||
swallowed = true
|
||||
return Result.SWALLOW
|
||||
}
|
||||
candidate = false
|
||||
if (swallowed) return Result.SWALLOW
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
val tapped = candidate && swallowed && event.eventTime - twoAt < TAP_MS
|
||||
val wasSwallowed = swallowed
|
||||
candidate = false
|
||||
swallowed = false
|
||||
return when {
|
||||
tapped -> Result.TAP
|
||||
wasSwallowed -> Result.CANCEL
|
||||
else -> Result.PASS
|
||||
}
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
candidate = false
|
||||
swallowed = false
|
||||
}
|
||||
}
|
||||
return Result.PASS
|
||||
}
|
||||
|
||||
private fun note(event: MotionEvent, index: Int) {
|
||||
starts[event.getPointerId(index)] = event.getX(index) to event.getY(index)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAND_MS = 250L
|
||||
const val TAP_MS = 350L
|
||||
}
|
||||
}
|
||||
@@ -73,10 +73,42 @@ internal object DesktopFileRemoval {
|
||||
}
|
||||
}
|
||||
|
||||
private val RECORD = Regex("[A-Za-z0-9@._+:-]+")
|
||||
|
||||
fun desktopRecords(root: File): Set<String> {
|
||||
val list = safeFile(root, "usr/share/droiddeck/pacman/desktop-packages.txt") ?: return emptySet()
|
||||
if (!Files.isRegularFile(list.toPath(), NOFOLLOW_LINKS)) return emptySet()
|
||||
return list.readLines().mapNotNull { line ->
|
||||
line.split(' ').takeIf { it.size == 2 }?.let { "${it[0]}-${it[1]}" }?.takeIf { RECORD.matches(it) && it != "." && it != ".." }
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
fun removeRecords(root: File, records: Set<String>) {
|
||||
val lib = File(root, "var/lib/pacman")
|
||||
if (Files.isSymbolicLink(File(root, "var").toPath()) || Files.isSymbolicLink(lib.toPath())) return
|
||||
val local = File(lib, "local")
|
||||
if (!local.isDirectory || Files.isSymbolicLink(local.toPath())) return
|
||||
for (record in records) {
|
||||
if (!RECORD.matches(record) || record == "." || record == "..") continue
|
||||
val dir = File(local, record)
|
||||
if (Files.isSymbolicLink(dir.toPath()) || !dir.isDirectory) continue
|
||||
for (file in dir.listFiles().orEmpty()) {
|
||||
if (Files.isSymbolicLink(file.toPath()) || file.isFile) Files.delete(file.toPath())
|
||||
}
|
||||
if (!dir.delete()) throw IOException("Cannot remove $dir")
|
||||
}
|
||||
for (name in listOf("sync/droiddeck.db", "droiddeck-desktop")) {
|
||||
val file = File(lib, name)
|
||||
if (Files.isSymbolicLink(file.toPath()) || file.isFile) Files.delete(file.toPath())
|
||||
}
|
||||
}
|
||||
|
||||
fun runtimeFiles(root: File): Set<String> = buildSet {
|
||||
val database = File(root, "var/lib/pacman/local")
|
||||
if (!database.isDirectory || Files.isSymbolicLink(database.toPath())) throw IOException("Runtime package database missing")
|
||||
val desktop = desktopRecords(root)
|
||||
for (pkg in database.listFiles().orEmpty()) {
|
||||
if (pkg.name in desktop) continue
|
||||
val files = File(pkg, "files")
|
||||
if (!pkg.isDirectory || Files.isSymbolicLink(pkg.toPath()) || !files.isFile || Files.isSymbolicLink(files.toPath())) continue
|
||||
var inFiles = false
|
||||
|
||||
@@ -50,12 +50,14 @@ internal object DesktopRemoval {
|
||||
check(version in versions && (installing == null || installing.version in versions)) { context.getString(R.string.desktop_removal_unknown) }
|
||||
val entries = lines(context, "kde-remove.tsv.gzip").map(DesktopFileRemoval.Entry::parse)
|
||||
val keep = protected(context, root)
|
||||
val records = DesktopFileRemoval.desktopRecords(root)
|
||||
cleanLegacy(context, listener)
|
||||
FileUtils.writeString(pending, version!!)
|
||||
check(FileUtils.readString(pending)?.trim() == version) { "Could not reserve desktop removal" }
|
||||
if (marker.exists() && !marker.delete()) error("Could not clear desktop marker")
|
||||
val removing = context.getString(R.string.desktop_removing)
|
||||
val result = DesktopFileRemoval.remove(root, entries, keep) { listener.onProgress(removing, it) }
|
||||
DesktopFileRemoval.removeRecords(root, records)
|
||||
for ((asset, path) in com.droiddeck.launcher.session.SessionFiles.DESKTOP_FILES) {
|
||||
val target = DesktopFileRemoval.safeFile(root, path) ?: continue
|
||||
if (!isRegularFile(target)) continue
|
||||
|
||||
@@ -76,4 +76,22 @@ class DesktopFileRemovalTest {
|
||||
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/\nusr/bin/\nusr/bin/gamescope\n\n%BACKUP%\netc/config\n")
|
||||
assertEquals(setOf("usr/bin/gamescope"), DesktopFileRemoval.runtimeFiles(root))
|
||||
}
|
||||
|
||||
@Test fun desktopPackageRecordsAreNotRuntimeFilesAndAreRemovedWithTheDesktop() {
|
||||
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/bin/gamescope\n")
|
||||
file("var/lib/pacman/local/kate-26.04.3-1/files", "%FILES%\nusr/bin/kate\n")
|
||||
file("var/lib/pacman/local/kate-26.04.3-1/desc", "%NAME%\nkate\n")
|
||||
file("var/lib/pacman/local/htop-3.5.3-1/files", "%FILES%\nusr/bin/htop\n")
|
||||
file("var/lib/pacman/sync/droiddeck.db", "db")
|
||||
file("var/lib/pacman/droiddeck-desktop", "stamp")
|
||||
file("usr/share/droiddeck/pacman/desktop-packages.txt", "kate 26.04.3-1\n../../etc 1\n")
|
||||
val records = DesktopFileRemoval.desktopRecords(root)
|
||||
assertEquals(setOf("kate-26.04.3-1"), records)
|
||||
assertEquals(setOf("usr/bin/gamescope", "usr/bin/htop"), DesktopFileRemoval.runtimeFiles(root))
|
||||
DesktopFileRemoval.removeRecords(root, records)
|
||||
assertFalse(File(root, "var/lib/pacman/local/kate-26.04.3-1").exists())
|
||||
assertTrue(File(root, "var/lib/pacman/local/htop-3.5.3-1/files").exists())
|
||||
assertFalse(File(root, "var/lib/pacman/sync/droiddeck.db").exists())
|
||||
assertFalse(File(root, "var/lib/pacman/droiddeck-desktop").exists())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user