[PATCH v2] ui/console: Fix console resize with placeholder surface

Tianlan Zhou posted 1 patch 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240208154705.1896-1-bobby825@126.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] ui/console: Fix console resize with placeholder surface
Posted by Tianlan Zhou 2 weeks, 2 days ago
In `qemu_console_resize()`, the old surface of the console is kept if
the new console size is the same as the old one. If the old surface is a
placeholder, and the new size of console is the same as the placeholder
surface (640*480), it won't be replaced.
In this situation, the surface's `QEMU_PLACEHOLDER_FLAG` flag is still
set, so the console won't be displayed in SDL display mode.
This patch fixes this problem by forcing a new surface if the old one is
a placeholder.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Tianlan Zhou <bobby825@126.com>

---

v2:
- Slightly modify the commit message
- Add Reviewed-by: Marc-André Lureau

v1:
- Initial patch

---
 ui/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/console.c b/ui/console.c
index 7db921e3b7..832055675c 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1577,7 +1577,7 @@ void qemu_console_resize(QemuConsole *s, int width, int height)
     assert(QEMU_IS_GRAPHIC_CONSOLE(s));
 
     if ((s->scanout.kind != SCANOUT_SURFACE ||
-         (surface && surface->flags & QEMU_ALLOCATED_FLAG)) &&
+         (surface && !is_buffer_shared(surface) && !is_placeholder(surface))) &&
         qemu_console_get_width(s, -1) == width &&
         qemu_console_get_height(s, -1) == height) {
         return;
-- 
2.38.1.windows.1