From 2e91c8df61a2d4f431c16a6cde9f4b35c5eac38d Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sat, 27 Sep 2025 20:38:57 +0200 Subject: [PATCH] Fix live wallpaper tap commands --- .../ui/launcher/scaffold/LauncherScaffold.kt | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt index 6356c4a69..bd45b5c27 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/scaffold/LauncherScaffold.kt @@ -1,5 +1,6 @@ package de.mm20.launcher2.ui.launcher.scaffold +import android.app.WallpaperManager import android.view.animation.PathInterpolator import androidx.activity.compose.LocalActivity import androidx.activity.compose.PredictiveBackHandler @@ -16,6 +17,7 @@ import androidx.compose.animation.fadeOut import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.gestures.Orientation +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.gestures.draggable import androidx.compose.foundation.gestures.draggable2D import androidx.compose.foundation.gestures.rememberDraggable2DState @@ -74,6 +76,7 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalView @@ -1098,6 +1101,8 @@ internal fun LauncherScaffold( val activity = LocalActivity.current as AppCompatActivity val view = LocalView.current + val wallpaperManager = remember(activity) { WallpaperManager.getInstance(activity) } + val density = LocalDensity.current val systemBarInsets = WindowInsets.displayCutout .union(WindowInsets.waterfall) @@ -1423,19 +1428,26 @@ internal fun LauncherScaffold( config.homeComponent.Component( Modifier .fillMaxSize() - .combinedClickable( - enabled = config.longPress != null || config.doubleTap != null, - onClick = {}, - onLongClick = if (config.longPress != null) { - { scope.launch { state.onLongPress() } } - } else null, - onDoubleClick = if (config.doubleTap != null) { - { scope.launch { state.onDoubleTap() } } - } else null, - hapticFeedbackEnabled = false, - indication = null, - interactionSource = null, - ) + .pointerInput(wallpaperManager, config.doubleTap) { + detectTapGestures( + onDoubleTap = config.doubleTap?.let { + { scope.launch { state.onDoubleTap() } } + }, + onLongPress = config.longPress?.let { + { scope.launch { state.onLongPress() } } + }, + onTap = { + wallpaperManager.sendWallpaperCommand( + view.windowToken, + WallpaperManager.COMMAND_TAP, + it.x.toInt(), + it.y.toInt(), + 0, + null + ) + } + ) + } .homePageAnimation( state, if (config.homeComponent.drawBackground) {