New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ComposePanel that can be disposed manually #620
Conversation
Just as an alternative option, you could put a |
We discussed this flag with @igordmn and decided that flag that controls behavior is much worse than inheritance |
From another PR:
|
I'm not a big believer in "experts" and their generic advice. But anyway, I'm just suggesting... |
My thought was to have smth like this, so this boolean param it not exposed. It is used internally and only inside removeNotify class ComposePanel internal constructor(
private val skiaLayerAnalytics: SkiaLayerAnalytics,
private val autoDisposable: Boolean,
) : JLayeredPane() {
@ExperimentalComposeUiApi
constructor(
panelScope: CoroutineScope,
skiaLayerAnalytics: SkiaLayerAnalytics = SkiaLayerAnalytics.Empty
) : this(skiaLayerAnalytics, autoDisposable = false) {
panelScope.launch {
try {
awaitCancellation()
} finally {
dispose()
}
}
} |
Also, we have |
Honestly, choosing from these two, I would choose a boolean flag here |
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposePanel.desktop.kt
Outdated
Show resolved
Hide resolved
d120ba2
to
658ccaf
Compare
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposePanel.desktop.kt
Show resolved
Hide resolved
So, ComposePanel can be disposed manually or automatically on `removeNotify`
658ccaf
to
cabbcbf
Compare
…o there won't be paint requests
* Allow change ComposePanel dispose behavior by `isDisposeOnRemove` So, ComposePanel can be disposed manually or automatically on `removeNotify`
* Allow change ComposePanel dispose behavior by `isDisposeOnRemove` So, ComposePanel can be disposed manually or automatically on `removeNotify`
This is an imported pull request from androidx#620. Rewrite to using providers for getting HEAD SHA and changed files information from either MANIFEST and CHANGE_INFO files or git if these env variables are not set. Resolves #620 Github-Pr-Head-Sha: 75a21ad GitOrigin-RevId: 1baae30 Test: updated tests to match the new code structure Bug: 303481898 Change-Id: I227ed2997280d4b41ba9d38c4ed5e8224843feef
Proposed Changes
Current implementation of ComposePanel disposes Compose content on each detach from Swing hierarchy. But for some cases (like toolwindows in IntelliJ) it doesn't work well, since state getting lost. This state can be controlled only externally. For example, in IntelliJ
Disposable
is used for that.This PR adds the
ComposePanel.isDisposeOnRemove
property. By default, it is true. If it is false, the Compose state will be preserved when the ComposePanel is removed from the UI hierarchy. In this case, the Compose state must be controlled by developers - they must callComposePanel.dispose()
manually.Testing
Test: run introduced test
Issues Fixed
No issues related to this PR