ScrollRegion function generates inappropriate EVENT_CONSOLE_UPDATE_SCROLL #16964

Open
opened 2026-01-31 05:28:36 +00:00 by claunia · 1 comment
Owner

Originally created by @j4james on GitHub (Mar 10, 2022).

Windows Terminal version

n/a

Windows build number

10.0.19041.1415

Other Software

No response

Steps to reproduce

The ScrollRegion function is used in conhost to "scroll" an area of the screen buffer in multiple directions. It's used in a variety of places, but the closest equivalent in the public API is the ScrollConsoleScreenBuffer function. It doesn't pan the viewport, as typically occurs when the console scrolls - it's more akin to copying a chunk of the buffer from one position to another.

But if you look at the code for ScrollRegion, it makes a call to _ScrollScreen, which then makes a call to NotifyConsoleUpdateScrollEvent like this:

3bd3a4f712/src/host/output.cpp (L279)

That code is a bit obfuscated by the use of Origin, but it essentially boils down to:

pNotifier->NotifyConsoleUpdateScrollEvent(target.Left() - source.Left(), target.Top() - source.RightInclusive());

Quite clearly the second parameter is nonsense.

That said, I'm not sure a scroll event should be used here at all. As mentioned above, it's not the equivalent of the viewport scrolling, so I don't think it makes sense to trigger an EVENT_CONSOLE_UPDATE_SCROLL.

Hopefully someone that is more knowledgable about accessibility can chime in here, but it seemed to me that EVENT_CONSOLE_UPDATE_SCROLL was how you would track the movement of the viewport. Other update events use absolute coordinates, so you need to know the viewport position in order to obtain their relative location. And if something like ScrollRegion is sending unrelated scroll events, that makes that data useless.

Expected Behavior

I don't think ScrollRegion should be triggering EVENT_CONSOLE_UPDATE_SCROLL at all, but if it does, it should at least give meaningful deltas.

Actual Behavior

ScrollRegion is triggering meaningless EVENT_CONSOLE_UPDATE_SCROLL notifications.

Originally created by @j4james on GitHub (Mar 10, 2022). ### Windows Terminal version n/a ### Windows build number 10.0.19041.1415 ### Other Software _No response_ ### Steps to reproduce The `ScrollRegion` function is used in conhost to "scroll" an area of the screen buffer in multiple directions. It's used in a variety of places, but the closest equivalent in the public API is the [ScrollConsoleScreenBuffer](https://docs.microsoft.com/en-us/windows/console/scrollconsolescreenbuffer) function. It doesn't pan the viewport, as typically occurs when the console scrolls - it's more akin to copying a chunk of the buffer from one position to another. But if you look at the code for [`ScrollRegion`](https://github.com/microsoft/terminal/blob/3bd3a4f712006d752b59d66e104aeb6bc5f7f9d6/src/host/output.cpp#L436-L437), it makes a call to `_ScrollScreen`, which then makes a call to `NotifyConsoleUpdateScrollEvent` like this: https://github.com/microsoft/terminal/blob/3bd3a4f712006d752b59d66e104aeb6bc5f7f9d6/src/host/output.cpp#L279 That code is a bit obfuscated by the use of `Origin`, but it essentially boils down to: ```cpp pNotifier->NotifyConsoleUpdateScrollEvent(target.Left() - source.Left(), target.Top() - source.RightInclusive()); ``` Quite clearly the second parameter is nonsense. That said, I'm not sure a scroll event should be used here at all. As mentioned above, it's not the equivalent of the viewport scrolling, so I don't think it makes sense to trigger an `EVENT_CONSOLE_UPDATE_SCROLL`. Hopefully someone that is more knowledgable about accessibility can chime in here, but it seemed to me that `EVENT_CONSOLE_UPDATE_SCROLL` was how you would track the movement of the viewport. Other update events use absolute coordinates, so you need to know the viewport position in order to obtain their relative location. And if something like `ScrollRegion` is sending unrelated scroll events, that makes that data useless. ### Expected Behavior I don't think `ScrollRegion` should be triggering `EVENT_CONSOLE_UPDATE_SCROLL` at all, but if it does, it should at least give meaningful deltas. ### Actual Behavior `ScrollRegion` is triggering meaningless `EVENT_CONSOLE_UPDATE_SCROLL` notifications.
claunia added the Help WantedProduct-ConhostArea-OutputIssue-BugPriority-3 labels 2026-01-31 05:28:36 +00:00
Author
Owner

@j4james commented on GitHub (Mar 10, 2022):

Btw, I thought at first that it might make sense to send an EVENT_CONSOLE_UPDATE_REGION here, indicating the area of the screen that had changed, but I suspect that's not right either. I tried that out with the screen reader running, and it forces it to start reading that whole area of the screen again. If you're doing something that scrolls in a window, I would think all you care about is the newly revealed lines - you don't need to be told about the parts that have just moved and which you've likely already seen.

@j4james commented on GitHub (Mar 10, 2022): Btw, I thought at first that it might make sense to send an `EVENT_CONSOLE_UPDATE_REGION` here, indicating the area of the screen that had changed, but I suspect that's not right either. I tried that out with the screen reader running, and it forces it to start reading that whole area of the screen again. If you're doing something that scrolls in a window, I would think all you care about is the newly revealed lines - you don't need to be told about the parts that have just moved and which you've likely already seen.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16964