diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.desktop.kt index e653c129849ea..eeb8daeee702f 100644 --- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.desktop.kt +++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.desktop.kt @@ -49,6 +49,8 @@ import androidx.compose.ui.input.pointer.PointerType import androidx.compose.ui.isClearFocusOnMouseDownEnabled import androidx.compose.ui.navigationevent.BackNavigationEventInput import androidx.compose.ui.platform.AwtDragAndDropManager +import androidx.compose.ui.platform.Clipboard +import androidx.compose.ui.platform.ClipboardManager import androidx.compose.ui.platform.DefaultInputModeManager import androidx.compose.ui.platform.DelegateRootForTestListener import androidx.compose.ui.platform.DesktopTextInputService @@ -60,12 +62,19 @@ import androidx.compose.ui.platform.PlatformContext import androidx.compose.ui.platform.PlatformDragAndDropManager import androidx.compose.ui.platform.PlatformTextInputMethodRequest import androidx.compose.ui.platform.PlatformWindowContext +import androidx.compose.ui.platform.UriHandler import androidx.compose.ui.platform.TaskDispatchers import androidx.compose.ui.platform.ViewConfiguration import androidx.compose.ui.platform.WindowInfo import androidx.compose.ui.platform.a11y.ComposeSceneAccessibility +import androidx.compose.ui.platform.createPlatformClipboard +import androidx.compose.ui.platform.createPlatformClipboardManager +import androidx.compose.ui.platform.createPlatformUriHandler import androidx.compose.ui.scene.skia.SkiaLayerComponent import androidx.compose.ui.semantics.SemanticsOwner +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.createFontFamilyResolver +import androidx.compose.ui.text.platform.FontLoader import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.IntRect @@ -871,6 +880,24 @@ internal class ComposeSceneMediator( DefaultInputModeManager() } + override val clipboard: Clipboard by lazy(LazyThreadSafetyMode.NONE) { + createPlatformClipboard() + } + override val clipboardManager: ClipboardManager by lazy(LazyThreadSafetyMode.NONE) { + createPlatformClipboardManager() + } + + override val uriHandler: UriHandler by lazy(LazyThreadSafetyMode.NONE) { + createPlatformUriHandler() + } + + override val fontFamilyResolver: FontFamily.Resolver by lazy(LazyThreadSafetyMode.NONE) { + createFontFamilyResolver() + } + override val fontLoader: FontLoader by lazy(LazyThreadSafetyMode.NONE) { + FontLoader() + } + override val textInputService get() = this@ComposeSceneMediator.textInputService override suspend fun startInputMethod(request: PlatformTextInputMethodRequest): Nothing { diff --git a/compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.ios.kt b/compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.ios.kt index 7b727bb295c52..8766ba73b8743 100644 --- a/compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.ios.kt +++ b/compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.ios.kt @@ -47,7 +47,6 @@ import androidx.compose.ui.input.pointer.PointerButton import androidx.compose.ui.input.pointer.PointerButtons import androidx.compose.ui.input.pointer.PointerEventType import androidx.compose.ui.input.pointer.PointerId -import androidx.compose.ui.input.pointer.PointerKeyboardModifiers import androidx.compose.ui.input.pointer.PointerType import androidx.compose.ui.input.pointer.isAltPressed import androidx.compose.ui.input.pointer.isCtrlPressed @@ -77,6 +76,23 @@ import androidx.compose.ui.uikit.LocalNativeTextInputContext import androidx.compose.ui.uikit.LocalUIView import androidx.compose.ui.uikit.OnFocusBehavior import androidx.compose.ui.uikit.density +import androidx.compose.ui.uikit.toNanoSeconds +import androidx.compose.ui.input.key.internal +import androidx.compose.ui.input.key.type +import androidx.compose.ui.input.pointer.PointerKeyboardModifiers +import androidx.compose.ui.input.pointer.isAltPressed +import androidx.compose.ui.input.pointer.isCtrlPressed +import androidx.compose.ui.input.pointer.isMetaPressed +import androidx.compose.ui.input.pointer.isShiftPressed +import androidx.compose.ui.platform.Clipboard +import androidx.compose.ui.platform.ClipboardManager +import androidx.compose.ui.platform.UriHandler +import androidx.compose.ui.platform.createPlatformClipboard +import androidx.compose.ui.platform.createPlatformClipboardManager +import androidx.compose.ui.platform.createPlatformUriHandler +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.createFontFamilyResolver +import androidx.compose.ui.text.platform.FontLoader import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.DpOffset @@ -918,6 +934,24 @@ internal class ComposeSceneMediator( CupertinoHapticFeedback() } + override val clipboard: Clipboard by lazy(LazyThreadSafetyMode.NONE) { + createPlatformClipboard() + } + override val clipboardManager: ClipboardManager by lazy(LazyThreadSafetyMode.NONE) { + createPlatformClipboardManager() + } + + override val uriHandler: UriHandler by lazy(LazyThreadSafetyMode.NONE) { + createPlatformUriHandler() + } + + override val fontFamilyResolver: FontFamily.Resolver by lazy(LazyThreadSafetyMode.NONE) { + createFontFamilyResolver() + } + override val fontLoader: FontLoader by lazy(LazyThreadSafetyMode.NONE) { + FontLoader() + } + override fun convertLocalToWindowPosition(localPosition: Offset): Offset = windowContext.convertLocalToWindowPosition(_overlayView, localPosition) diff --git a/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/node/RootNodeOwner.skiko.kt b/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/node/RootNodeOwner.skiko.kt index 14b0cadb41ac1..f31859f54d1b0 100644 --- a/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/node/RootNodeOwner.skiko.kt +++ b/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/node/RootNodeOwner.skiko.kt @@ -66,17 +66,15 @@ import androidx.compose.ui.input.rotary.RotaryScrollEvent import androidx.compose.ui.layout.RootMeasurePolicy import androidx.compose.ui.layout.RulerProviderModifierElement import androidx.compose.ui.modifier.ModifierLocalManager -import androidx.compose.ui.platform.DefaultAccessibilityManager import androidx.compose.ui.platform.DelegatingSoftwareKeyboardController import androidx.compose.ui.platform.PlatformContext import androidx.compose.ui.platform.PlatformRootForTest import androidx.compose.ui.platform.PlatformTextInputMethodRequest import androidx.compose.ui.platform.PlatformTextInputSessionScope import androidx.compose.ui.platform.PlatformWindowInsets +import androidx.compose.ui.platform.SoundEffect import androidx.compose.ui.platform.TaskDispatchers -import androidx.compose.ui.platform.createPlatformClipboard -import androidx.compose.ui.platform.createPlatformClipboardManager -import androidx.compose.ui.platform.createPlatformUriHandler +import androidx.compose.ui.platform.UriHandler import androidx.compose.ui.scene.ComposeScene import androidx.compose.ui.scene.ComposeSceneInputHandler import androidx.compose.ui.scene.ComposeScenePointer @@ -87,8 +85,9 @@ import androidx.compose.ui.semantics.isTraversalGroup import androidx.compose.ui.semantics.semantics import androidx.compose.ui.spatial.RectManager import androidx.compose.ui.text.InternalTextApi -import androidx.compose.ui.text.font.createFontFamilyResolver +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.TextInputService +import androidx.compose.ui.text.platform.FontLoader import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.IntSize @@ -475,21 +474,21 @@ internal class RootNodeOwner( override val rootForTest get() = this@RootNodeOwner.rootForTest override val hapticFeedBack get() = platformContext.hapticFeedback override val inputModeManager get() = platformContext.inputModeManager - override val clipboardManager = createPlatformClipboardManager() - override val clipboard = createPlatformClipboard() - override val accessibilityManager = DefaultAccessibilityManager() + override val clipboardManager get() = platformContext.clipboardManager + override val clipboard get() = platformContext.clipboard + override val accessibilityManager get() = platformContext.accessibilityManager override val graphicsContext get() = this@RootNodeOwner.graphicsContext override val textToolbar get() = platformContext.textToolbar @Suppress("DEPRECATION") - override val autofillTree = androidx.compose.ui.autofill.AutofillTree() + override val autofillTree get() = platformContext.autofillTree @Suppress("DEPRECATION") override val autofill: androidx.compose.ui.autofill.Autofill? - get() = null + get() = platformContext.autofill - // TODO https://youtrack.jetbrains.com/issue/CMP-1572 - override val autofillManager: AutofillManager? get() = null + // TODO https://youtrack.jetbrains.com/issue/CMP-7485 + override val autofillManager: AutofillManager? get() = platformContext.autofillManager override val density get() = this@RootNodeOwner.density override val textInputService by lazy(LazyThreadSafetyMode.NONE) { TextInputService(platformContext.textInputService) @@ -544,20 +543,18 @@ internal class RootNodeOwner( PointerIconServiceImpl() } - override val uriHandler by lazy(LazyThreadSafetyMode.NONE) { createPlatformUriHandler() } - + override val uriHandler : UriHandler get() = platformContext.uriHandler + override val soundEffect: SoundEffect get() = platformContext.soundEffect override val semanticsOwner = SemanticsOwner(root, rootSemanticsNode, layoutNodes) override val windowInfo get() = platformContext.windowInfo override val taskDispatchers: TaskDispatchers get() = platformContext.taskDispatchers - @ExperimentalMediaQueryApi override val uiMediaScope: UiMediaScope get() = platformContext.mediaScope override val retainedValuesStore: RetainedValuesStore get() = ForgetfulRetainedValuesStore override val rectManager = RectManager(layoutNodes) - @Suppress("OVERRIDE_DEPRECATION", "DEPRECATION") - override val fontLoader = androidx.compose.ui.text.platform.FontLoader() - override val fontFamilyResolver = createFontFamilyResolver() + override val fontLoader: FontLoader get() = platformContext.fontLoader + override val fontFamilyResolver: FontFamily.Resolver get() = platformContext.fontFamilyResolver override val layoutDirection get() = _layoutDirection override val localeList get() = platformContext.localeList override var showLayoutBounds by mutableStateOf(false) @@ -1004,4 +1001,4 @@ private object IdentityPositionCalculator : PositionCalculator { } private fun Modifier.rulerProvider(windowInsets: PlatformWindowInsets) = - if (ComposeUiFlags.areWindowInsetsRulersEnabled) then(RulerProviderModifierElement(windowInsets)) else this \ No newline at end of file + if (ComposeUiFlags.areWindowInsetsRulersEnabled) then(RulerProviderModifierElement(windowInsets)) else this diff --git a/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/DefaultAccessibilityManager.skiko.kt b/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/DefaultAccessibilityManager.skiko.kt deleted file mode 100644 index b487c98374b07..0000000000000 --- a/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/DefaultAccessibilityManager.skiko.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package androidx.compose.ui.platform - -internal class DefaultAccessibilityManager : AccessibilityManager { - override fun calculateRecommendedTimeoutMillis( - originalTimeoutMillis: Long, - containsIcons: Boolean, - containsText: Boolean, - containsControls: Boolean - ): Long { - return originalTimeoutMillis - } -} diff --git a/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/PlatformContext.skiko.kt b/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/PlatformContext.skiko.kt index 74318ced1baa8..e6c2101f6b9b3 100644 --- a/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/PlatformContext.skiko.kt +++ b/compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/PlatformContext.skiko.kt @@ -24,6 +24,8 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalMediaQueryApi import androidx.compose.ui.FrameRateCategory import androidx.compose.ui.InternalComposeUiApi +import androidx.compose.ui.autofill.AutofillManager +import androidx.compose.ui.autofill.AutofillTree import androidx.compose.ui.UiMediaScope import androidx.compose.ui.focus.FocusDirection import androidx.compose.ui.focus.FocusManager @@ -44,11 +46,14 @@ import androidx.compose.ui.scene.CanvasLayersComposeScene import androidx.compose.ui.scene.ComposeScene import androidx.compose.ui.semantics.SemanticsNode import androidx.compose.ui.semantics.SemanticsOwner +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.createFontFamilyResolver import androidx.compose.ui.text.input.EditCommand import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeOptions import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.intl.LocaleList +import androidx.compose.ui.text.platform.FontLoader import androidx.compose.ui.unit.Dp import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner @@ -228,6 +233,26 @@ interface PlatformContext { */ val prefetchScheduler: PlatformPrefetchScheduler get() = NoOpPlatformPrefetchScheduler + val accessibilityManager: AccessibilityManager get() = NoOpAccessibilityManager + + val clipboard : Clipboard + + @Suppress("DEPRECATION") + val clipboardManager : ClipboardManager + + @Suppress("DEPRECATION") + val autofillTree : AutofillTree + get() = AutofillTree() + + @Suppress("DEPRECATION") + val autofill: androidx.compose.ui.autofill.Autofill? + get() = null + + // TODO https://youtrack.jetbrains.com/issue/CMP-7485 + val autofillManager: AutofillManager? + get() = null + + val uriHandler : UriHandler /** * Media-related information exposed to the composition. * @@ -240,6 +265,14 @@ interface PlatformContext { @ExperimentalMediaQueryApi val mediaScope: UiMediaScope get() = EmptyMediaScope + @Suppress("DEPRECATION") + val fontLoader: FontLoader + + val fontFamilyResolver: FontFamily.Resolver + + val soundEffect: SoundEffect + get() = NoSoundEffect + interface RootForTestListener { fun onRootForTestCreated(root: PlatformRootForTest) fun onRootForTestDisposed(root: PlatformRootForTest) @@ -292,6 +325,21 @@ interface PlatformContext { override val inputModeManager: InputModeManager by lazy(LazyThreadSafetyMode.NONE) { DefaultInputModeManager() } + override val clipboard: Clipboard by lazy(LazyThreadSafetyMode.NONE) { + createPlatformClipboard() + } + override val clipboardManager: ClipboardManager by lazy(LazyThreadSafetyMode.NONE) { + createPlatformClipboardManager() + } + override val uriHandler: UriHandler by lazy(LazyThreadSafetyMode.NONE) { + createPlatformUriHandler() + } + override val fontFamilyResolver: FontFamily.Resolver by lazy(LazyThreadSafetyMode.NONE) { + createFontFamilyResolver() + } + override val fontLoader: FontLoader by lazy(LazyThreadSafetyMode.NONE) { + FontLoader() + } } // This object must be immutable because it is used as a delegate in other ViewConfiguration @@ -317,6 +365,16 @@ private object EmptyPlatformScreenReader : PlatformScreenReader { override val isActive: Boolean = false } +private object NoOpAccessibilityManager : AccessibilityManager { + override fun calculateRecommendedTimeoutMillis( + originalTimeoutMillis: Long, + containsIcons: Boolean, + containsText: Boolean, + containsControls: Boolean + ): Long = originalTimeoutMillis + +} + private object NoOpPlatformPrefetchScheduler : PlatformPrefetchScheduler { override fun scheduleHighPriorityPrefetch(request: PlatformPrefetchRequest) = Unit