monitor-manager: Make color space and HDR metadata accessible from lg

This adds a new 'experimental-hdr' string property to the MonitorManager
which can be changed from looking glass.

Currently when the string equals 'on', HDR (PQ, Rec2020) will be enabled
on all monitors which support it. In the future support for more
transfer functions and color spaces as well as HDR metadata can be
added.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
This commit is contained in:
Sebastian Wick
2023-03-02 01:35:10 +01:00
committed by Marge Bot
parent fad0efa687
commit 48e759c443
3 changed files with 157 additions and 0 deletions

View File

@ -2242,3 +2242,63 @@ meta_monitor_set_privacy_screen_enabled (MetaMonitor *monitor,
return meta_output_set_privacy_screen_enabled (output, enabled, error);
}
gboolean
meta_monitor_set_color_space (MetaMonitor *monitor,
MetaOutputColorspace color_space,
GError **error)
{
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
GList *l;
for (l = priv->outputs; l; l = l->next)
{
MetaOutput *output = l->data;
if (!meta_output_is_color_space_supported (output, color_space))
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"The color space is not supported by this monitor");
return FALSE;
}
}
for (l = priv->outputs; l; l = l->next)
{
MetaOutput *output = l->data;
meta_output_set_color_space (output, color_space);
}
return TRUE;
}
gboolean
meta_monitor_set_hdr_metadata (MetaMonitor *monitor,
MetaOutputHdrMetadata *metadata,
GError **error)
{
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
GList *l;
for (l = priv->outputs; l; l = l->next)
{
MetaOutput *output = l->data;
if (!meta_output_is_hdr_metadata_supported (output))
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"HDR metadata is not supported by this monitor");
return FALSE;
}
}
for (l = priv->outputs; l; l = l->next)
{
MetaOutput *output = l->data;
meta_output_set_hdr_metadata (output, metadata);
}
return TRUE;
}