[mutter] wayland: Fetch wl_output logical monitor via helper



commit 2b59b85d858978a16834eccbc708d723f4a46c38
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Feb 5 16:46:43 2021 +0100

    wayland: Fetch wl_output logical monitor via helper
    
    Will be useful when wl_output gets tied to a MetaMonitor, instead of a
    MetaLogicalMonitor.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>

 src/wayland/meta-wayland-legacy-xdg-shell.c | 14 +++++++++++---
 src/wayland/meta-wayland-outputs.c          |  6 ++++++
 src/wayland/meta-wayland-outputs.h          |  2 ++
 src/wayland/meta-wayland-surface.c          |  2 +-
 src/wayland/meta-wayland-xdg-shell.c        | 12 ++++++++----
 5 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/wayland/meta-wayland-legacy-xdg-shell.c b/src/wayland/meta-wayland-legacy-xdg-shell.c
index 3c1ed8e935..af789ec2a1 100644
--- a/src/wayland/meta-wayland-legacy-xdg-shell.c
+++ b/src/wayland/meta-wayland-legacy-xdg-shell.c
@@ -438,9 +438,17 @@ zxdg_toplevel_v6_set_fullscreen (struct wl_client   *client,
 
   if (output_resource)
     {
-      MetaWaylandOutput *output = wl_resource_get_user_data (output_resource);
-      if (output && output->logical_monitor)
-        meta_window_move_to_monitor (window, output->logical_monitor->number);
+      MetaWaylandOutput *wayland_output;
+
+      wayland_output = wl_resource_get_user_data (output_resource);
+      if (wayland_output)
+        {
+          MetaLogicalMonitor *logical_monitor;
+
+          logical_monitor =
+            meta_wayland_output_get_logical_monitor (wayland_output);
+          meta_window_move_to_monitor (window, logical_monitor->number);
+        }
     }
 
   meta_window_make_fullscreen (window);
diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c
index 623832731d..5d085f12fd 100644
--- a/src/wayland/meta-wayland-outputs.c
+++ b/src/wayland/meta-wayland-outputs.c
@@ -63,6 +63,12 @@ meta_wayland_output_get_resources (MetaWaylandOutput *wayland_output)
   return wayland_output->resources;
 }
 
+MetaLogicalMonitor *
+meta_wayland_output_get_logical_monitor (MetaWaylandOutput *wayland_output)
+{
+  return wayland_output->logical_monitor;
+}
+
 static void
 output_resource_destroy (struct wl_resource *res)
 {
diff --git a/src/wayland/meta-wayland-outputs.h b/src/wayland/meta-wayland-outputs.h
index f906818e7c..4804681783 100644
--- a/src/wayland/meta-wayland-outputs.h
+++ b/src/wayland/meta-wayland-outputs.h
@@ -52,6 +52,8 @@ struct _MetaWaylandOutput
 
 const GList * meta_wayland_output_get_resources (MetaWaylandOutput *wayland_output);
 
+MetaLogicalMonitor * meta_wayland_output_get_logical_monitor (MetaWaylandOutput *wayland_output);
+
 void meta_wayland_outputs_init (MetaWaylandCompositor *compositor);
 
 #endif /* META_WAYLAND_OUTPUTS_H */
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index ee1635792e..872ee6c496 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1368,7 +1368,7 @@ update_surface_output_state (gpointer key, gpointer value, gpointer user_data)
 
   g_assert (surface->role);
 
-  logical_monitor = wayland_output->logical_monitor;
+  logical_monitor = meta_wayland_output_get_logical_monitor (wayland_output);
   if (!logical_monitor)
     {
       set_surface_is_on_output (surface, wayland_output, FALSE);
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c
index c5f0d0b913..62a5e786ce 100644
--- a/src/wayland/meta-wayland-xdg-shell.c
+++ b/src/wayland/meta-wayland-xdg-shell.c
@@ -461,12 +461,16 @@ xdg_toplevel_set_fullscreen (struct wl_client   *client,
 
   if (output_resource)
     {
-      MetaWaylandOutput *output = wl_resource_get_user_data (output_resource);
+      MetaWaylandOutput *wayland_output;
 
-      if (output && output->logical_monitor)
+      wayland_output = wl_resource_get_user_data (output_resource);
+      if (wayland_output)
         {
-          meta_window_move_to_monitor (window,
-                                       output->logical_monitor->number);
+          MetaLogicalMonitor *logical_monitor;
+
+          logical_monitor =
+            meta_wayland_output_get_logical_monitor (wayland_output);
+          meta_window_move_to_monitor (window, logical_monitor->number);
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]