Skip to content

Conversation

@mattkae
Copy link
Contributor

@mattkae mattkae commented Nov 25, 2025

fixes #177822

What's new?

  • The FlutterWindow now consumes any WM_SYSKEYDOWN (VK_MENU) message
  • Wrote a test to validate that this is the case
  • Make it so that the KeyboardManager can be provided

This PR was made possible by #178523

How to test?

  1. Create a new flutter project
  2. Add the following:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output
  1. Click alt. Note that the message is received.
  2. Continue clicking alt and validate that the message is received.
  3. Alt tab out and back and note that subsequent alts are correctly received.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@mattkae mattkae requested a review from loic-sharma November 25, 2025 18:39
@github-actions github-actions bot added engine flutter/engine related. See also e: labels. platform-windows Building on or for Windows specifically a: desktop Running on desktop labels Nov 25, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves the issue of Alt key down events being missed on Win32 by consuming the WM_SYSKEYDOWN message for VK_MENU. The changes are well-implemented, including making KeyboardManager injectable to improve testability. A new unit test has been added that correctly validates the fix. The related changes, such as adding a virtual destructor to KeyboardManager and making HandleMessage virtual, are good practices and necessary for the testing strategy. Overall, this is a high-quality contribution.

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent improvement all around, thanks for fixing this!

@mattkae mattkae added this pull request to the merge queue Nov 26, 2025
Merged via the queue into flutter:master with commit fde117b Nov 26, 2025
179 of 180 checks passed
@mattkae mattkae deleted the bugfix/alt_keydown branch November 26, 2025 13:48
@Piinks
Copy link
Contributor

Piinks commented Nov 26, 2025

The tree is closed right now. Please please do not manually merge PRs in general. You should use the auto submit label.

@Piinks
Copy link
Contributor

Piinks commented Nov 26, 2025

Reason for revert: the tree is closed, should not have been merged.

@mattkae
Copy link
Contributor Author

mattkae commented Nov 26, 2025

Reason for revert: the tree is closed, should not have been merged.

Whoops, should not have merged. I still see it on main though. Did it actually get reverted?

@jtmcdole jtmcdole added the revert Autorevert PR (with "Reason for revert:" comment) label Nov 26, 2025
auto-submit bot pushed a commit that referenced this pull request Nov 26, 2025
@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Nov 26, 2025
@Piinks
Copy link
Contributor

Piinks commented Nov 26, 2025

Ah no the label didn't stick. Thanks for adding it!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 26, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
…the flutter app (#179097)" (#179136)

<!-- start_original_pr_link -->
Reverts: #179097
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: the tree is closed, should not have been merged.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: mattkae
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {loic-sharma}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
fixes [#177822](#177822)

## What's new?
- The `FlutterWindow` now consumes any `WM_SYSKEYDOWN (VK_MENU)` message
- Wrote a test to validate that this is the case
- Make it so that the `KeyboardManager` can be provided

This PR was made possible by
#178523

## How to test?
1. Create a new flutter project
2. Add the following:

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output
```
3. Click alt. Note that the message is received.
4. Continue clicking alt and validate that the message is received.
5. Alt tab out and back and note that subsequent alts are correctly
received.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.


<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 26, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 26, 2025
flutter/flutter@3f553f6...7b98d50

2025-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fix for win32 embedder failing to send all alt key downs to the flutter app (#179097)" (flutter/flutter#179136)
2025-11-26 [email protected] Fix for win32 embedder failing to send all alt key downs to the flutter app (flutter/flutter#179097)
2025-11-26 [email protected] Modernize framework lints (flutter/flutter#179089)
2025-11-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add framework-side hitTestBehavior support to Semantics (#178817)" (flutter/flutter#179100)
2025-11-25 [email protected] Add framework-side hitTestBehavior support to Semantics (flutter/flutter#178817)
2025-11-25 [email protected] Roll Packages from e019cf9 to cc3dca6 (1 revision) (flutter/flutter#179081)
2025-11-25 [email protected] Add tooltip windows to the windowing API alongside the window positioning logic (flutter/flutter#177404)
2025-11-25 [email protected] FlutterWindowsView::SendWindowMetrics now reliably sends the display_id (flutter/flutter#179053)
2025-11-25 [email protected] Remove semantics geometry shortcircuit (flutter/flutter#178680)
2025-11-25 [email protected] Add an assert message when OverlayEntry.remove is called twice (flutter/flutter#178163)
2025-11-25 [email protected] Roll Fuchsia Linux SDK from pOO9Jl9HTLsEmks6y... to nzuAxCJGeJbkZCTkr... (flutter/flutter#179066)
2025-11-25 [email protected] Dynamically set MinimumOSVersion in App.framework (flutter/flutter#178253)
2025-11-25 [email protected] Roll Skia from d83c30b090f4 to 925c311f4b37 (2 revisions) (flutter/flutter#179060)
2025-11-25 [email protected] Marks Linux build_android_host_app_with_module_aar to be unflaky (flutter/flutter#174864)
2025-11-25 [email protected] Marks Linux_mokey complex_layout__start_up to be unflaky (flutter/flutter#174865)
2025-11-25 [email protected] Manual Dart SDK roll to 3.11.0-169.0.dev (flutter/flutter#179054)
2025-11-25 [email protected] Bump Dart to 3.9 (flutter/flutter#179041)
2025-11-25 [email protected] Roll Skia from e298c2f93ebf to d83c30b090f4 (2 revisions) (flutter/flutter#179058)
2025-11-24 [email protected] updated licenses_cpp readme (flutter/flutter#178874)
2025-11-24 [email protected] Roll Skia from 43d2020be565 to e298c2f93ebf (5 revisions) (flutter/flutter#179046)
2025-11-24 [email protected] Refactor `_isLabel` method in `stepper.dart` to use `any` for better readablity (flutter/flutter#178909)
2025-11-24 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 5 to 6 in the all-github-actions group (flutter/flutter#179049)
2025-11-24 [email protected] Disposes test restoration manager when accessed by bindings (flutter/flutter#176519)
2025-11-24 [email protected] [ Widget Preview ] Always generate scaffold under `$TMP` (flutter/flutter#179039)
2025-11-24 [email protected] Roll Packages from e67b6be to e019cf9 (9 revisions) (flutter/flutter#179035)
2025-11-24 [email protected] Update CHANGELOG.md for Flutter 3.38.3 (flutter/flutter#178935)
2025-11-24 [email protected] Remove unnecessary `String.valueOf` in `SettingsChannel.java‎` (flutter/flutter#178590)
2025-11-24 [email protected] Roll pub manually, pick up flutter_lints in examples/api (flutter/flutter#179030)
2025-11-24 [email protected] Roll Dart SDK from 24cc9a740bd3 to afca43095efa (1 revision) (flutter/flutter#179019)
2025-11-24 [email protected] Pass EXCLUDED_ARCHS from Xcode project to xcodebuild for macOS builds (flutter/flutter#176948)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…er app (flutter#179097)

fixes [flutter#177822](flutter#177822)

## What's new?
- The `FlutterWindow` now consumes any `WM_SYSKEYDOWN (VK_MENU)` message
- Wrote a test to validate that this is the case
- Make it so that the `KeyboardManager` can be provided

This PR was made possible by
flutter#178523

## How to test?
1. Create a new flutter project
2. Add the following:

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output
```
3. Click alt. Note that the message is received.
4. Continue clicking alt and validate that the message is received.
5. Alt tab out and back and note that subsequent alts are correctly
received.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…the flutter app (flutter#179097)" (flutter#179136)

<!-- start_original_pr_link -->
Reverts: flutter#179097
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: the tree is closed, should not have been merged.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: mattkae
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {loic-sharma}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
fixes [flutter#177822](flutter#177822)

## What's new?
- The `FlutterWindow` now consumes any `WM_SYSKEYDOWN (VK_MENU)` message
- Wrote a test to validate that this is the case
- Make it so that the `KeyboardManager` can be provided

This PR was made possible by
flutter#178523

## How to test?
1. Create a new flutter project
2. Add the following:

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output
```
3. Click alt. Note that the message is received.
4. Continue clicking alt and validate that the message is received.
5. Alt tab out and back and note that subsequent alts are correctly
received.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.


<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…er app (flutter#179097)

fixes [flutter#177822](flutter#177822)

## What's new?
- The `FlutterWindow` now consumes any `WM_SYSKEYDOWN (VK_MENU)` message
- Wrote a test to validate that this is the case
- Make it so that the `KeyboardManager` can be provided

This PR was made possible by
flutter#178523

## How to test?
1. Create a new flutter project
2. Add the following:

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output
```
3. Click alt. Note that the message is received.
4. Continue clicking alt and validate that the message is received.
5. Alt tab out and back and note that subsequent alts are correctly
received.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…the flutter app (flutter#179097)" (flutter#179136)

<!-- start_original_pr_link -->
Reverts: flutter#179097
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: the tree is closed, should not have been merged.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: mattkae
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {loic-sharma}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
fixes [flutter#177822](flutter#177822)

## What's new?
- The `FlutterWindow` now consumes any `WM_SYSKEYDOWN (VK_MENU)` message
- Wrote a test to validate that this is the case
- Make it so that the `KeyboardManager` can be provided

This PR was made possible by
flutter#178523

## How to test?
1. Create a new flutter project
2. Add the following:

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output
```
3. Click alt. Note that the message is received.
4. Continue clicking alt and validate that the message is received.
5. Alt tab out and back and note that subsequent alts are correctly
received.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.


<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-windows Building on or for Windows specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] HardwareKeyboard misses next key press after alt is pressed

4 participants