Message ID | 20240324152150.21506-1-irina.ryapolova@syntacore.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | chardev/char-win-stdio: Fix keyboard input after exit Qemu on | expand |
Hi On Sun, Mar 24, 2024 at 7:23 PM Irina Ryapolova <irina.ryapolova@syntacore.com> wrote: > > After exit Qemu need to return the terminal to the default state. > > Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com> > --- > chardev/char-win-stdio.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c > index 1a18999e78..4fa2c3de8b 100644 > --- a/chardev/char-win-stdio.c > +++ b/chardev/char-win-stdio.c > @@ -220,6 +220,7 @@ err1: > static void char_win_stdio_finalize(Object *obj) > { > WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj); > + DWORD dwMode; > > if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) { > CloseHandle(stdio->hInputReadyEvent); > @@ -230,6 +231,10 @@ static void char_win_stdio_finalize(Object *obj) > if (stdio->hInputThread != INVALID_HANDLE_VALUE) { > TerminateThread(stdio->hInputThread, 0); > } > + > + GetConsoleMode(stdio->hStdIn, &dwMode); > + dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT; > + SetConsoleMode(stdio->hStdIn, dwMode); I'd suggest saving the mode when opening instead, to make sure we restore the same value. thanks
Hi Irina On Mon, Mar 25, 2024 at 10:44 AM Marc-André Lureau <marcandre.lureau@gmail.com> wrote: > > Hi > > On Sun, Mar 24, 2024 at 7:23 PM Irina Ryapolova > <irina.ryapolova@syntacore.com> wrote: > > > > After exit Qemu need to return the terminal to the default state. > > > > Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com> > > --- > > chardev/char-win-stdio.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c > > index 1a18999e78..4fa2c3de8b 100644 > > --- a/chardev/char-win-stdio.c > > +++ b/chardev/char-win-stdio.c > > @@ -220,6 +220,7 @@ err1: > > static void char_win_stdio_finalize(Object *obj) > > { > > WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj); > > + DWORD dwMode; > > > > if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) { > > CloseHandle(stdio->hInputReadyEvent); > > @@ -230,6 +231,10 @@ static void char_win_stdio_finalize(Object *obj) > > if (stdio->hInputThread != INVALID_HANDLE_VALUE) { > > TerminateThread(stdio->hInputThread, 0); > > } > > + > > + GetConsoleMode(stdio->hStdIn, &dwMode); > > + dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT; > > + SetConsoleMode(stdio->hStdIn, dwMode); > > I'd suggest saving the mode when opening instead, to make sure we > restore the same value. > > thanks Do you agree? Could you update the patch? thanks
diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c index 1a18999e78..4fa2c3de8b 100644 --- a/chardev/char-win-stdio.c +++ b/chardev/char-win-stdio.c @@ -220,6 +220,7 @@ err1: static void char_win_stdio_finalize(Object *obj) { WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj); + DWORD dwMode; if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) { CloseHandle(stdio->hInputReadyEvent); @@ -230,6 +231,10 @@ static void char_win_stdio_finalize(Object *obj) if (stdio->hInputThread != INVALID_HANDLE_VALUE) { TerminateThread(stdio->hInputThread, 0); } + + GetConsoleMode(stdio->hStdIn, &dwMode); + dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT; + SetConsoleMode(stdio->hStdIn, dwMode); } static int win_stdio_write(Chardev *chr, const uint8_t *buf, int len)
After exit Qemu need to return the terminal to the default state. Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com> --- chardev/char-win-stdio.c | 5 +++++ 1 file changed, 5 insertions(+)