Skip to content

[JEWEL-1298] Fix JDialogRenderer Density Issues#3475

Open
DanielSouzaBertoldi wants to merge 1 commit intoJetBrains:masterfrom
DanielSouzaBertoldi:dsb/JEWEL-1298
Open

[JEWEL-1298] Fix JDialogRenderer Density Issues#3475
DanielSouzaBertoldi wants to merge 1 commit intoJetBrains:masterfrom
DanielSouzaBertoldi:dsb/JEWEL-1298

Conversation

@DanielSouzaBertoldi
Copy link
Copy Markdown
Collaborator

(this description was generated by jewel-pr-preparer)

JDialogRenderer had two density-related bugs affecting popup positioning and content rendering when the app overrides LocalDensity.

Changes

  • Replace LocalDensity.current with dialog.density() (the actual screen scale from graphicsConfiguration) when converting Compose layout coordinates to AWT logical pixels in withDensity — the screen scale factor is always the correct ratio here, independent of any app-level density override.
  • Fix ProvideValuesFromOtherContext to provide the ComposePanel's defaults as the outer context and the caller's composition locals as the inner context, so the caller's values (including any LocalDensity override) correctly win over ComposePanel defaults instead of being silently discarded.

Release notes

Bug fixes

  • Fixed JDialogRenderer incorrectly using LocalDensity for AWT coordinate conversion, causing popups to appear at the wrong position or size when the app overrides the Compose density.
  • Fixed ProvideValuesFromOtherContext swallowing caller-provided composition locals (such as LocalDensity) in favor of ComposePanel defaults.

Demo

Before After
Screen.Recording.2026-04-01.at.09.41.20.mov
Screen.Recording.2026-04-01.at.09.39.03.mov

@DanielSouzaBertoldi
Copy link
Copy Markdown
Collaborator Author

Yo, btw, why do we have both kotlinter and ktfmt?

We should really just stick to one of them, otherwise we get situations like in this PR, where ktfmt formats the code in a certain way that kotlinter does not like at all:

image

Even though this is pretty rare, it can happen.

I took a look at the .editorconfig file and most ktlinter rules are disabled anyways:

image

@rock3r
Copy link
Copy Markdown
Collaborator

rock3r commented Apr 2, 2026

@DanielSouzaBertoldi we can disable it if we want to, but it does check more than what ktfmt enforces IIRC

@@ -419,7 +421,7 @@ private fun Rectangle.withDensity(density: Float): Rectangle =
@Composable
private fun ProvideValuesFromOtherContext(context: CompositionLocalContext, content: @Composable () -> Unit) {
val existingContext = currentCompositionLocalContext
CompositionLocalProvider(context) { CompositionLocalProvider(existingContext, content) }
CompositionLocalProvider(existingContext) { CompositionLocalProvider(context, content) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I found an issue connected to this change, pls correct me if I'm wrong
If I enable Custom Popup Renderer and try to open Sub menus, it just disappears and i cannot open further submenus. Video is attached.
When I revert your change, it works fine.
After some discussion with AI, he told me that "a submenu is itself another popup, opened from inside the first popup, and for that nested popup to appear correctly, the submenu code must see the current popup host component, but because of the change it sees the original parent window component." Does it make any sense? 😄

Screen.Recording.2026-04-08.at.15.26.49.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants