Sitelet https://github.com/flutter/flutter/pull/192356
Skip to content

[Linux] Add window rendering and drag controls - #192356

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
robert-ancell:linux-undecorated
Sep 10, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
robert-ancell:linux-undecorated

Conversation

@robert-ancell

Copy link
Copy Markdown
Contributor

Add Linux specific calls that give an app more control over how its window is rendered and let it move and resize itself:

  • setDecorated() turns off the titlebar and border drawn by GTK.

  • setAppPaintable() stops GTK filling the window with the background color of the theme, and setBackgroundColor() sets the color the view clears to instead, so a window can be transparent where the app does not paint.

  • beginMoveDrag() and beginResizeDrag() hand a pointer press over to the window manager, which then moves or resizes the window itself. Resizing takes a WindowDragEdge saying which edge or corner is being dragged.

Windows are also given a visual with an alpha channel where the screen is composited, as one can only be chosen before a window is realized.

Add Linux specific calls that give an app more control over how its
window is rendered and let it move and resize itself:

 * setDecorated() turns off the titlebar and border drawn by GTK.

 * setAppPaintable() stops GTK filling the window with the background
   color of the theme, and setBackgroundColor() sets the color the view
   clears to instead, so a window can be transparent where the app does
   not paint.

 * beginMoveDrag() and beginResizeDrag() hand a pointer press over to
   the window manager, which then moves or resizes the window itself.
   Resizing takes a WindowDragEdge saying which edge or corner is being
   dragged.

Windows are also given a visual with an alpha channel where the screen
is composited, as one can only be chosen before a window is realized.
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 7, 2026
@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.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Sep 7, 2026

@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 adds Linux-specific windowing features, including window resizing, dragging, transparency support, and background color configuration via GTK/GDK FFI bindings. Feedback suggests adding a destruction check in setDecorated to prevent crashes, using an explicit switch expression instead of .index mapping for enums to improve safety, and wrapping FFI memory allocations in a try-finally block to avoid memory leaks.

Comment thread packages/flutter/lib/src/widgets/_window_linux.dart
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart
Using a destroyed window passes a freed pointer to GTK. The other calls
on a window controller check for this first, so make setDecorated() do
the same, and document it as the others are.

@mattkae mattkae 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.

A few things!

Comment thread packages/flutter/lib/src/widgets/_window_linux.dart
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated
Comment thread packages/flutter/lib/src/widgets/_window_linux.dart Outdated

@mattkae mattkae 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.

Happy camper 🏕️

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