mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
monitor-config-store: Store and parse rgbrange
monitor property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
This commit is contained in:
parent
5ca2e06b2c
commit
3f866d22c9
@ -33,6 +33,7 @@ typedef struct _MetaMonitorConfig
|
||||
gboolean enable_underscanning;
|
||||
gboolean has_max_bpc;
|
||||
unsigned int max_bpc;
|
||||
MetaOutputRGBRange rgb_range;
|
||||
} MetaMonitorConfig;
|
||||
|
||||
typedef struct _MetaLogicalMonitorConfig
|
||||
|
@ -166,6 +166,7 @@ typedef enum
|
||||
STATE_MONITOR_MODE_FLAG,
|
||||
STATE_MONITOR_UNDERSCANNING,
|
||||
STATE_MONITOR_MAXBPC,
|
||||
STATE_MONITOR_RGB_RANGE,
|
||||
STATE_DISABLED,
|
||||
STATE_POLICY,
|
||||
STATE_STORES,
|
||||
@ -216,6 +217,7 @@ meta_monitor_config_init (MetaMonitorConfig *config)
|
||||
config->enable_underscanning = FALSE;
|
||||
config->has_max_bpc = FALSE;
|
||||
config->max_bpc = 0;
|
||||
config->rgb_range = META_OUTPUT_RGB_RANGE_AUTO;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -463,6 +465,10 @@ handle_start_element (GMarkupParseContext *context,
|
||||
{
|
||||
parser->state = STATE_MONITOR_MAXBPC;
|
||||
}
|
||||
else if (g_str_equal (element_name, "rgbrange"))
|
||||
{
|
||||
parser->state = STATE_MONITOR_RGB_RANGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
|
||||
@ -563,6 +569,13 @@ handle_start_element (GMarkupParseContext *context,
|
||||
return;
|
||||
}
|
||||
|
||||
case STATE_MONITOR_RGB_RANGE:
|
||||
{
|
||||
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
|
||||
"Invalid element '%s' under rgbrange", element_name);
|
||||
return;
|
||||
}
|
||||
|
||||
case STATE_DISABLED:
|
||||
{
|
||||
if (!g_str_equal (element_name, "monitorspec"))
|
||||
@ -854,6 +867,14 @@ handle_end_element (GMarkupParseContext *context,
|
||||
return;
|
||||
}
|
||||
|
||||
case STATE_MONITOR_RGB_RANGE:
|
||||
{
|
||||
g_assert (g_str_equal (element_name, "rgbrange"));
|
||||
|
||||
parser->state = STATE_MONITOR;
|
||||
return;
|
||||
}
|
||||
|
||||
case STATE_MONITOR:
|
||||
{
|
||||
MetaLogicalMonitorConfig *logical_monitor_config;
|
||||
@ -1368,6 +1389,21 @@ handle_text (GMarkupParseContext *context,
|
||||
return;
|
||||
}
|
||||
|
||||
case STATE_MONITOR_RGB_RANGE:
|
||||
{
|
||||
if (text_equals (text, text_len, "auto"))
|
||||
parser->current_monitor_config->rgb_range = META_OUTPUT_RGB_RANGE_AUTO;
|
||||
else if (text_equals (text, text_len, "full"))
|
||||
parser->current_monitor_config->rgb_range = META_OUTPUT_RGB_RANGE_FULL;
|
||||
else if (text_equals (text, text_len, "limited"))
|
||||
parser->current_monitor_config->rgb_range = META_OUTPUT_RGB_RANGE_LIMITED;
|
||||
else
|
||||
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
|
||||
"Invalid RGB Range type %.*s", (int)text_len, text);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case STATE_STORE:
|
||||
{
|
||||
MetaConfigStore store;
|
||||
@ -1515,6 +1551,30 @@ append_monitor_spec (GString *buffer,
|
||||
g_string_append_printf (buffer, "%s</monitorspec>\n", indentation);
|
||||
}
|
||||
|
||||
static void
|
||||
append_rgb_range (GString *buffer,
|
||||
MetaOutputRGBRange rgb_range,
|
||||
const char *indentation)
|
||||
{
|
||||
const char *rgb_range_str;
|
||||
|
||||
switch (rgb_range)
|
||||
{
|
||||
case META_OUTPUT_RGB_RANGE_FULL:
|
||||
rgb_range_str = "full";
|
||||
break;
|
||||
case META_OUTPUT_RGB_RANGE_LIMITED:
|
||||
rgb_range_str = "limited";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append_printf (buffer, "%s<rgbrange>%s</rgbrange>\n",
|
||||
indentation,
|
||||
rgb_range_str);
|
||||
}
|
||||
|
||||
static void
|
||||
append_monitors (GString *buffer,
|
||||
GList *monitor_configs)
|
||||
@ -1543,6 +1603,7 @@ append_monitors (GString *buffer,
|
||||
g_string_append (buffer, " </mode>\n");
|
||||
if (monitor_config->enable_underscanning)
|
||||
g_string_append (buffer, " <underscanning>yes</underscanning>\n");
|
||||
append_rgb_range (buffer, monitor_config->rgb_range, " ");
|
||||
|
||||
if (monitor_config->has_max_bpc)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user