Skip to content

[Windows][windowing] Activating a child RegularWindow from the taskbar briefly focuses it, then the main window is brought to front #187436

Description

@CHOIgoung

Steps to reproduce

  1. Enable Flutter windowing:

    flutter config --enable-windowing
  2. Run a minimal Windows app using SDK windowing:

    • main window: runWidget + RegularWindow
    • child window: WindowRegistry.register(WindowEntry(... RegularWindowController ...))
  3. Open a child window.

  4. Focus the main window.

  5. Try to activate the child window from the Windows taskbar.

Expected result

The selected child window should become the foreground window and stay above the main window.

Actual result

The child window is briefly brought to the front, but the main window immediately becomes active again and covers it.

Minimal repro

The app is intentionally minimal and follows the SDK windowing pattern:

  • runWidget(...)
  • main RegularWindow
  • MaterialApp
  • WindowRegistry.of(context)
  • child WindowEntry with RegularWindowController
// ignore_for_file: implementation_imports, invalid_use_of_internal_member

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/_window.dart' as fw;

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runWidget(const MultiWindowApp());
}

class MultiWindowApp extends StatefulWidget {
  const MultiWindowApp({super.key});

  @override
  State<MultiWindowApp> createState() => _MultiWindowAppState();
}

class _MultiWindowAppState extends State<MultiWindowApp> {
  final fw.RegularWindowController _controller = fw.RegularWindowController(
    preferredSize: const Size(800, 600),
    title: 'Main window',
    delegate: _MainWindowDelegate(),
  );

  @override
  Widget build(BuildContext context) {
    return fw.RegularWindow(
      controller: _controller,
      child: const MaterialApp(home: MainWindow()),
    );
  }
}

class MainWindow extends StatelessWidget {
  const MainWindow({super.key});

  @override
  Widget build(BuildContext context) {
    final registry = fw.WindowRegistry.of(context);

    return Scaffold(
      body: Center(
        child: FilledButton(
          onPressed: () => openChildWindow(registry),
          child: const Text('Open child window'),
        ),
      ),
    );
  }
}

void openChildWindow(fw.WindowRegistry registry) {
  late final fw.WindowEntry entry;
  final controller = fw.RegularWindowController(
    preferredSize: const Size(520, 360),
    title: 'Child window',
    delegate: _ChildWindowDelegate(
      onDestroyed: () => registry.unregister(entry),
    ),
  );

  entry = fw.WindowEntry(
    controller: controller,
    builder: (_) => const MaterialApp(home: ChildWindow()),
  );

  registry.register(entry);
}

class ChildWindow extends StatelessWidget {
  const ChildWindow({super.key});

  @override
  Widget build(BuildContext context) {
    return const Scaffold(backgroundColor: Color(0xFFE8F0FF));
  }
}

class _MainWindowDelegate with fw.RegularWindowControllerDelegate {
  @override
  void onWindowDestroyed() {
    exit(0);
  }
}

class _ChildWindowDelegate with fw.RegularWindowControllerDelegate {
  const _ChildWindowDelegate({required this.onDestroyed});

  final VoidCallback onDestroyed;

  @override
  void onWindowDestroyed() {
    onDestroyed();
  }
}

Flutter Doctor

Flutter 3.45.0-1.0.pre-325 • channel master
Framework revision 1365d5baa1
Engine revision 1365d5baa1
Dart 3.13.0-158.0.dev

Windows 11 25H2
Visual Studio Community 2026 18.6.0
Windows 10 SDK 10.0.26100.0

Feature flag:
enable-windowing: true
issue.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: multi windowIssues related to multi window supportplatform-windowsBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamtriaged-windowsTriaged by the Windows platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions