Skip to content

Commit bb993fa

Browse files
fix(build): honor [tool.flet.app].hide_window_on_start in Windows runner (#6562)
* fix(build): honor [tool.flet.app].hide_window_on_start in Windows runner The packaged Windows app showed its window on startup even when `hide_window_on_start = true` was set in pyproject.toml. The Dart-side `setupDesktop()` correctly skipped its own `windowManager.show()`, but the native Win32 runner (flutter_window.cpp) only consulted the `FLET_HIDE_WINDOW_ON_START` env var and unconditionally called `Show()` on the first frame, so the pyproject toggle had no effect. Templatize the runner with the same `tool.flet.<platform>.app.hide_window_on_start` / `tool.flet.app.hide_window_on_start` lookup already used by main.dart, and OR the baked-in value with the env-var check so either source hides the window at startup. * docs(linux): document build prerequisites and Wayland window positioning Add a Prerequisites section listing the apt packages required to build Flet Linux apps (matching linux_deps.py), noting that lld is required and that the GStreamer/mpv packages are for the Audio service and Video control. Also document that programmatic window positioning (Page.window.center(), left/top, move) is a no-op on Wayland (compositor-controlled) and works on X11/XWayland, with the GDK_BACKEND=x11 workaround. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 68dea98 commit bb993fa

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

sdk/python/templates/build/{{cookiecutter.out_dir}}/windows/runner/flutter_window.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{%- set hide_window_on_start = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".app.hide_window_on_start")
2+
or get_pyproject("tool.flet.app.hide_window_on_start") -%}
13
#include "flutter_window.h"
24

35
#include <optional>
@@ -29,6 +31,7 @@ bool FlutterWindow::OnCreate() {
2931
SetChildContent(flutter_controller_->view()->GetNativeWindow());
3032

3133
const bool hide_window_on_start =
34+
{{ "true" if hide_window_on_start else "false" }} ||
3235
HasEnvironmentVariable(L"FLET_HIDE_WINDOW_ON_START");
3336
flutter_controller_->engine()->SetNextFrameCallback([this,
3437
hide_window_on_start]() {

website/docs/publish/linux.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,89 @@ This guide provides detailed Linux-specific information.
99
Complementary and more general information is available [here](index.md).
1010
:::
1111

12+
## Prerequisites
13+
14+
Flet uses [Flutter](https://flutter.dev) to build Linux apps. Compiling the app
15+
and its native plugins links against GTK and a number of system libraries, so
16+
these must be installed before running `flet build linux`.
17+
18+
On Debian/Ubuntu-based distributions, install the required packages with `apt`:
19+
20+
```bash
21+
sudo apt update
22+
sudo apt install -y \
23+
binutils clang cmake llvm lld ninja-build pkg-config \
24+
libgtk-3-dev libsecret-1-0 libsecret-1-dev libunwind-dev \
25+
gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-libav \
26+
gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
27+
gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio gstreamer1.0-qt5 \
28+
gstreamer1.0-tools gstreamer1.0-x \
29+
libasound2-dev libgstreamer1.0-dev \
30+
libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev \
31+
libmpv-dev mpv
32+
```
33+
34+
This is the same set of packages Flet uses in its own build environment. A few
35+
notes on what they are for:
36+
37+
- **Build toolchain**`clang`, `cmake`, `ninja-build`, `pkg-config`, `llvm`,
38+
`lld`, `binutils` and `libgtk-3-dev` are required to compile and link the app.
39+
In particular, the `lld` linker must be present — without it the build fails
40+
with a linker error.
41+
- **Secret storage**`libsecret-1-0` and `libsecret-1-dev` are used for secure
42+
storage / keyring access.
43+
- **Audio and video** — the `gstreamer1.0-*`, `libgstreamer*-dev`,
44+
`libasound2-dev`, `libmpv-dev` and `mpv` packages are required by the
45+
[`Audio`](../services/audio/index.md#usage) service and
46+
[`Video`](../controls/video/index.md#linux) control. You can omit them if your
47+
app does not play media, but installing the full set above avoids surprises.
48+
See those pages for control-specific details.
49+
50+
:::note[Other distributions]
51+
Package names differ on non-Debian distributions (e.g. Fedora, Arch). Install
52+
the equivalent GTK 3, GStreamer, `mpv`/`libmpv`, `libsecret`, `clang`/`llvm`,
53+
`lld`, `cmake` and `ninja` development packages for your distribution.
54+
:::
55+
1256
## `flet build linux`
1357

1458
:::note[Note]
1559
This command can be run on **Linux only** (or [WSL](https://docs.microsoft.com/en-us/windows/wsl/about)).
1660
:::
1761

1862
Builds a Linux executable.
63+
64+
## Window positioning on Wayland
65+
66+
On Linux the **display server** controls window placement, and this differs
67+
between X11 and Wayland:
68+
69+
- **X11** lets applications set their own top-level window position.
70+
- **Wayland** (the default session on modern GNOME/Ubuntu) does **not** — by
71+
design, a client cannot position its own top-level window; the compositor
72+
(e.g. Mutter) decides where windows are placed.
73+
74+
As a result, on a Wayland session the following have **no effect** (window
75+
*sizing* still works — only positioning is restricted):
76+
77+
- [`Page.window.center()`](../types/window.md)
78+
- setting [`Page.window.left`](../types/window.md) / `Page.window.top`
79+
- moving the window programmatically
80+
81+
This is a Wayland protocol limitation, not a Flet bug. The same code works as
82+
expected on Windows, macOS, Linux X11 sessions, and Wayland sessions running the
83+
app through **XWayland**.
84+
85+
To force the X11 backend (XWayland) on a Wayland session and re-enable
86+
programmatic positioning, run the app with the `GDK_BACKEND` environment
87+
variable:
88+
89+
```bash
90+
GDK_BACKEND=x11 ./your_app
91+
```
92+
93+
You can check the current session type with:
94+
95+
```bash
96+
echo $XDG_SESSION_TYPE # "wayland" or "x11"
97+
```

0 commit comments

Comments
 (0)