Skip to content

Window Insets support for Compose for Web#3202

Open
Konstantin (terrakok) wants to merge 8 commits into
jb-mainfrom
CMP-10141
Open

Window Insets support for Compose for Web#3202
Konstantin (terrakok) wants to merge 8 commits into
jb-mainfrom
CMP-10141

Conversation

@terrakok

@terrakok Konstantin (terrakok) commented Jul 7, 2026

Copy link
Copy Markdown
Member

Added support for system window insets on Web. Compose scenes can now render edge-to-edge while respecting the safe area and the keyboard, exposing everything through the standard WindowInsets APIs (WindowInsets.safeDrawing, WindowInsets.ime, etc.).

compressO-Recording.2026-07-07.at.15-33-34.mp4

New experimental API

A new configuration flag on ComposeViewportConfiguration:

ComposeViewport(configure = { enableBrowserWindowInsets = true }) {
    // content that reacts to WindowInsets.safeDrawing, WindowInsets.ime, ...
}
  • Defaults to false, so existing behavior is unchanged. When enabled, the scene reads safe area insets and tracks IME geometry, and reports them through the standard WindowInsets APIs.
  • Requires the page to opt in to edge-to-edge rendering via the viewport meta tag:
    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
    

Without viewport-fit=cover the browser applies safe area padding automatically and all env(safe-area-inset-*) variables return 0px, so insets would always be zero. If the flag is enabled but the meta tag is missing, a warning is logged to the console.

Fixes https://youtrack.jetbrains.com/issue/CMP-10141

Testing

Added new web tests

Release Notes

Features - Web

  • Added experimental support for system window insets on Web.

…ts` is true

Added a warning to notify developers if the `viewport-fit=cover` attribute is missing from the meta viewport tag, ensuring safe area insets are applied correctly.
…recise insets adjustments

- Added support for updating insets on canvas resize via `onCanvasResized`.
- Enhanced safe area and IME insets calculations to account for canvas position and size.
- Introduced comprehensive test coverage for `WebWindowInsetsManager`.
- Validates safe area insets, canvas offset handling, resize updates, and density conversions.
@ApoloApps

Copy link
Copy Markdown

I would still prefer to introduce the PlatformEmbeddingStrategy interface with FullPageStrategy and EmbeddedStrategy implementations (as per the youtrack issue). Much of what is explained in the enableBrowserWindowInsets KDoc can be easily understood with this API. PlatformEmbeddingStrategy can be used for other non-insets related APIs that might need different implementation in these modes

@eymar

Copy link
Copy Markdown
Member

introduce the PlatformEmbeddingStrategy interface with FullPageStrategy and EmbeddedStrategy implementations

As I understood your idea, FullPageStrategy would take care of configuring the index.html / styles for apps taking the entire viewport? Sort of simplification?
I think it's worth its a separate PR to simplify the API review process.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants