Issues with cursor invalidation in GDI #21593

Open
opened 2026-01-31 07:49:00 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Apr 28, 2024).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

Commit 378b6594bd

Windows build number

10.0.19045.4291

Other Software

No response

Steps to reproduce

  1. Make sure the conhost render engine is set to GDI (i.e. the UseDx registry entry is 0).
  2. Open a WSL shell in a recent build of OpenConsole (commit 20b0bed46d or later)
  3. Execute the following statements:
    printf "\e[2 q"; sleep 2; printf "\e[A"; sleep 2; printf "\e[B"
    

Expected Behavior

The above script is setting the cursor to a steady block so it's easy to see, sleeping for 2 seconds, moving up a line and sleeping for another 2 seconds, then moving the cursor back down again. You should be able to see the cursor the entire time.

Actual Behavior

Initially the cursor is visible, but as soon as we move up a line it becomes invisible for 2 seconds.

I believe this is a regression from PR #15500. Originally we would call InvalidateCursor (via TriggerRedrawCursor) whenever the cursor was moved, both to invalidate the old position and the new position. But since PR #15500, TriggerRedrawCursor has been nuked, and InvalidateCursor is now called at the start of every frame (regardless of whether the cursor is moved or not), and it only invalidates the old cursor position. So when the cursor moves, it's erased from the old position, but not redrawn in the new position.

This typically only affects vertical movement (other than some edge cases), because at some point I think we stopped caring about the horizontal extent of the invalidated region and just refresh the full width of the screen regardless. This also doesn't seem to affect the DX and Atlas engines, but I have no idea why.

Originally created by @j4james on GitHub (Apr 28, 2024). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version Commit 378b6594bd94cf3b27f4e309a11efe25d83de0d9 ### Windows build number 10.0.19045.4291 ### Other Software _No response_ ### Steps to reproduce 1. Make sure the conhost render engine is set to GDI (i.e. the `UseDx` registry entry is 0). 2. Open a WSL shell in a recent build of OpenConsole (commit 20b0bed46df71c596b4fb68edfb6bb4b4ebf1c89 or later) 3. Execute the following statements: ``` printf "\e[2 q"; sleep 2; printf "\e[A"; sleep 2; printf "\e[B" ``` ### Expected Behavior The above script is setting the cursor to a steady block so it's easy to see, sleeping for 2 seconds, moving up a line and sleeping for another 2 seconds, then moving the cursor back down again. You should be able to see the cursor the entire time. ### Actual Behavior Initially the cursor is visible, but as soon as we move up a line it becomes invisible for 2 seconds. I believe this is a regression from PR #15500. Originally we would call `InvalidateCursor` (via `TriggerRedrawCursor`) whenever the cursor was moved, both to invalidate the old position and the new position. But since PR #15500, `TriggerRedrawCursor` has been nuked, and `InvalidateCursor` is now called at the start of every frame (regardless of whether the cursor is moved or not), and it only invalidates the old cursor position. So when the cursor moves, it's erased from the old position, but not redrawn in the new position. This typically only affects vertical movement (other than some edge cases), because at some point I think we stopped caring about the horizontal extent of the invalidated region and just refresh the full width of the screen regardless. This also doesn't seem to affect the DX and Atlas engines, but I have no idea why.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21593