mouse events not delivered using conhost mode and vt output #10263

Closed
opened 2026-01-31 02:16:40 +00:00 by claunia · 3 comments
Owner

Originally created by @gdamore on GitHub (Aug 24, 2020).

Environment

PS C:\Users\garre\Work\tcell_demos> [Environment]::OSVersion

Platform ServicePack Version VersionString


Win32NT 10.0.19041.0 Microsoft Windows NT 10.0.19041.0

PS C:\Users\garre\Work\tcell_demos>

Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd]
Windows Terminal version (if applicable):

Any other software?

Steps to reproduce

Easiest reproduced with my open source tcell demonstration application:

github.com/gdamore/tcell

go run _demos/mouse.go

On a traditional cmd.exe this delivers mouse events and the mouse position is tracked, and using any of the three mouse buttons starts an application layer event (we create a numbered box with the number matching the mouse button).

This is using the following modes on CONIN$:

ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT | ENABLE_EXTENDED_FLAGS -- basically we want to receive all the mouse positions, as well as window resize events.

This works beautifully on cmd.exe. But the mouse doesn't work at all on Terminal -- instead it seems like the mouse is treated as a region select/copy.

There is also a branch (win256color) that changes the code to use VT output mode, but it behaves the same with respect to the mouse selection.

(I'd like to avoid using VT style inputs if possible, as those are both less rich (some keys are not mapped), and I think this would cause me to lose resize events which may be important.)

Expected behavior

Mouse events are passed to my application using the normal Console API.

Actual behavior

Mouse events don't make it through at all.

Originally created by @gdamore on GitHub (Aug 24, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment PS C:\Users\garre\Work\tcell\_demos> [Environment]::OSVersion Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.19041.0 Microsoft Windows NT 10.0.19041.0 PS C:\Users\garre\Work\tcell\_demos> ```none Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd] Windows Terminal version (if applicable): Any other software? ``` # Steps to reproduce Easiest reproduced with my open source tcell demonstration application: github.com/gdamore/tcell go run _demos/mouse.go On a traditional cmd.exe this delivers mouse events and the mouse position is tracked, and using any of the three mouse buttons starts an application layer event (we create a numbered box with the number matching the mouse button). This is using the following modes on CONIN$: ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT | ENABLE_EXTENDED_FLAGS -- basically we want to receive all the mouse positions, as well as window resize events. This works beautifully on cmd.exe. But the mouse doesn't work at all on Terminal -- instead it seems like the mouse is treated as a region select/copy. There is also a branch (win256color) that changes the code to use VT output mode, but it behaves the same with respect to the mouse selection. (I'd like to avoid using VT style inputs if possible, as those are both less rich (some keys are not mapped), and I think this would cause me to lose resize events which may be important.) <!-- A description of how to trigger this bug. --> # Expected behavior Mouse events are passed to my application using the normal Console API. # Actual behavior Mouse events don't make it through at all.
claunia added the Resolution-Duplicate label 2026-01-31 02:16:40 +00:00
Author
Owner

@DHowett commented on GitHub (Aug 24, 2020):

Thanks! The generation of windows mouse events (instead of VT mouse events) is being tracked using /dup #376.
Extended flags doesn’t impact your use of mouse and window events, so unless you are using it as documented to manipulate the edit mode you do not need to include it.

(Also, thanks for tcell! Since it looks like it’s cross-platform, how do you intend to offer the otherwise-unmappable keys off Windows? Using Windows input events is usually a significant burden to cross-platform libraries, not something that makes them better. We’ve been trying to focus on improving our VT story for that reason!)

@DHowett commented on GitHub (Aug 24, 2020): Thanks! The generation of windows mouse events (instead of VT mouse events) is being tracked using /dup #376. Extended flags doesn’t impact your use of mouse and window events, so unless you are using it as documented to manipulate the edit mode you do not need to include it. (Also, thanks for tcell! Since it looks like it’s cross-platform, how do you intend to offer the otherwise-unmappable keys off Windows? Using Windows input events is usually a significant burden to cross-platform libraries, not something that makes them better. We’ve been trying to focus on improving our VT story for that reason!)
Author
Owner

@ghost commented on GitHub (Aug 24, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Aug 24, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@gdamore commented on GitHub (Aug 24, 2020):

@DHowett the reason I use legacy events for several reasons:

  1. I wrote tcell to work with Windows console applications (as well as VT applications) in the days before Windows 10 had VT support.

  2. VT events are necessarily limited. So yes, we can only offer certain key combinations on Windows, whereas for XTerm and similar we wind up not being able to report key presses that are not reported by the system (i.e. those that don't have escape codes associated with them.) I do generally discourage application authors to avoid reliance on those for that reason, but some application developers prefer to support them where they can, and accept that they can't on other systems.

  3. Window size reporting. On *nix, we get a SIGWINCH to tell us the window has changed size. I cannot imagine how we will get that in a Windows app -- do we get a Window resize signal as well?

Yes, this does impose a portability burden. The tcell application tries to provide for the necessary plumbing so that application authors don't have to worry about this, and it will Just Work regardless of using a Windows (old) console (think Windows 8 or earlier), a new Windows 10 console, Windows Terminal, iTerm (or any of the various alternatives) on macOS, a Linux or FreeBSD console, or an of the various X11 based terminal emulators.

@gdamore commented on GitHub (Aug 24, 2020): @DHowett the reason I use legacy events for several reasons: 1. I wrote tcell to work with Windows console applications (as well as VT applications) in the days before Windows 10 had VT support. 2. VT events are necessarily limited. So yes, we can only offer certain key combinations on Windows, whereas for XTerm and similar we wind up not being able to report key presses that are not reported by the system (i.e. those that don't have escape codes associated with them.) I do generally discourage application authors to avoid reliance on those for that reason, but some application developers prefer to support them where they can, and accept that they can't on other systems. 3. Window size reporting. On *nix, we get a SIGWINCH to tell us the window has changed size. I cannot imagine how we will get that in a Windows app -- do we get a Window resize signal as well? Yes, this does impose a portability burden. The tcell application tries to provide for the necessary plumbing so that application authors don't have to worry about this, and it will Just Work regardless of using a Windows (old) console (think Windows 8 or earlier), a new Windows 10 console, Windows Terminal, iTerm (or any of the various alternatives) on macOS, a Linux or FreeBSD console, or an of the various X11 based terminal emulators.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10263