From 46a4a080b71167cd725a6c3d208345d1bdc0e0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 1 Dec 2021 23:24:33 +0100 Subject: [PATCH] virtual-monitor: Split out mode info into separate struct Will help when changing virtual monitor modes. Part-of: --- 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 943753694..6febe4dfa 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 2bd95ffd7..f4a207a6d 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 2b733df9c..1daa1d8be 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 3bb883049..42d84f633 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 e3ddb289c..a5c63cee3 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 3f81f4180..0976f86ca 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);