monitor-store: Support configuring logical monitor scale

Add support to configure the logical monitor scale. With this, it
becomes possible to override the automatically calculated scaling
number per logical monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2017-01-19 17:26:52 +08:00
parent a393a614a1
commit ee32ca3efe

View File

@ -37,6 +37,7 @@
* <logicalmonitor>
* <x>0</x>
* <y>0</y>
* <scale>1</scale>
* <monitor>
* <monitorspec>
* <connector>LVDS1</connector>
@ -94,6 +95,7 @@ typedef enum
STATE_LOGICAL_MONITOR_Y,
STATE_LOGICAL_MONITOR_PRIMARY,
STATE_LOGICAL_MONITOR_PRESENTATION,
STATE_LOGICAL_MONITOR_SCALE,
STATE_MONITOR,
STATE_MONITOR_SPEC,
STATE_MONITOR_SPEC_CONNECTOR,
@ -206,6 +208,10 @@ handle_start_element (GMarkupParseContext *context,
{
parser->state = STATE_LOGICAL_MONITOR_Y;
}
else if (g_str_equal (element_name, "scale"))
{
parser->state = STATE_LOGICAL_MONITOR_SCALE;
}
else if (g_str_equal (element_name, "primary"))
{
parser->state = STATE_LOGICAL_MONITOR_PRIMARY;
@ -232,6 +238,7 @@ handle_start_element (GMarkupParseContext *context,
case STATE_LOGICAL_MONITOR_X:
case STATE_LOGICAL_MONITOR_Y:
case STATE_LOGICAL_MONITOR_SCALE:
case STATE_LOGICAL_MONITOR_PRIMARY:
case STATE_LOGICAL_MONITOR_PRESENTATION:
{
@ -533,6 +540,7 @@ handle_end_element (GMarkupParseContext *context,
{
case STATE_LOGICAL_MONITOR_X:
case STATE_LOGICAL_MONITOR_Y:
case STATE_LOGICAL_MONITOR_SCALE:
case STATE_LOGICAL_MONITOR_PRIMARY:
case STATE_LOGICAL_MONITOR_PRESENTATION:
{
@ -622,7 +630,8 @@ handle_end_element (GMarkupParseContext *context,
g_assert (g_str_equal (element_name, "logicalmonitor"));
logical_monitor_config->scale = 1;
if (logical_monitor_config->scale == 0)
logical_monitor_config->scale = 1;
if (!verify_logical_monitor_config (logical_monitor_config, error))
return;
@ -834,6 +843,23 @@ handle_text (GMarkupParseContext *context,
return;
}
case STATE_LOGICAL_MONITOR_SCALE:
{
if (!read_int (text, text_len,
&parser->current_logical_monitor_config->scale, error))
return;
if (parser->current_logical_monitor_config->scale <= 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Logical monitor scale '%d' invalid",
parser->current_logical_monitor_config->scale);
return;
}
return;
}
case STATE_LOGICAL_MONITOR_PRIMARY:
{
read_bool (text, text_len,