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>
This commit is contained in:
Jonas Ådahl 2021-12-01 23:24:33 +01:00 committed by Marge Bot
parent a09b99261f
commit 46a4a080b7
6 changed files with 18 additions and 10 deletions

View File

@ -61,6 +61,7 @@ typedef struct _MetaScreenCastStream MetaScreenCastStream;
typedef struct _MetaVirtualMonitor MetaVirtualMonitor;
typedef struct _MetaVirtualMonitorInfo MetaVirtualMonitorInfo;
typedef struct _MetaVirtualModeInfo MetaVirtualModeInfo;
typedef struct _MetaIdleManager MetaIdleManager;

View File

@ -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);

View File

@ -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,

View File

@ -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;

View File

@ -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 */

View File

@ -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);