Skip to content

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

Merged
Alexander Maryanovsky (m-sasha) merged 4 commits into
jb-mainfrom
m-sasha/public-local-window
Apr 28, 2026
Merged

Rename LocalWindow to LocalAwtWindow, make it public and provide it in ComposePanel#3007
Alexander Maryanovsky (m-sasha) merged 4 commits into
jb-mainfrom
m-sasha/public-local-window

Conversation

@m-sasha

Copy link
Copy Markdown

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.

@MatkovIvan Ivan Matkov (MatkovIvan) left a comment

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.

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

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.

* [ImageComposeScene].
*/
@ExperimentalComposeUiApi
val LocalAwtWindow = compositionLocalOf<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.

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

* [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

@m-sasha Alexander Maryanovsky (m-sasha) Apr 23, 2026

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.

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 Alexander Maryanovsky (m-sasha) merged commit d813291 into jb-main Apr 28, 2026
33 of 34 checks passed
@m-sasha Alexander Maryanovsky (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