MetaMonitor: Add mode spec concept

Add a "mode spec" concept, meaning to be used as a identifier for an
actual monitor mode. It consists of details making a mode unique, i.e.
the total resolution and refresh rate. This will later be used to get
the actual monitor mode (set of one or more CRTC modes).

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2016-12-17 22:29:33 +08:00
parent 0637537355
commit 5d9e2d8d2e
2 changed files with 30 additions and 13 deletions

View File

@ -28,9 +28,7 @@
typedef struct _MetaMonitorMode
{
int width;
int height;
float refresh_rate;
MetaMonitorModeSpec spec;
MetaMonitorCrtcMode *crtc_modes;
} MetaMonitorMode;
@ -176,9 +174,11 @@ meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
MetaMonitorMode *mode;
mode = g_new0 (MetaMonitorMode, 1);
mode->width = crtc_mode->width;
mode->height = crtc_mode->height;
mode->refresh_rate = crtc_mode->refresh_rate;
mode->spec = (MetaMonitorModeSpec) {
.width = crtc_mode->width,
.height = crtc_mode->height,
.refresh_rate = crtc_mode->refresh_rate
},
mode->crtc_modes = g_new (MetaMonitorCrtcMode, 1);
mode->crtc_modes[0] = (MetaMonitorCrtcMode) {
.x = 0,
@ -337,7 +337,8 @@ meta_monitor_tiled_generate_modes (MetaMonitorTiled *monitor_tiled)
mode = g_new0 (MetaMonitorMode, 1);
meta_monitor_tiled_calculate_tiled_size (monitor,
&mode->width, &mode->height);
&mode->spec.width,
&mode->spec.height);
mode->crtc_modes = g_new (MetaMonitorCrtcMode,
g_list_length (monitor_priv->outputs));
for (l = monitor_priv->outputs, i = 0; l; l = l->next, i++)
@ -356,10 +357,11 @@ meta_monitor_tiled_generate_modes (MetaMonitorTiled *monitor_tiled)
.crtc_mode = preferred_crtc_mode
};
g_warn_if_fail (mode->refresh_rate == 0.0f ||
mode->refresh_rate == preferred_crtc_mode->refresh_rate);
g_warn_if_fail (mode->spec.refresh_rate == 0.0f ||
(mode->spec.refresh_rate ==
preferred_crtc_mode->refresh_rate));
mode->refresh_rate = preferred_crtc_mode->refresh_rate;
mode->spec.refresh_rate = preferred_crtc_mode->refresh_rate;
}
monitor_priv->modes = g_list_append (monitor_priv->modes, mode);
@ -452,19 +454,25 @@ meta_monitor_get_modes (MetaMonitor *monitor)
return priv->modes;
}
MetaMonitorModeSpec *
meta_monitor_mode_get_spec (MetaMonitorMode *monitor_mode)
{
return &monitor_mode->spec;
}
void
meta_monitor_mode_get_resolution (MetaMonitorMode *monitor_mode,
int *width,
int *height)
{
*width = monitor_mode->width;
*height = monitor_mode->height;
*width = monitor_mode->spec.width;
*height = monitor_mode->spec.height;
}
float
meta_monitor_mode_get_refresh_rate (MetaMonitorMode *monitor_mode)
{
return monitor_mode->refresh_rate;
return monitor_mode->spec.refresh_rate;
}
void

View File

@ -28,6 +28,13 @@
typedef struct _MetaMonitorMode MetaMonitorMode;
typedef struct _MetaMonitorModeSpec
{
int width;
int height;
float refresh_rate;
} MetaMonitorModeSpec;
typedef struct _MetaMonitorCrtcMode
{
int x;
@ -91,6 +98,8 @@ uint32_t meta_monitor_tiled_get_tile_group_id (MetaMonitorTiled *monitor_tiled);
GList * meta_monitor_get_modes (MetaMonitor *monitor);
MetaMonitorModeSpec * meta_monitor_mode_get_spec (MetaMonitorMode *monitor_mode);
void meta_monitor_mode_get_resolution (MetaMonitorMode *monitor_mode,
int *width,
int *height);