From d67dcadd6d1d8618a5bfcf15663357480632e7c5 Mon Sep 17 00:00:00 2001 From: axel10 Date: Sat, 11 Jul 2026 12:19:40 +0800 Subject: [PATCH 1/3] fix(linux): use gtk_window_set_geometry_hints to fix window size limits Using `gdk_window_set_geometry_hints` on the lower-level `GdkWindow` causes two major issues in GTK applications: 1. If window size limits (like `setMinimumSize` or `setMaximumSize`) are set before the window is realized (which is common during application startup), `get_gdk_window` returns `nullptr` and the sizing hints are silently ignored. 2. Even after realization, GTK's high-level layout cycle can bypass or override direct changes to the low-level `GdkWindow` hints. This commit replaces `gdk_window_set_geometry_hints` with the GTK-level `gtk_window_set_geometry_hints` on the `GtkWindow` directly. This allows GTK to cache the constraints internally, applying them correctly upon window realization and respecting them during GTK layout calculation. --- packages/window_manager/linux/window_manager_plugin.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/window_manager/linux/window_manager_plugin.cc b/packages/window_manager/linux/window_manager_plugin.cc index 7093ca49..35b7560c 100644 --- a/packages/window_manager/linux/window_manager_plugin.cc +++ b/packages/window_manager/linux/window_manager_plugin.cc @@ -213,7 +213,7 @@ static FlMethodResponse* set_aspect_ratio(WindowManagerPlugin* self, static_cast(self->window_hints & ~GDK_HINT_ASPECT); } - gdk_window_set_geometry_hints(get_gdk_window(self), &self->window_geometry, + gtk_window_set_geometry_hints(get_window(self), nullptr, &self->window_geometry, self->window_hints); g_autoptr(FlValue) result = fl_value_new_bool(true); return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); @@ -309,7 +309,7 @@ static FlMethodResponse* set_minimum_size(WindowManagerPlugin* self, static_cast(self->window_hints & ~GDK_HINT_MIN_SIZE); } - gdk_window_set_geometry_hints(get_gdk_window(self), &self->window_geometry, + gtk_window_set_geometry_hints(get_window(self), nullptr, &self->window_geometry, self->window_hints); g_autoptr(FlValue) result = fl_value_new_bool(true); @@ -338,7 +338,7 @@ static FlMethodResponse* set_maximum_size(WindowManagerPlugin* self, if (self->window_geometry.max_height < 0) self->window_geometry.max_height = G_MAXINT; - gdk_window_set_geometry_hints(get_gdk_window(self), &self->window_geometry, + gtk_window_set_geometry_hints(get_window(self), nullptr, &self->window_geometry, self->window_hints); g_autoptr(FlValue) result = fl_value_new_bool(true); From dfd346723469fab54c6c9e94da24fadfc358f3e2 Mon Sep 17 00:00:00 2001 From: axel10 Date: Fri, 7 Aug 2026 01:02:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwin10=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/window_manager/windows/window_manager_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/window_manager/windows/window_manager_plugin.cpp b/packages/window_manager/windows/window_manager_plugin.cpp index ba7720ae..404e1c40 100644 --- a/packages/window_manager/windows/window_manager_plugin.cpp +++ b/packages/window_manager/windows/window_manager_plugin.cpp @@ -28,7 +28,7 @@ bool IsWindows11OrGreater() { dwBuild = (DWORD)(HIWORD(dwVersion)); #pragma warning(pop) - return dwBuild < 22000; + return dwBuild >= 22000; } class WindowManagerPlugin : public flutter::Plugin { From 2ce213c03de85654bae826b7993d362e67075344 Mon Sep 17 00:00:00 2001 From: axel10 Date: Fri, 14 Aug 2026 13:49:09 +0800 Subject: [PATCH 3/3] fix(windows): fix double titlebar on Windows 10 when TitleBarStyle is hidden When `titleBarStyle` is set to `TitleBarStyle.hidden` on Windows 10, adding a 1px top offset in `WM_NCCALCSIZE` leaves a non-client margin at the top of the window. On Windows 10, DWM interprets this non-client margin as an active caption area and forces rendering of the system default title bar alongside the Flutter custom title bar. Removing the extra top offset allows the client area to cover the top edge completely, preventing DWM from drawing the native title bar. --- packages/window_manager/windows/window_manager_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/window_manager/windows/window_manager_plugin.cpp b/packages/window_manager/windows/window_manager_plugin.cpp index 404e1c40..2e2fb090 100644 --- a/packages/window_manager/windows/window_manager_plugin.cpp +++ b/packages/window_manager/windows/window_manager_plugin.cpp @@ -168,9 +168,9 @@ std::optional WindowManagerPlugin::HandleWindowProc(HWND hWnd, adjustNCCALCSIZE(hWnd, reinterpret_cast(lParam)); } else { NCCALCSIZE_PARAMS* sz = reinterpret_cast(lParam); - // on windows 10, if set to 0, there's a white line at the top - // of the app and I've yet to find a way to remove that. - sz->rgrc[0].top += IsWindows11OrGreater() ? 0 : 1; + // Do not add top offset on Windows 10, otherwise DWM interprets the non-zero + // non-client top margin as having a native caption and renders the system title bar. + sz->rgrc[0].top += 0; // The following lines are required for resizing the window. // https://github.com/leanflutter/window_manager/issues/483 sz->rgrc[0].right -= 8;