bgo#593866 - Don't assert when the current output doesn't have a resolution set yet
Signed-off-by: Federico Mena Quintero <federico@novell.com>
This commit is contained in:
parent
16b523deb3
commit
5ebf7c1c51
1 changed files with 29 additions and 24 deletions
|
@ -511,6 +511,29 @@ make_resolution_string (int width, int height)
|
|||
return g_strdup_printf (_("%d x %d"), width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
find_best_mode (GnomeRRMode **modes, int *out_width, int *out_height)
|
||||
{
|
||||
int i;
|
||||
|
||||
*out_width = 0;
|
||||
*out_height = 0;
|
||||
|
||||
for (i = 0; modes[i] != NULL; i++)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
w = gnome_rr_mode_get_width (modes[i]);
|
||||
h = gnome_rr_mode_get_height (modes[i]);
|
||||
|
||||
if (w * h > *out_width * *out_height)
|
||||
{
|
||||
*out_width = w;
|
||||
*out_height = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rebuild_resolution_combo (App *app)
|
||||
{
|
||||
|
@ -548,7 +571,12 @@ rebuild_resolution_combo (App *app)
|
|||
current = idle_free (make_resolution_string (app->current_output->width, app->current_output->height));
|
||||
|
||||
if (!combo_select (app->resolution_combo, current))
|
||||
g_assert_not_reached ();
|
||||
{
|
||||
int best_w, best_h;
|
||||
|
||||
find_best_mode (modes, &best_w, &best_h);
|
||||
combo_select (app->resolution_combo, idle_free (make_resolution_string (best_w, best_h)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -653,29 +681,6 @@ on_rate_changed (GtkComboBox *box, gpointer data)
|
|||
foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
|
||||
}
|
||||
|
||||
static void
|
||||
find_best_mode (GnomeRRMode **modes, int *out_width, int *out_height)
|
||||
{
|
||||
int i;
|
||||
|
||||
*out_width = 0;
|
||||
*out_height = 0;
|
||||
|
||||
for (i = 0; modes[i] != NULL; i++)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
w = gnome_rr_mode_get_width (modes[i]);
|
||||
h = gnome_rr_mode_get_height (modes[i]);
|
||||
|
||||
if (w * h > *out_width * *out_height)
|
||||
{
|
||||
*out_width = w;
|
||||
*out_height = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
select_resolution_for_current_output (App *app)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue