Repository navigation
[Windows] Multi-window: buttons stop working when dragging a click from a window to another one #189583
Copy link
Copy link
Closed
Labels
a: desktopRunning on desktopRunning on desktopa: multi windowIssues related to multi window supportIssues related to multi window supporthas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamOwned by the Windows platform team
Description
Steps to reproduce
This issue seems to have been introduced by this commit : #187629
I tried on the previous commit and everything was working fine.
- Use the
masterFlutter channel on Windows - Run the
flutter config --enable-windowingcommand to enable windowing - Launch the app from the code sample below (
flutter run -d windows) - Like in the following video, open 2 other windows using the main screen button
- Press down the left mouse button on the first child window
- While keeping the mouse button down, switch the focused window using Alt+tab
- Hover or release the left mouse button on one of the buttons of the new focused window
- The button where the click is released doesn't work anymore
Expected results
When moving from a window to another one while keeping the left mouse button pressed, the press should be dismissed when leaving the window and ignored by the new window.
Actual results
When releasing the mouse button that was pressed on one window above a button of another window, the button do not receive the press events anymore and appear pressed (like in the video).
Code sample
The code used in the video :
Code sample
// 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(
size: 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(
size: 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 StatefulWidget {
const ChildWindow({super.key});
@override
State<ChildWindow> createState() => _ChildWindowState();
}
class _ChildWindowState extends State<ChildWindow> {
static const colors = [
Color(0xFFE8F0FF),
Color(0xFFFFE8E8),
];
Color color = colors[0];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: color,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
spacing: 4,
children: [
ElevatedButton(
onPressed: () {
setState(() {
color = colors.firstWhere((c) => c != color);
});
},
child: const Text('Change color'),
),
ElevatedButton(
onPressed: () {
setState(() {
color = colors.firstWhere((c) => c != color);
});
},
child: const Text('Change color'),
),
],
),
),
);
}
}
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();
}
}Screenshots or Video
Screenshots / Video demonstration
2026-07-16.14-14-44.mp4
Logs
Logs
Running the app with the `--verbose` flag does not show specific logs when the bug occurs.Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.47.0-1.0.pre-98, on Microsoft Windows [version 10.0.19045.6937], locale fr-FR)
[√] Windows Version (10 Famille 64 bits, 22H2, 2009)
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: [https://developer.android.com/studio/index.html](https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdeveloper.android.com%2Fstudio%2Findex.html&data=05%7C02%7Ck.despoulains%40betclicgroup.com%7C92e899b336f5496a86a708dee33cbe7c%7C349cb0f5cf5b4f4c89f1e13af5555b16%7C0%7C0%7C639198047214544654%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=nkI%2FTW4EIgyp2PwtOfjsy0QPCd%2Bq1jHK%2B7oaCqU3AUg%3D&reserved=0)
On first launch it will assist you in installing the Android SDK components.
(or visit [https://flutter.dev/to/windows-android-setup](https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fflutter.dev%2Fto%2Fwindows-android-setup&data=05%7C02%7Ck.despoulains%40betclicgroup.com%7C92e899b336f5496a86a708dee33cbe7c%7C349cb0f5cf5b4f4c89f1e13af5555b16%7C0%7C0%7C639198047214584947%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Pd0TYc0zdlxFgRnHHFrrP%2BH1CF2ByQU15gIeybSn2VM%3D&reserved=0) for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.8.0)
[√] Connected device (3 available)
[√] Network resources
! Doctor found issues in 1 category.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: desktopRunning on desktopRunning on desktopa: multi windowIssues related to multi window supportIssues related to multi window supporthas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamOwned by the Windows platform team
Activity
suryaKommana2662 commentedon Jul 17, 2026
@kevindespoulains-bc Thanks for the report. I was able to reproduce this issue on Windows using the latest Flutter master.
Following the provided reproduction steps, I observed the same behavior:
Alt + Tabwhile keeping the mouse button pressed.After doing so, the button in the second window remained in a pressed state and no longer responded to subsequent clicks, matching the behavior described in the report. Routing this to
team-windowsfor further investigation.I've attached a screen recording demonstrating the issue.
https://github.com/user-attachments/assets/f0c560f9-8369-4264-bb20-c596ed9e984a
Flutter Doctor Output
knopp commentedon Jul 20, 2026
cc @mattkae, @loic-sharma
knopp commentedon Jul 25, 2026
Thanks for the bisect, it really helped!
I looked into this - the culprit is this part of #187629:
With this the
WM_MOUSEMOVEsets the mouse button state from the event itself. Before this didn't happen, the mouse buttons state was set through mouse down and up events.This normally doesn't make difference because we get mouse down, capture mouse and send mouse move - the buttons in mouse move event match the state set by mouse down. However when switching to new window mid drag, windows will no longer honor the mouse capture and will start sending the
WM_MOUSEMOVEevent to new window, with the button flag sets. But this window never saw the mouse down event - this confuses the pointer tracking in Flutter. In debug build this actually crashes with assertion.I looked at most other applications, and I think generally the best way to handle this is to simply ignore WM_MOUSEMOVE that has buttons set when
GetCapture()doesn't return current HWND. This seems to match behavior of other windows applications.[Win32] Ignore mouse move events without capture when dragging (flutt…
github-actions commentedon Aug 12, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.