From 28e5faab283d9f672bc9b38ff9a233c896b55a41 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
Date: Thu, 12 May 2022 16:02:09 +0200
Subject: [PATCH] xwayland: pass the emulated mode by reference

When using xrandr emulation, the emulated mode is passed as a pointer to
the XRandR mode from the xwl_output associated with the X11 client.

In preparation for fullscreen mode, we want to be able to reuse that
code but use a separate emulated mode.

Simply change the internal API to pass a reference to the emulated mode.

This introduces no functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
---
 hw/xwayland/xwayland-window.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 2c6b74fce6..491ce223ec 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -270,7 +270,7 @@ window_get_client_toplevel(WindowPtr window)
 static Bool
 xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
                                   struct xwl_output **xwl_output_ret,
-                                  struct xwl_emulated_mode **emulated_mode_ret)
+                                  struct xwl_emulated_mode *emulated_mode_ret)
 {
     struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
     struct xwl_emulated_mode *emulated_mode;
@@ -302,7 +302,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
             drawable->width  == emulated_mode->width &&
             drawable->height == emulated_mode->height) {
 
-            *emulated_mode_ret = emulated_mode;
+            memcpy(emulated_mode_ret, emulated_mode, sizeof(struct xwl_emulated_mode));
             *xwl_output_ret = xwl_output;
             return TRUE;
         }
@@ -320,7 +320,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
         drawable->width  == xwl_screen->width &&
         drawable->height == xwl_screen->height) {
 
-        *emulated_mode_ret = emulated_mode;
+        memcpy(emulated_mode_ret, emulated_mode, sizeof(struct xwl_emulated_mode));
         *xwl_output_ret = xwl_output;
         return TRUE;
     }
@@ -331,11 +331,11 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
 void
 xwl_window_check_resolution_change_emulation(struct xwl_window *xwl_window)
 {
-    struct xwl_emulated_mode *emulated_mode;
+    struct xwl_emulated_mode emulated_mode;
     struct xwl_output *xwl_output;
 
     if (xwl_window_should_enable_viewport(xwl_window, &xwl_output, &emulated_mode))
-        xwl_window_enable_viewport(xwl_window, xwl_output, emulated_mode);
+        xwl_window_enable_viewport(xwl_window, xwl_output, &emulated_mode);
     else if (xwl_window_has_viewport_enabled(xwl_window))
         xwl_window_disable_viewport(xwl_window);
 }
-- 
GitLab