monitor-manager: Filter out low screen resolutions

Avoid exporting through org.gnome.Mutter.DisplayConfig.GetCurrentState
excessively-low screen resolutions setting both a minimum width and a minimum
height. GetCurrentState is e.g. used by Gnome Control Center to build a list of
selectable resolutions.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=793223


(cherry picked from commit 649c26e05a)
This commit is contained in:
Andrea Azzarone 2018-07-16 16:09:40 +00:00 committed by Marco Trevisan
parent 44682a2cc5
commit 0c5e61a2ab
3 changed files with 23 additions and 2 deletions

View File

@ -1323,9 +1323,13 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
GVariantBuilder mode_properties_builder;
MetaCrtcModeFlag mode_flags;
if (!meta_monitor_mode_should_be_advertised (monitor_mode))
continue;
mode_id = meta_monitor_mode_get_id (monitor_mode);
meta_monitor_mode_get_resolution (monitor_mode,
&mode_width, &mode_height);
refresh_rate = meta_monitor_mode_get_refresh_rate (monitor_mode);
preferred_scale =

View File

@ -1553,6 +1553,22 @@ meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
return calculate_scale (monitor, monitor_mode);
}
static gboolean
is_logical_size_large_enough (gint width, gint height)
{
return width >= MINIMUM_LOGICAL_WIDTH &&
height >= MINIMUM_LOGICAL_HEIGHT;
}
gboolean
meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode)
{
g_return_val_if_fail (monitor_mode != NULL, FALSE);
return is_logical_size_large_enough (monitor_mode->spec.width,
monitor_mode->spec.height);
}
static float
get_closest_scale_factor_for_resolution (float width,
float height,
@ -1573,8 +1589,7 @@ get_closest_scale_factor_for_resolution (float width,
if (scale < MINIMUM_SCALE_FACTOR ||
scale > MAXIMUM_SCALE_FACTOR ||
floorf (scaled_w) < MINIMUM_LOGICAL_WIDTH ||
floorf (scaled_h) < MINIMUM_LOGICAL_HEIGHT)
!is_logical_size_large_enough (floorf (scaled_w), floorf (scaled_h)))
goto out;
if (floorf (scaled_w) == scaled_w && floorf (scaled_h) == scaled_h)

View File

@ -219,6 +219,8 @@ gboolean meta_monitor_mode_foreach_output (MetaMonitor *monitor,
gpointer user_data,
GError **error);
gboolean meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode);
MetaMonitorSpec * meta_monitor_spec_clone (MetaMonitorSpec *monitor_id);
gboolean meta_monitor_spec_equals (MetaMonitorSpec *monitor_id,