Skip to content

Fix cursor being hidden when pressing modifier keys#19473

Merged
lhecker merged 2 commits intomicrosoft:mainfrom
angesie:fix/19445
Oct 21, 2025
Merged

Fix cursor being hidden when pressing modifier keys#19473
lhecker merged 2 commits intomicrosoft:mainfrom
angesie:fix/19445

Conversation

@angesie
Copy link
Contributor

@angesie angesie commented Oct 17, 2025

Summary of the Pull Request

Added a check to ensure IslandWindow::HideCursor() is only called when a non-modifier key (e.g., not Shift, Control, Alt, or Windows keys) is pressed. This prevents unintended cursor hiding when only modifier keys are used.

References and Relevant Issues

19445 - The mouse pointer has disappeared when press CTRL or SHIFT

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Built and deployed CascadiaPackage through VS, tested the deployed Terminal Dev app on local machine.

PR Checklist

Added a check to ensure IslandWindow::HideCursor() is only called when a non-modifier key (e.g., not Shift, Control, Alt, or Windows keys) is pressed. This prevents unintended cursor hiding when only modifier keys are used.
@angesie angesie marked this pull request as ready for review October 17, 2025 13:16
@Mayuri9356
Copy link

Thanks for the review. I'm excited to contribute to this project. I'm available to make any requested changes quickly!

Comment on lines +489 to +496
const bool modifierKey = (msg.wParam == VK_SHIFT ||
msg.wParam == VK_CONTROL ||
msg.wParam == VK_MENU ||
msg.wParam == VK_LWIN ||
msg.wParam == VK_RWIN);

// Hide the cursor only when the key pressed is not a modifier key.
if (!modifierKey)
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for working on this. Elsewhere we have this function:

static constexpr bool IsInputKey(WORD vkey)
{
return vkey != VK_CONTROL &&
vkey != VK_LCONTROL &&
vkey != VK_RCONTROL &&
vkey != VK_MENU &&
vkey != VK_LMENU &&
vkey != VK_RMENU &&
vkey != VK_SHIFT &&
vkey != VK_LSHIFT &&
vkey != VK_RSHIFT &&
vkey != VK_LWIN &&
vkey != VK_RWIN &&
vkey != VK_SNAPSHOT;
}

Perhaps we should copy it verbatim here and use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi! Thanks for the feedback :)
I've refactored the code following your advice, and re-tested it

Introduce IsInputKey function, coppied from Terminal.hpp, for improving the modifier key handling logic and following the codebase standards. Update cursor hiding logic to use the new function.
@angesie angesie requested a review from lhecker October 20, 2025 19:19
@angesie
Copy link
Contributor Author

angesie commented Oct 20, 2025

@microsoft-github-policy-service agree

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

Thank you for doing this!

At some point in the future we can think about how to unify the IsInputKey copies, but not today. :)

@lhecker
Copy link
Member

lhecker commented Oct 20, 2025

/azp run

@lhecker lhecker changed the title fix(TerminalControl): #19445 cursor hidden on modifier key down Fix cursor being hidden when pressing modifier keys Oct 20, 2025
@zadjii-msft
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhecker lhecker merged commit b357de9 into microsoft:main Oct 21, 2025
15 checks passed
@PratapShashwat PratapShashwat mentioned this pull request Oct 23, 2025
3 tasks
@github-project-automation github-project-automation bot moved this to To Cherry Pick in 1.24 Servicing Pipeline Dec 17, 2025
@github-project-automation github-project-automation bot moved this to To Cherry Pick in 1.23 Servicing Pipeline Dec 17, 2025
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.23 Servicing Pipeline Dec 17, 2025
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.24 Servicing Pipeline Dec 17, 2025
DHowett pushed a commit that referenced this pull request Dec 17, 2025
Closes #19445

(cherry picked from commit b357de9)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgirMu0
Service-Version: 1.23
DHowett pushed a commit that referenced this pull request Dec 17, 2025
Closes #19445

(cherry picked from commit b357de9)
Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgirMuw
Service-Version: 1.24
@DHowett DHowett moved this from Cherry Picked to Shipped in 1.23 Servicing Pipeline Jan 15, 2026
@DHowett DHowett moved this from Cherry Picked to Shipped in 1.24 Servicing Pipeline Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

The mouse pointer has disappeared when press CTRL or SHIFT

4 participants