Skip to content

Clarify usage of compose.swing.render.on.graphics flag #2071

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

Open
wants to merge 4 commits into
base: jb-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal object ComposeFeatureFlags {
get() = LayerType.parse(System.getProperty("compose.layers.type"))

/**
* Indicates whether the Compose should use Swing graphics for rendering.
* Indicates whether the [androidx.compose.ui.awt.ComposePanel] should use Swing graphics for rendering.
* This prevents transitional rendering issues when panels are being shown, hidden, or resized.
* It also enables proper layering when combining Swing components and compose panels.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal class ComposeWindowPanel(
container = this,
skiaLayerAnalytics = skiaLayerAnalytics,
window = window,
useSwingGraphics = false,
useSwingGraphics = false, // Swing graphics is not supposed to be used here.
layerType = ComposeFeatureFlags.layerType.let {
// LayerType.OnComponent may can only be used with rendering via Swing graphics,
// but it's always disabled here. Using fallback instead of [check] to support
Expand Down Expand Up @@ -101,6 +101,11 @@ internal class ComposeWindowPanel(
override fun getDefaultComponent(aContainer: Container?) = null
}
isFocusCycleRoot = true

if (ComposeFeatureFlags.useSwingGraphics) {
println("Usage of \"compose.swing.render.on.graphics\" affect only behaviour of ComposePanel." +
"Usage together with ComposeWindow or ComposeDialog won't have any effect.")
}
Comment on lines +105 to +108
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about printing this. The flag is for the entire process, but you can have both ComposePanel and ComposeWindow in a single app...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. The intention here is to notify already wrong configured applications. Ideas are welcome

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a global flag, though? Can we not make it an argument to ComposePanel instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already thought about it, so yes we can. But I don't really won't to remove global flag because despite "experimental" status it's widely adopted

Copy link
Member Author

@MatkovIvan MatkovIvan May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a global flag, though?

It was introduced in #601, so for now it's "historically" I guess

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposed as another optional/experimental parameter in ComposePanel's constructor

Copy link
Member

@m-sasha m-sasha May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

As for this print, I think I personally would prefer not to pollute the output, but I'd leave the decision to @igordmn .
If we do add it, probably better to print to System.err, though (we're in desktopMain here).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is valid to open a ComposeWindow inside IntelliJ that can use a global useSwingGraphics for ComposePanel's. Because it is valid, we shouldn't print anything. A better name, something like composePanelUseSwingGraphics, wouldn't cause the issue.

As for a flag, I prefer an argument over it. For historical reasons we can either keep it, or deprecate it.

}

override fun setBounds(x: Int, y: Int, width: Int, height: Int) {
Expand Down