microsoft / microsoft/terminal

mouse events are sent incorrectly in win32-input-mode

Open
#15,083 21 comments 0 reactions 0 assignees View on GitHub
Area-Input Area-VT Help Wanted Issue-Bug Product-Conhost Product-Conpty
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Steps to reproduce

1. Compile this test app using gcc under WSL:

```
#include
#include
#include
#include
#include
#include
#include
#include
#include

int main()
{
struct termios _ts = {};
int _ts_r = tcgetattr(1, &_ts);
if (_ts_r == 0) {
struct termios ts_ne = _ts;
//ts_ne.c_lflag &= ~(ECHO | ECHONL);
cfmakeraw(&ts_ne);
if (tcsetattr(1, TCSADRAIN, &ts_ne ) != 0) {
perror("TTYBackend: tcsetattr");
}
}

fprintf(stderr, "\x1b[?1049h");
fprintf(stderr, "\x1b[?1000h");
fprintf(stderr, "\x1b[?1001h");
fprintf(stderr, "\x1b[?1002h");

fprintf(stderr, "\x1b[?9001h");

for (;;) {
char ch = 0;
if (read(0, &ch, 1) <= 0) break;
if (ch <= 0x20 || ch == 0x7f) {
if (ch == 0x1b) fprintf(stderr, " ");
fprintf(stderr, "\\x%02x", (unsigned int)(unsigned char)ch);
} else {
fprintf(stderr, "%c", ch);
}
if (ch == 0x0d) break;
if (ch == 0x0a) break;
}
fprintf(stderr, "\x1b[?1049l");
fprintf(stderr, "\x1b[?1000l");
fprintf(stderr, "\x1b[?1001l");
fprintf(stderr, "\x1b[?1002l");

fprintf(stderr, "\x1b[?9001l");

if (tcsetattr(1, TCSADRAIN, &_ts ) != 0) {
perror("TTYBackend: tcsetattr");
}
}
```

2. Run it under Windows Terminal

3. Move mouse over the terminal window.

### Expected Behavior

We should see mouse movement escape sequences (`\x1b[M...` format)

### Actual Behavior

We see win32-input-mode escape sequences (`\x1b[A;B;C;D;E;F_` format)

![изображение](https://user-images.githubusercontent.com/1151423/229324322-11b546ed-8f84-40d1-8e13-a1930edef110.png)

Contributor guide

Open the contributing guide

Research direction

Compile and run the provided C test app under WSL in Windows Terminal, then compare the mouse input produced after enabling the listed terminal modes. Trace the win32-input-mode handling responsible for the \x1b[A;B;C;D;E;F_ sequences. Done means mouse movement produces the expected \x1b[M... format in this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.