Skip to content

Rename LocalWindow to LocalAwtWindow, make it public and provide it in ComposePanel#3007

Merged
m-sasha merged 4 commits intojb-mainfrom
m-sasha/public-local-window
Apr 28, 2026
Merged

Rename LocalWindow to LocalAwtWindow, make it public and provide it in ComposePanel#3007
m-sasha merged 4 commits intojb-mainfrom
m-sasha/public-local-window

Conversation

@m-sasha
Copy link
Copy Markdown

@m-sasha m-sasha commented Apr 23, 2026

Rename LocalWindow to LocalAwtWindow, make it public and provide it in ComposePanel

Testing

Added unit tests.

Release Notes

Features - Desktop

  • The parent AWT window of a composition is now available via LocalAwtWindow.current.

Copy link
Copy Markdown
Collaborator

@MatkovIvan MatkovIvan left a comment

Choose a reason for hiding this comment

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

Why is it needed?

Comment thread compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/LocalAwtWindow.kt Outdated
@m-sasha
Copy link
Copy Markdown
Author

m-sasha commented Apr 23, 2026

Why is it needed?

I don't need it public, but it is useful I think.
I do need it provided in ComposePanel, to be able to correctly show DialogWindows from there.

@m-sasha m-sasha force-pushed the m-sasha/public-local-window branch from 932fef3 to 7e2ef2d Compare April 23, 2026 15:27
* [ImageComposeScene].
*/
@ExperimentalComposeUiApi
val LocalAwtWindow = compositionLocalOf<java.awt.Window?> { null } No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
val LocalAwtWindow = compositionLocalOf<java.awt.Window?> { null }
val LocalAwtWindow = staticCompositionLocalOf<java.awt.Window?> { null }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@m-sasha m-sasha requested review from MatkovIvan and igordmn April 23, 2026 19:41
* [ImageComposeScene].
*/
@ExperimentalComposeUiApi
val LocalAwtWindow = staticCompositionLocalOf<java.awt.Window?> { null } No newline at end of file
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.

Maybe it's better to provide a way to get Component where Compose is attached? SwingUtilities.getWindowAncestor might be called outside on the usage side

Copy link
Copy Markdown
Author

@m-sasha m-sasha Apr 23, 2026

Choose a reason for hiding this comment

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

We could do that too, but if you just have the component, you won't know about the window changing (if it's removed and added somewhere else). At least not without adding AWT listeners, at which point I think it's too much AWT knowledge that we'd be asking from the developer.

It would also raise the question: which component exactly we'd want to report as "the" component.

@m-sasha m-sasha requested a review from MatkovIvan April 24, 2026 14:33
@m-sasha m-sasha merged commit d813291 into jb-main Apr 28, 2026
33 of 34 checks passed
@m-sasha m-sasha deleted the m-sasha/public-local-window branch April 28, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants