Skip to content

Re-enable the parent window when a modal dialog's process dies #996

Open

Description

Follow-up to #995, which adds IPty.setParentWindow().

Once the host window owns the console window, a modal dialog owned by the console window's root owner (the host), like the Connect-AzAccount sign-in picker, disables the host while it's open. That's normal Windows behavior, and Windows Terminal works the same way. Closing the dialog enables the host again.

If the dialog's process dies while the dialog is open, for example because it crashed or was killed, nothing enables the host again, so it stops taking mouse and keyboard input. In VS Code, that's the whole window.

Proposal: an opt-in IWindowsPtyForkOptions.conptyReenableParentWindowOnExit. When the shell exits, if the parent window is still disabled and no visible window is owned by it, directly or through other owned windows, call EnableWindow(parent, TRUE).

  • Opt-in, because node-pty can't tell why the window is disabled. A host that disables its own window without showing a window it owns would get it enabled again.
  • It only runs when the shell exits, so it doesn't cover a dialog from a child process that dies while the shell keeps running.
  • Run it off the exit thread, since EnableWindow waits for the window's thread.
  • Compare window handles by their low 32 bits, since only those are significant.

An implementation with tests was in #995 at f164f25 before it was moved out. In a VS Code dev build with it, killing the shell while the Connect-AzAccount picker had VS Code disabled enabled VS Code again after about 50 ms. VS Code would opt in (microsoft/vscode#342784), since it only disables its windows while showing a window they own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions