monitor-config-manager: Verify more things about logical monitor configs
Verify even more assumptions we make about logical monitor configs: - Have a more explicit check that the monitor modes in the logical monitor are all equal - Complain if scale factor with physical layout mode is fractional - Make sure that scale factor with logical layout mode actually scales to a non-fractional width and height Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
This commit is contained in:
parent
a203020c4b
commit
becee89fb9
@ -1756,8 +1756,11 @@ meta_verify_logical_monitor_config (MetaLogicalMonitorConfig *logical_monitor
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
int expected_mode_width = 0;
|
int layout_width, layout_height;
|
||||||
int expected_mode_height = 0;
|
MetaMonitorConfig *first_monitor_config;
|
||||||
|
int mode_width, mode_height;
|
||||||
|
int expected_mode_width = 0, expected_mode_height = 0;
|
||||||
|
float scale = logical_monitor_config->scale;
|
||||||
|
|
||||||
if (logical_monitor_config->layout.x < 0 ||
|
if (logical_monitor_config->layout.x < 0 ||
|
||||||
logical_monitor_config->layout.y < 0)
|
logical_monitor_config->layout.y < 0)
|
||||||
@ -1776,42 +1779,74 @@ meta_verify_logical_monitor_config (MetaLogicalMonitorConfig *logical_monitor
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mtk_monitor_transform_is_rotated (logical_monitor_config->transform))
|
first_monitor_config = logical_monitor_config->monitor_configs->data;
|
||||||
{
|
mode_width = first_monitor_config->mode_spec->width;
|
||||||
expected_mode_width = logical_monitor_config->layout.height;
|
mode_height = first_monitor_config->mode_spec->height;
|
||||||
expected_mode_height = logical_monitor_config->layout.width;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
expected_mode_width = logical_monitor_config->layout.width;
|
|
||||||
expected_mode_height = logical_monitor_config->layout.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (layout_mode)
|
|
||||||
{
|
|
||||||
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
|
|
||||||
expected_mode_width = (int) roundf (expected_mode_width *
|
|
||||||
logical_monitor_config->scale);
|
|
||||||
expected_mode_height = (int) roundf (expected_mode_height *
|
|
||||||
logical_monitor_config->scale);
|
|
||||||
break;
|
|
||||||
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (l = logical_monitor_config->monitor_configs; l; l = l->next)
|
for (l = logical_monitor_config->monitor_configs; l; l = l->next)
|
||||||
{
|
{
|
||||||
MetaMonitorConfig *monitor_config = l->data;
|
MetaMonitorConfig *monitor_config = l->data;
|
||||||
|
|
||||||
if (monitor_config->mode_spec->width != expected_mode_width ||
|
if (monitor_config->mode_spec->width != mode_width ||
|
||||||
monitor_config->mode_spec->height != expected_mode_height)
|
monitor_config->mode_spec->height != mode_height)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Monitor modes in logical monitor conflict");
|
"Monitors modes in logical monitor not equal");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mtk_monitor_transform_is_rotated (logical_monitor_config->transform))
|
||||||
|
{
|
||||||
|
layout_width = logical_monitor_config->layout.height;
|
||||||
|
layout_height = logical_monitor_config->layout.width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
layout_width = logical_monitor_config->layout.width;
|
||||||
|
layout_height = logical_monitor_config->layout.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (layout_mode)
|
||||||
|
{
|
||||||
|
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
|
||||||
|
{
|
||||||
|
float scaled_width = mode_width / scale;
|
||||||
|
float scaled_height = mode_height / scale;
|
||||||
|
|
||||||
|
if (floorf (scaled_width) != scaled_width ||
|
||||||
|
floorf (scaled_height) != scaled_height)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Scaled logical monitor size is fractional");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_mode_width = (int) roundf (layout_width * scale);
|
||||||
|
expected_mode_height = (int) roundf (layout_height * scale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
|
||||||
|
if (!G_APPROX_VALUE (scale, roundf (scale), FLT_EPSILON))
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"A fractional scale with physical layout mode not allowed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_mode_width = layout_width;
|
||||||
|
expected_mode_height = layout_height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode_width != expected_mode_width || mode_height != expected_mode_height)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Monitor mode size doesn't match scaled monitor layout");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user