[mutter] virtual-monitor: Split out mode info into separate struct



commit 46a4a080b71167cd725a6c3d208345d1bdc0e0ba
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Dec 1 23:24:33 2021 +0100

    virtual-monitor: Split out mode info into separate struct
    
    Will help when changing virtual monitor modes.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>

 src/backends/meta-backend-types.h                 | 1 +
 src/backends/meta-virtual-monitor.c               | 8 +++++---
 src/backends/meta-virtual-monitor.h               | 9 +++++++--
 src/backends/native/meta-crtc-mode-virtual.c      | 4 ++--
 src/backends/native/meta-crtc-mode-virtual.h      | 4 ++--
 src/backends/native/meta-virtual-monitor-native.c | 2 +-
 6 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/meta-backend-types.h b/src/backends/meta-backend-types.h
index 9437536944..6febe4dfa3 100644
--- a/src/backends/meta-backend-types.h
+++ b/src/backends/meta-backend-types.h
@@ -61,6 +61,7 @@ typedef struct _MetaScreenCastStream MetaScreenCastStream;
 
 typedef struct _MetaVirtualMonitor MetaVirtualMonitor;
 typedef struct _MetaVirtualMonitorInfo MetaVirtualMonitorInfo;
+typedef struct _MetaVirtualModeInfo MetaVirtualModeInfo;
 
 typedef struct _MetaIdleManager MetaIdleManager;
 
diff --git a/src/backends/meta-virtual-monitor.c b/src/backends/meta-virtual-monitor.c
index 2bd95ffd7d..f4a207a6d8 100644
--- a/src/backends/meta-virtual-monitor.c
+++ b/src/backends/meta-virtual-monitor.c
@@ -71,9 +71,11 @@ meta_virtual_monitor_info_new (int         width,
   MetaVirtualMonitorInfo *info;
 
   info = g_new0 (MetaVirtualMonitorInfo, 1);
-  info->width = width;
-  info->height = height;
-  info->refresh_rate = refresh_rate;
+  info->mode_info = (MetaVirtualModeInfo) {
+    .width = width,
+    .height = height,
+    .refresh_rate = refresh_rate,
+  };
   info->vendor = g_strdup (vendor);
   info->product = g_strdup (product);
   info->serial = g_strdup (serial);
diff --git a/src/backends/meta-virtual-monitor.h b/src/backends/meta-virtual-monitor.h
index 2b733df9cc..1daa1d8bee 100644
--- a/src/backends/meta-virtual-monitor.h
+++ b/src/backends/meta-virtual-monitor.h
@@ -26,16 +26,21 @@
 #include "backends/meta-backend-types.h"
 #include "core/util-private.h"
 
-typedef struct _MetaVirtualMonitorInfo
+struct _MetaVirtualModeInfo
 {
   int width;
   int height;
   float refresh_rate;
+};
+
+struct _MetaVirtualMonitorInfo
+{
+  MetaVirtualModeInfo mode_info;
 
   char *vendor;
   char *product;
   char *serial;
-} MetaVirtualMonitorInfo;
+};
 
 #define META_TYPE_VIRTUAL_MONITOR (meta_virtual_monitor_get_type ())
 G_DECLARE_DERIVABLE_TYPE (MetaVirtualMonitor, meta_virtual_monitor,
diff --git a/src/backends/native/meta-crtc-mode-virtual.c b/src/backends/native/meta-crtc-mode-virtual.c
index 3bb883049e..42d84f6330 100644
--- a/src/backends/native/meta-crtc-mode-virtual.c
+++ b/src/backends/native/meta-crtc-mode-virtual.c
@@ -34,8 +34,8 @@ G_DEFINE_TYPE (MetaCrtcModeVirtual, meta_crtc_mode_virtual,
                META_TYPE_CRTC_MODE)
 
 MetaCrtcModeVirtual *
-meta_crtc_mode_virtual_new (uint64_t                      id,
-                            const MetaVirtualMonitorInfo *info)
+meta_crtc_mode_virtual_new (uint64_t                   id,
+                            const MetaVirtualModeInfo *info)
 {
   g_autoptr (MetaCrtcModeInfo) crtc_mode_info = NULL;
   g_autofree char *crtc_mode_name = NULL;
diff --git a/src/backends/native/meta-crtc-mode-virtual.h b/src/backends/native/meta-crtc-mode-virtual.h
index e3ddb289c9..a5c63cee3e 100644
--- a/src/backends/native/meta-crtc-mode-virtual.h
+++ b/src/backends/native/meta-crtc-mode-virtual.h
@@ -28,7 +28,7 @@ G_DECLARE_FINAL_TYPE (MetaCrtcModeVirtual, meta_crtc_mode_virtual,
                       META, CRTC_MODE_VIRTUAL,
                       MetaCrtcMode)
 
-MetaCrtcModeVirtual * meta_crtc_mode_virtual_new (uint64_t                      id,
-                                                  const MetaVirtualMonitorInfo *info);
+MetaCrtcModeVirtual * meta_crtc_mode_virtual_new (uint64_t                   id,
+                                                  const MetaVirtualModeInfo *info);
 
 #endif /* META_CRTC_MODE_VIRTUAL_H */
diff --git a/src/backends/native/meta-virtual-monitor-native.c 
b/src/backends/native/meta-virtual-monitor-native.c
index 3f81f4180e..0976f86cae 100644
--- a/src/backends/native/meta-virtual-monitor-native.c
+++ b/src/backends/native/meta-virtual-monitor-native.c
@@ -54,7 +54,7 @@ meta_virtual_monitor_native_new (uint64_t                      id,
   MetaOutputVirtual *output_virtual;
 
   crtc_virtual = meta_crtc_virtual_new (id);
-  crtc_mode_virtual = meta_crtc_mode_virtual_new (id, info);
+  crtc_mode_virtual = meta_crtc_mode_virtual_new (id, &info->mode_info);
   output_virtual = meta_output_virtual_new (id, info,
                                             crtc_virtual,
                                             crtc_mode_virtual);


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