Fix Alt modifier stuck after Alt-Tab on Windows - #52220
Merged
Merged
Conversation
zed-codeowner-coordinator
Bot
requested review from
a team,
Anthony-Eid and
osiewicz
and removed request for
a team
March 23, 2026 15:12
Contributor
osiewicz
approved these changes
Apr 16, 2026
Member
|
Thank you! |
osiewicz
enabled auto-merge (squash)
April 16, 2026 16:43
auto-merge was automatically disabled
April 16, 2026 17:08
Head branch was pushed to by a user without write access
HuaGu-Dragon
force-pushed
the
reset-modifier
branch
from
April 16, 2026 17:08
c70f4b6 to
a9d1588
Compare
Contributor
Author
|
Hi @osiewicz I noticed the CI failure was due to a git merge-base error after auto-merge. I've rebased the branch onto the latest main and force-pushed to ensure the common ancestor is clean. Would you mind taking another look? I think the CI should pass now or let me know if any further action is needed on my side? Thanks! |
AzureZee
added a commit
to AzureZee/gpuix
that referenced
this pull request
Apr 18, 2026
AzureZee
added a commit
to AzureZee/gpuix
that referenced
this pull request
Apr 18, 2026
kathbigra
pushed a commit
to kathbigra/zed
that referenced
this pull request
May 10, 2026
## Context Fixes a bug on Windows where the Alt modifier key becomes stuck in the pressed state after using Alt-Tab to switch away from and back to the Zed application. ### Root Cause In `crates/gpui_windows/src/events.rs`, when the window loses focus during Alt-Tab, the WM_KEYUP event for the Alt key is never delivered to the application. The pending modifier state in GPUI remains as `alt=true`. When the window regains focus, there is no synchronization point to reset this stale state. ## How to Review In `handle_activate_msg()` (WM_ACTIVATE handler), when the window is activated: 1. Reset the cached modifier tracking state (`last_reported_modifiers` and `last_reported_capslock` set to `None`) 2. Query the actual current modifier state from Windows using `GetKeyState()` APIs 3. Dispatch a `ModifiersChanged` event with the true state to synchronize GPUI ## Self-Review Checklist <!-- Check before requesting review: --> - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable I think it's difficult to add tests for this because it's platform-dependent, but I recorded a video for comparison — sorry I only have an anime‑style app to show the key presses. <details> <summary>Video</summary> https://github.com/user-attachments/assets/b545178c-b360-4e2b-8d60-d6f95a0b4b79 https://github.com/user-attachments/assets/bc4d41eb-6f42-4040-a588-0fc46c576db7 </details> Closes zed-industries#45485 Release Notes: - Fixed Alt modifier key stuck after Alt-Tab on Windows. Modifier state is now synchronized when the window regains focus, ensuring correct key interpretation after window switching.
Zenor27
pushed a commit
to Zenor27/zed
that referenced
this pull request
Jul 4, 2026
## Context Fixes a bug on Windows where the Alt modifier key becomes stuck in the pressed state after using Alt-Tab to switch away from and back to the Zed application. ### Root Cause In `crates/gpui_windows/src/events.rs`, when the window loses focus during Alt-Tab, the WM_KEYUP event for the Alt key is never delivered to the application. The pending modifier state in GPUI remains as `alt=true`. When the window regains focus, there is no synchronization point to reset this stale state. ## How to Review In `handle_activate_msg()` (WM_ACTIVATE handler), when the window is activated: 1. Reset the cached modifier tracking state (`last_reported_modifiers` and `last_reported_capslock` set to `None`) 2. Query the actual current modifier state from Windows using `GetKeyState()` APIs 3. Dispatch a `ModifiersChanged` event with the true state to synchronize GPUI ## Self-Review Checklist <!-- Check before requesting review: --> - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable I think it's difficult to add tests for this because it's platform-dependent, but I recorded a video for comparison — sorry I only have an anime‑style app to show the key presses. <details> <summary>Video</summary> https://github.com/user-attachments/assets/b545178c-b360-4e2b-8d60-d6f95a0b4b79 https://github.com/user-attachments/assets/bc4d41eb-6f42-4040-a588-0fc46c576db7 </details> Closes zed-industries#45485 Release Notes: - Fixed Alt modifier key stuck after Alt-Tab on Windows. Modifier state is now synchronized when the window regains focus, ensuring correct key interpretation after window switching.
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
## Context Fixes a bug on Windows where the Alt modifier key becomes stuck in the pressed state after using Alt-Tab to switch away from and back to the Zed application. ### Root Cause In `crates/gpui_windows/src/events.rs`, when the window loses focus during Alt-Tab, the WM_KEYUP event for the Alt key is never delivered to the application. The pending modifier state in GPUI remains as `alt=true`. When the window regains focus, there is no synchronization point to reset this stale state. ## How to Review In `handle_activate_msg()` (WM_ACTIVATE handler), when the window is activated: 1. Reset the cached modifier tracking state (`last_reported_modifiers` and `last_reported_capslock` set to `None`) 2. Query the actual current modifier state from Windows using `GetKeyState()` APIs 3. Dispatch a `ModifiersChanged` event with the true state to synchronize GPUI ## Self-Review Checklist <!-- Check before requesting review: --> - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable I think it's difficult to add tests for this because it's platform-dependent, but I recorded a video for comparison — sorry I only have an anime‑style app to show the key presses. <details> <summary>Video</summary> https://github.com/user-attachments/assets/b545178c-b360-4e2b-8d60-d6f95a0b4b79 https://github.com/user-attachments/assets/bc4d41eb-6f42-4040-a588-0fc46c576db7 </details> Closes zed-industries#45485 Release Notes: - Fixed Alt modifier key stuck after Alt-Tab on Windows. Modifier state is now synchronized when the window regains focus, ensuring correct key interpretation after window switching.
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
## Context Fixes a bug on Windows where the Alt modifier key becomes stuck in the pressed state after using Alt-Tab to switch away from and back to the Zed application. ### Root Cause In `crates/gpui_windows/src/events.rs`, when the window loses focus during Alt-Tab, the WM_KEYUP event for the Alt key is never delivered to the application. The pending modifier state in GPUI remains as `alt=true`. When the window regains focus, there is no synchronization point to reset this stale state. ## How to Review In `handle_activate_msg()` (WM_ACTIVATE handler), when the window is activated: 1. Reset the cached modifier tracking state (`last_reported_modifiers` and `last_reported_capslock` set to `None`) 2. Query the actual current modifier state from Windows using `GetKeyState()` APIs 3. Dispatch a `ModifiersChanged` event with the true state to synchronize GPUI ## Self-Review Checklist <!-- Check before requesting review: --> - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable I think it's difficult to add tests for this because it's platform-dependent, but I recorded a video for comparison — sorry I only have an anime‑style app to show the key presses. <details> <summary>Video</summary> https://github.com/user-attachments/assets/b545178c-b360-4e2b-8d60-d6f95a0b4b79 https://github.com/user-attachments/assets/bc4d41eb-6f42-4040-a588-0fc46c576db7 </details> Closes zed-industries#45485 Release Notes: - Fixed Alt modifier key stuck after Alt-Tab on Windows. Modifier state is now synchronized when the window regains focus, ensuring correct key interpretation after window switching.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Fixes a bug on Windows where the Alt modifier key becomes stuck in the pressed state after using Alt-Tab to switch away from and back to the Zed application.
Root Cause
In
crates/gpui_windows/src/events.rs, when the window loses focus during Alt-Tab, the WM_KEYUP event for the Alt key is never delivered to the application. The pending modifier state in GPUI remains asalt=true. When the window regains focus, there is no synchronization point to reset this stale state.How to Review
In
handle_activate_msg()(WM_ACTIVATE handler), when the window is activated:last_reported_modifiersandlast_reported_capslockset toNone)GetKeyState()APIsModifiersChangedevent with the true state to synchronize GPUISelf-Review Checklist
I think it's difficult to add tests for this because it's platform-dependent, but I recorded a video for comparison — sorry I only have an anime‑style app to show the key presses.
Video
previous.mp4
after.mp4
Closes #45485
Release Notes: