Skip to content

minimumSize makes hidden windows restore too large in 0.7.0 #35

Closed

Description

@Skyost

With window_manager 0.7.0, setting minimumSize on a hidden-title-bar window makes maximize/unmaximize restore the wrong size under KDE Wayland. This reproduces in a freshly generated Flutter Linux application with no other plugins and no runner modifications.

Environment :

  • Flutter 3.50.0 stable, framework ab2912035e, engine 371f77202a
  • Dart 3.14.0
  • window_manager 0.7.0
  • nativeapi / nativeapi_flutter / cnativeapi 0.6.0
  • Fedora 45, KDE Plasma / KWin 6.8.2, GTK 3.24.52, Breeze
  • Wayland session, GDK_BACKEND=wayland, 125% display scaling

Reproduction :

  1. flutter create --empty --platforms=linux --project-name wm_minimum_repro wm_minimum_repro
  2. cd wm_minimum_repro
  3. flutter pub add window_manager:0.7.0
  4. Replace lib/main.dart with the code below. Leave linux/runner/my_application.cc unchanged.
  5. flutter build linux --debug
  6. GDK_BACKEND=wayland build/linux/x64/debug/bundle/wm_minimum_repro
  7. Run the same binary with the minimum-size assignment disabled:
    GDK_BACKEND=wayland WM_SKIP_MINIMUM=1 build/linux/x64/debug/bundle/wm_minimum_repro

Expected :
Both runs restore the initial 800 x 600 size after every maximize/unmaximize cycle.

Actual, with minimumSize = Size(800, 600)
minimum=true initial=Size(800.0, 600.0)
cycle=1 maximized=Size(1536.0, 795.0)
cycle=1 restored=Size(1536.0, 864.0)
cycle=2 maximized=Size(1536.0, 795.0)
cycle=2 restored=Size(1536.0, 864.0)
cycle=3 maximized=Size(1536.0, 795.0)
cycle=3 restored=Size(1536.0, 864.0)

Control, omitting only the minimumSize assignment
minimum=false initial=Size(800.0, 600.0)
cycle=1 maximized=Size(1536.0, 795.0)
cycle=1 restored=Size(800.0, 600.0)
cycle=2 maximized=Size(1536.0, 795.0)
cycle=2 restored=Size(800.0, 600.0)
cycle=3 maximized=Size(1536.0, 795.0)
cycle=3 restored=Size(800.0, 600.0)

The one-second delays allow mapping and deferred shadow setup to complete. The initial size is explicitly reapplied after mapping. Both runs exit normally.

Regression comparison with window_manager 0.5.2
The same freshly generated runner, SDK, desktop session, requested dimensions, one-second delays and three maximize/unmaximize cycles were also tested using 0.5.2's corresponding API:

  • windowManager.ensureInitialized()
  • windowManager.setTitleBarStyle(TitleBarStyle.hidden)
  • windowManager.setMinimumSize(const Size(800, 600))
  • windowManager.setSize / getSize / maximize / unmaximize

With the minimum set, 0.5.2 restores Size(800.0, 600.0) after all three cycles. Version 0.7.0 restores Size(1536.0, 864.0). Omitting the minimum makes both versions restore 800 x 600. This establishes a geometry regression, rather than merely an existing minimum-size limitation. The separate implicit-view cleanup warning logged by 0.5.2 at shutdown is not the issue reported here.

Possible cause :
Window::Impl::RefreshGeometryHints adds the GDK-surface/frame difference to the minimum-size hints. With GTK's client-side decorations on Wayland, the custom shadow/gutter may be counted again. The observed height increase is 264 logical pixels (twice the 132-pixel gutter on this host).

Application workaround :
In our application, omitting window.minimumSize on Linux and setting gtk_widget_set_size_request(GTK_WIDGET(view), 800, 600) on the primary FlView preserves the content minimum and correct restoration. This workaround is not applied in the standalone reproduction above. Repeated maximize/restore and an attempted resize below the minimum pass in the application on both Wayland and XWayland.

Minimal lib/main.dart :

import 'dart:io';

import 'package:flutter/widgets.dart';
import 'package:window_manager/window_manager.dart';

/// Reproduces hidden-window minimum-size restoration in a stock Linux runner.
///
/// Copy this file to a fresh Flutter project's `lib/main.dart` and add
/// `window_manager: 0.7.0`. Run with `GDK_BACKEND=wayland`; repeat with
/// `WM_SKIP_MINIMUM=1` to compare the same window without minimum-size hints.
/// Do not use Focale's runner, which contains a content-minimum workaround.
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final Window window = WindowManager.instance.getCurrent() ?? (throw StateError('No primary window'));
  final bool applyMinimum = Platform.environment['WM_SKIP_MINIMUM'] != '1';
  window.titleBarStyle = .hidden;
  if (applyMinimum) {
    window.minimumSize = const Size(800, 600).toNative();
  }
  window.setSize(const Size(800, 600).toNative(), false);
  window.title = 'window_manager minimum size reproduction';
  runApp(
    const Directionality(
      textDirection: .ltr,
      child: ColoredBox(
        color: Color(0xFF244865),
        child: Center(
          child: Text('800 × 600 content', style: TextStyle(color: Color(0xFFFFFFFF), fontSize: 24)),
        ),
      ),
    ),
  );
  window.show();
  await Future<void>.delayed(const Duration(seconds: 1));
  window.setSize(const Size(800, 600).toNative(), false);
  await Future<void>.delayed(const Duration(seconds: 1));
  stdout.writeln('minimum=$applyMinimum initial=${window.size.toSize()}');
  for (int cycle = 1; cycle <= 3; cycle++) {
    window.maximize();
    await Future<void>.delayed(const Duration(seconds: 1));
    stdout.writeln('cycle=$cycle maximized=${window.size.toSize()}');
    window.unmaximize();
    await Future<void>.delayed(const Duration(seconds: 1));
    stdout.writeln('cycle=$cycle restored=${window.size.toSize()}');
  }
  window.close();
}

Activity

  1. Skyost commented on Nov 14, 2026

    @Skyost
    Author

    Just saw that I posted this in nativeapi instead of multiview_desktop, sorry ! Feel free to move the issue to the other repo.

  2. lijy91 commented on Nov 14, 2026

    @lijy91
    Member

    Fixed on main in 56e7632f, using nativeapi-core commit 18d2a41.

    The minimum-size hint could retain the old shadow gutter during maximize/restore and interfere with GDK's saved restore size. GTK windows with content now derive their minimum through the content widget's size request, so GTK accounts for the current decorations during layout. The host's existing size request is preserved and restored when the minimum is cleared.

    We reproduced the native regression on GTK 3.24.52 / KWin 6.8.1: with the minimum enabled, all three restores produced 1280×864 instead of 800×600. After the fix:

    • The new native regression passes all 48 checks on both Wayland and XWayland, including repeated restoration, minimum/maximum enforcement, and clearing the minimum.
    • A freshly generated Flutter 3.50 application with an unmodified Linux runner restores 800×600 after all three cycles, with the minimum both enabled and omitted, under Breeze and 125% output scaling on Wayland and XWayland.
    • Existing size-constraint and aspect-ratio regressions also pass.

    Verification details and commands. Fedora 45 / KWin 6.8.2 were not independently tested. This fix belongs in nativeapi, so there is no need to move the issue.

    The fix is on main; a package release containing it has not been published yet.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions