Skip to content

Expose LinuxWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners#188917

Merged
robert-ancell merged 3 commits into
flutter:masterfrom
canonical:third-party-linux-windowing
Jul 8, 2026
Merged

Expose LinuxWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners#188917
robert-ancell merged 3 commits into
flutter:masterfrom
canonical:third-party-linux-windowing

Conversation

@mattkae

@mattkae mattkae commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

While authoring https://github.com/mattkae/layer_shell.dart, I realized that the Linux Windowing platform had a few major problems when it came to extending it for out-of-tree windowing owners:

  1. 3rd party windows could not register in the _windows or _views maps, which meant that they could never be parents. This is invalid, as other windows (e.g. layer shell windows) may indeed want to be valid parents and open popups. For example, a top panel may want to open a sound control dropdown.
  2. I wanted to extend RegularWindowLinux, but that was unfortunately not possible because the regular windows realize themselves by the time the constructor returns. Gtk layer shell windows require that the window become layer shell before it is realized. We could have added an odd flag to the regular window, but that felt like duct-tape over a larger issue whereby an external author could NOT do anything sufficiently complex with the current API.

What's new?

  • Created a GtkWindowRegistrar that can be used to register and unregister 3rd party windows

Associated PR: mattkae/layer_shell.dart#1

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 2, 2026
@mattkae
mattkae marked this pull request as ready for review July 2, 2026 15:08
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Linux windowing implementation by introducing a GtkWindowRegistrar to track native GTK windows and Flutter views, and exposes previously private classes and enums as @internal public types. The review feedback suggests marking GtkWindowRegistrar as final, adding assertions to prevent duplicate registrations, throwing specific StateErrors instead of generic Exceptions when lookups fail, and removing obsolete // ignore: unused_field comments from the newly exposed enums.

Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
@mattkae mattkae added the CICD Run CI/CD label Jul 2, 2026
@robert-ancell

robert-ancell commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Two things immediately come to mind:

  • Should this be LinuxWindow, not GtkWindow to match the existing public naming style.
  • Should Gtk/LinuxWindow contain _GtkWindow and not expose this detail to the user. We're adding a lot of API and potential footguns. I think the user should just provide the GtkWindow* pointer and it is up to them to control everything in native code or via their own FFI APIs.

@mattkae mattkae changed the title Expose Gtk objects on _window_linux.dart in order to better support out of tree LinuxWindowingOwners Expose GtkWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners Jul 6, 2026
@mattkae
mattkae force-pushed the third-party-linux-windowing branch from 7cb600e to a3d1155 Compare July 6, 2026 15:02
@mattkae

mattkae commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Two things immediately come to mind:

* Should this be `LinuxWindow`, not `GtkWindow` to match the existing public naming style.

* Should `Gtk/LinuxWindow` contain `_GtkWindow` and not expose this detail to the user. We're adding a lot of API and potential footguns. I think the user should just provide the `GtkWindow*` pointer and it is up to them to control everything in native code or via their own FFI APIs.

I removed a lot of the publicizing here in favor of just exposing GtkWindowRegistrar. Out of tree windowing owners can just implement the FFI bits themselves

@mattkae mattkae changed the title Expose GtkWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners Expose LinuxWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners Jul 8, 2026

@robert-ancell robert-ancell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@robert-ancell
robert-ancell added this pull request to the merge queue Jul 8, 2026
Merged via the queue into flutter:master with commit 5616240 Jul 8, 2026
87 checks passed
@robert-ancell
robert-ancell deleted the third-party-linux-windowing branch July 8, 2026 21:56
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 10, 2026
…12169)

Manual roll Flutter from 91939cc4db78 to dc2a8703e12b (50 revisions)

Manual roll requested by [email protected]

flutter/flutter@91939cc...dc2a870

2026-07-09 [email protected] [ios,macos] Update swiftc.py flags to match swiftc (flutter/flutter#189174)
2026-07-09 [email protected] [AGP 9] Update Warn Version to AGP 9+ (flutter/flutter#189109)
2026-07-09 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#189203)
2026-07-09 [email protected] [web] Roll Chrome to 145 (framework) (flutter/flutter#182861)
2026-07-09 [email protected] Roll Packages from 52d84d6 to 20928d5 (6 revisions) (flutter/flutter#189194)
2026-07-09 [email protected] [web] Avoid absolute positioning for base CanvasKit canvas (flutter/flutter#188337)
2026-07-09 [email protected] Roll Dart SDK from cdb7217e65aa to a11fb7ed40a5 (6 revisions) (flutter/flutter#189195)
2026-07-09 [email protected] Fix dereference of nullptr in the moved-to-rect signal in the Linux embedder (flutter/flutter#189152)
2026-07-09 [email protected] Fix data for design packages (flutter/flutter#189140)
2026-07-09 [email protected] Roll Skia from 7b42d1251d54 to ab3a7b98c94d (2 revisions) (flutter/flutter#189181)
2026-07-09 [email protected] Roll Skia from 05d9d214e0b7 to 7b42d1251d54 (2 revisions) (flutter/flutter#189175)
2026-07-09 [email protected] Roll Skia from 542c8bdd7f4f to 05d9d214e0b7 (4 revisions) (flutter/flutter#189169)
2026-07-09 [email protected] UberSDF rect handling for thin (line-like) rectangles (flutter/flutter#188821)
2026-07-09 [email protected] Roll Skia from dd572c07f63c to 542c8bdd7f4f (4 revisions) (flutter/flutter#189160)
2026-07-09 [email protected] [flutter_tools] Fix hot restart for WASM web builds (flutter/flutter#187898)
2026-07-08 [email protected] Split FlViewRenderer into OpenGL and software backends (flutter/flutter#188824)
2026-07-08 [email protected] Promote android_hardware_smoke_tests out of bringup in CI (flutter/flutter#189081)
2026-07-08 [email protected] Roll Skia from 8df24be66531 to dd572c07f63c (4 revisions) (flutter/flutter#189150)
2026-07-08 [email protected] Expose LinuxWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners (flutter/flutter#188917)
2026-07-08 [email protected] Roll pub packages (flutter/flutter#189149)
2026-07-08 [email protected] fix(ci): harden some workflows (flutter/flutter#189087)
2026-07-08 [email protected] Roll Skia from 51a62da33da0 to 8df24be66531 (1 revision) (flutter/flutter#189139)
2026-07-08 [email protected] Roll Dart SDK to Dart 3.13 beta3 (flutter/flutter#189122)
2026-07-08 [email protected] [flutter_tools] Don't crash on non-UTF-8 plugin pubspec.yaml (flutter/flutter#188976)
2026-07-08 [email protected] [flutter_tools] Watch transitive #include headers for FragmentProgram hot reload (flutter/flutter#187945)
2026-07-08 [email protected] Roll Skia from 040d9f55de00 to 51a62da33da0 (1 revision) (flutter/flutter#189135)
2026-07-08 [email protected] Roll Packages from 92525f5 to 52d84d6 (7 revisions) (flutter/flutter#189134)
2026-07-08 [email protected] [flutter_tools] Forcefully kill hung subprocesses 5 seconds after timeout (flutter/flutter#187178)
2026-07-08 [email protected] Expose the app's build name and number as compile-time constants (flutter/flutter#187935)
2026-07-08 [email protected] Roll Skia from 1ff92f879815 to 040d9f55de00 (1 revision) (flutter/flutter#189131)
2026-07-08 [email protected] Roll Skia from 6137414bef5c to 1ff92f879815 (6 revisions) (flutter/flutter#189126)
2026-07-08 [email protected] [test cross imports] More test/rendering + flutter_test/test fixes (flutter/flutter#188954)
2026-07-08 [email protected] engine: explain why each candidate build was skipped in Flutter web loader (flutter/flutter#186254)
2026-07-08 [email protected] vscode: add missing unicode.h (flutter/flutter#189102)
2026-07-08 [email protected] Roll Fuchsia Linux SDK from 7RjQJBW3m-3Jl-7jr... to QcRFUtvCw2EobfJ8s... (flutter/flutter#189104)
2026-07-08 [email protected] Roll Skia from 075fbe4778d9 to 6137414bef5c (10 revisions) (flutter/flutter#189106)
2026-07-08 [email protected] engine: warn on WASM load failure when not crossOriginIsolated (flutter/flutter#186252)
2026-07-08 [email protected] Roll Dart SDK from c9bccc09e733 to db2155f56bf3 (2 revisions) (flutter/flutter#189105)
2026-07-08 [email protected] [flutter_tools] Prevent interactive device selection in machine mode (flutter/flutter#188267)
2026-07-08 [email protected] [flutter_tools] Fix wireless ADB device discovery when serial contains spaces (flutter/flutter#187943)
2026-07-07 [email protected] [web] Fix grouped autofill on iOS Chrome (flutter/flutter#187459)
2026-07-07 [email protected] Fix TextSelectionOverlay crash when layout is degenerate (flutter/flutter#188672)
2026-07-07 [email protected] [flutter_tools] Provision Android NDK in the main Gradle invocation (flutter/flutter#186337)
2026-07-07 [email protected] Android_hardware_smoke_test: Migrate to AGP 9 (flutter/flutter#189082)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants