[gnome-control-center/wip/benzea/display-settings-widget: 7/10] display: Ensure we always have a mode for the monitor
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/benzea/display-settings-widget: 7/10] display: Ensure we always have a mode for the monitor
- Date: Sun, 20 Jan 2019 09:07:51 +0000 (UTC)
commit d98da8358acf0ae3ad438d7167e12cc20f01d4be
Author: Benjamin Berg <bberg redhat com>
Date: Sat Jan 19 23:35:36 2019 +0100
display: Ensure we always have a mode for the monitor
We need a valid mode to show the settings for a monitor. Just make up
one if we don't have something usable.
panels/display/cc-display-settings.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/panels/display/cc-display-settings.c b/panels/display/cc-display-settings.c
index 1e522836a..6335f1152 100644
--- a/panels/display/cc-display-settings.c
+++ b/panels/display/cc-display-settings.c
@@ -263,6 +263,11 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self)
cc_display_monitor_get_geometry (self->selected_output, NULL, NULL, &width, &height);
+ /* Selecte the first mode we can find if the monitor is disabled. */
+ current_mode = cc_display_monitor_get_mode (self->selected_output);
+ if (current_mode == NULL)
+ current_mode = cc_display_monitor_get_preferred_mode (self->selected_output);
+
if (should_show_rotation (self))
{
guint i;
@@ -298,11 +303,9 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self)
/* Only show refresh rate if we are not in cloning mode. */
if (!cc_display_config_is_cloning (self->config))
{
- CcDisplayMode *current_mode;
GList *item;
gdouble freq;
- current_mode = cc_display_monitor_get_mode (self->selected_output);
freq = cc_display_mode_get_freq_f (current_mode);
modes = cc_display_monitor_get_modes (self->selected_output);
@@ -348,8 +351,7 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self)
modes = cc_display_monitor_get_modes (self->selected_output);
g_list_store_remove_all (self->resolution_list);
- g_list_store_append (self->resolution_list,
- cc_display_monitor_get_mode (self->selected_output));
+ g_list_store_append (self->resolution_list, current_mode);
hdy_combo_row_set_selected_index (HDY_COMBO_ROW (self->resolution_row), 0);
for (item = modes; item != NULL; item = item->next)
{
@@ -393,14 +395,13 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self)
g_list_store_remove_all (self->scale_list);
if (!cc_display_config_is_cloning (self->config))
{
- CcDisplayMode *mode = cc_display_monitor_get_mode (self->selected_output);
const gdouble *scales, *scale;
- scales = cc_display_mode_get_supported_scales (mode);
+ scales = cc_display_mode_get_supported_scales (current_mode);
for (scale = scales; *scale != 0.0; scale++)
{
CcValueObject *obj;
- if (!display_mode_supported_at_scale (mode, *scale) &&
+ if (!display_mode_supported_at_scale (current_mode, *scale) &&
cc_display_monitor_get_scale (self->selected_output) != *scale)
continue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]