Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing Alt+any key closes app when using NetDriver #3916

Open
YourRobotOverlord opened this issue Feb 20, 2025 · 3 comments
Open

Pressing Alt+any key closes app when using NetDriver #3916

YourRobotOverlord opened this issue Feb 20, 2025 · 3 comments
Labels

Comments

@YourRobotOverlord
Copy link

Describe the bug
Pressing Alt+any key closes app when using NetDriver in v2_release

To Reproduce
Steps to reproduce the behavior:

  1. Go to UICatalog directory
  2. dotnet run --driver NetDriver
  3. Press Alt+F
  4. UICatalog immediately exits

Expected behavior
The 'File' menu should open

Desktop (please complete the following information):

  • OS: Windows 11
  • Windows Terminal/Powershell
@tznind
Copy link
Collaborator

tznind commented Feb 20, 2025

Looks like terminal sends Esc,F:

2025-02-20 07:52:15.193 +00:00 [VRB] AnsiResponseParser releasing '<esc>'
2025-02-20 07:52:15.193 +00:00 [VRB] AnsiResponseParser releasing 'f'
2025-02-20 07:52:15.200 +00:00 [VRB] InputProcessor raised Esc
2025-02-20 07:52:15.206 +00:00 [VRB] InputProcessor raised f
2025-02-20 07:52:15.211 +00:00 [VRB] MenuBar triggered redraw (NeedsDraw=True NeedsLayout=False) 
2025-02-20 07:52:15.234 +00:00 [INF] RequestStop 'UICatalogTopLevel(1){X=0,Y=0,Width=120,Height=30}'
2025-02-20 07:52:15.271 +00:00 [INF] Input loop exited cleanly

Terminal Sends Escape Sequences

Many terminal emulators translate Alt + Key as Esc followed by Key.
This is a legacy behavior from older Unix systems where the Meta key (Alt) was represented using an Escape (Esc) prefix.

Should be pretty easy fix in #3837 , more complicated in NetDriver/NetEvents (which v2 should replace at some point).

@tznind
Copy link
Collaborator

tznind commented Feb 20, 2025

Ok its actually slightly more complex because we have to distinguish between SS3 patterns and Alt patterns. For example.

EscOP - F1
EscO -  Alt + Upper case O

But AnsiParser is currently set up to assume input stream is deterministic - i.e. it has minimal timing awareness. So if we see EscO we cannot just release it as Alt - we need to wait and see if P follows in which case its F1.

There is some timing already built in with InputProcessor, for example here:

private IEnumerable<T> ReleaseParserHeldKeysIfStale ()
{
    if (Parser.State == AnsiResponseParserState.ExpectingEscapeSequence && DateTime.Now - Parser.StateChangedAt > _escTimeout)
    {
        return Parser.Release ().Select (o => o.Item2);
    }

    return [];
}

I think it should be possible to tap in at the release stage and do the Alt processing here.

@tznind
Copy link
Collaborator

tznind commented Feb 22, 2025

I have fixed in #3837 for the v2 driver, please try running v2net driver on that branch.

works for single keypress and held down

Image
Keys scenario with v2 net driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants