[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 8/8] chardev/char-win-stdio.c: restore old console mode
From: |
marcandre . lureau |
Subject: |
[PULL 8/8] chardev/char-win-stdio.c: restore old console mode |
Date: |
Tue, 23 Jul 2024 00:06:18 +0400 |
From: songziming <s.ziming@hotmail.com>
If I use `-serial stdio` on Windows, after QEMU exits, the terminal
could not handle arrow keys and tab any more. Because stdio backend
on Windows sets console mode to virtual terminal input when starts,
but does not restore the old mode when finalize.
This small patch saves the old console mode and set it back.
Signed-off-by: Ziming Song <s.ziming@hotmail.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID:
<ME3P282MB25488BE7C39BF0C35CD0DA5D8CA82@ME3P282MB2548.AUSP282.PROD.OUTLOOK.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..13325ca967 100644
--- a/chardev/char-win-stdio.c
+++ b/chardev/char-win-stdio.c
@@ -33,6 +33,7 @@
struct WinStdioChardev {
Chardev parent;
HANDLE hStdIn;
+ DWORD dwOldMode;
HANDLE hInputReadyEvent;
HANDLE hInputDoneEvent;
HANDLE hInputThread;
@@ -159,6 +160,7 @@ static void qemu_chr_open_stdio(Chardev *chr,
}
is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0;
+ stdio->dwOldMode = dwMode;
if (is_console) {
if (qemu_add_wait_object(stdio->hStdIn,
@@ -221,6 +223,9 @@ static void char_win_stdio_finalize(Object *obj)
{
WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj);
+ if (stdio->hStdIn != INVALID_HANDLE_VALUE) {
+ SetConsoleMode(stdio->hStdIn, stdio->dwOldMode);
+ }
if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputReadyEvent);
}
--
2.45.2.827.g557ae147e6
- [PULL 0/8] Ui patches, marcandre . lureau, 2024/07/22
- [PULL 1/8] vnc: increase max display size, marcandre . lureau, 2024/07/22
- [PULL 2/8] virtio-gpu-gl: declare dependency on ui-opengl, marcandre . lureau, 2024/07/22
- [PULL 3/8] Cursor: 8 -> 1 bit alpha downsampling improvement, marcandre . lureau, 2024/07/22
- [PULL 4/8] ui: add more tracing for dbus, marcandre . lureau, 2024/07/22
- [PULL 5/8] ui/vdagent: improve vdagent_fe_open() trace, marcandre . lureau, 2024/07/22
- [PULL 7/8] ui/vdagent: send caps on fe_open, marcandre . lureau, 2024/07/22
- [PULL 6/8] ui/vdagent: notify clipboard peers of serial reset, marcandre . lureau, 2024/07/22
- [PULL 8/8] chardev/char-win-stdio.c: restore old console mode,
marcandre . lureau <=
- Re: [PULL 0/8] Ui patches, Philippe Mathieu-Daudé, 2024/07/22
- Re: [PULL 0/8] Ui patches, Richard Henderson, 2024/07/23