diff mbox series

[32/67] ui/console: simplify getting active_console size

Message ID 20230830093843.3531473-33-marcandre.lureau@redhat.com
State New
Headers show
Series Make pixman an optional dependency | expand

Commit Message

Marc-André Lureau Aug. 30, 2023, 9:38 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

We can get the active console dimension regardless of its kind, by
simply giving NULL as argument. It will fallback with the given value
when the dimensions aren't known.

This will also allow to move the code in a separate unit more easily.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/console.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Daniel P. Berrangé Sept. 1, 2023, 2:37 p.m. UTC | #1
On Wed, Aug 30, 2023 at 01:38:06PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> We can get the active console dimension regardless of its kind, by
> simply giving NULL as argument. It will fallback with the given value
> when the dimensions aren't known.
> 
> This will also allow to move the code in a separate unit more easily.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  ui/console.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
diff mbox series

Patch

diff --git a/ui/console.c b/ui/console.c
index 5d521ba79d..70e11f924d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2577,10 +2577,8 @@  static void vc_chr_open(Chardev *chr,
     drv->console = s;
 
     if (QEMU_CONSOLE(s)->scanout.kind != SCANOUT_SURFACE) {
-        if (active_console && active_console->scanout.kind == SCANOUT_SURFACE) {
-            g_width = qemu_console_get_width(active_console, g_width);
-            g_height = qemu_console_get_height(active_console, g_height);
-        }
+        g_width = qemu_console_get_width(NULL, g_width);
+        g_height = qemu_console_get_height(NULL, g_height);
         QEMU_CONSOLE(s)->surface = qemu_create_displaysurface(g_width, g_height);
         QEMU_CONSOLE(s)->scanout.kind = SCANOUT_SURFACE;
     }