From f80bf834651f12fb98432376477350327963b476 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
Date: Thu, 12 May 2022 11:53:18 +0200
Subject: [PATCH] xwayland: add xwl_output_from_wl_output()

Add a convenient function to get the xwl_output from a given wl_output.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
---
 hw/xwayland/xwayland-output.c | 14 ++++++++++++++
 hw/xwayland/xwayland-output.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 3d9ef3677a..39434b5ec6 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -752,6 +752,20 @@ xwl_output_set_emulated(struct xwl_output *xwl_output)
                            &val, FALSE, FALSE);
 }
 
+struct xwl_output*
+xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
+                          struct wl_output* wl_output)
+{
+    struct xwl_output *xwl_output;
+
+    xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
+        if (xwl_output->output == wl_output)
+            return xwl_output;
+    }
+
+    return NULL;
+}
+
 struct xwl_output *
 xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
 {
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index 63aee82444..603b54527a 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -79,6 +79,9 @@ Bool xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen);
 void xwl_output_set_mode_fixed(struct xwl_output *xwl_output,
                                RRModePtr mode);
 
+struct xwl_output *xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
+                                             struct wl_output* wl_output);
+
 struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
                                      uint32_t id, Bool with_xrandr);
 
-- 
GitLab