File gnome-control-center-bnc519803-randr-monitor-shifting.diff of Package gnome-control-center
From 2e3933ea4bc1cd6130e230e732398e612b6c792d Mon Sep 17 00:00:00 2001
From: Federico Mena Quintero <federico@novell.com>
Date: Wed, 15 Jul 2009 18:48:35 -0500
Subject: [PATCH 1/4] RANDR - Factor out function to generate strings for resolution like 'width x height'
Signed-off-by: Federico Mena Quintero <federico@novell.com>
---
capplets/display/xrandr-capplet.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index dca6d49..81a6384 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -540,6 +540,12 @@ rebuild_on_off_radios (App *app)
g_signal_handlers_unblock_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
}
+static char *
+make_resolution_string (int width, int height)
+{
+ return g_strdup_printf (_("%d x %d"), width, height);
+}
+
static void
rebuild_resolution_combo (App *app)
{
@@ -572,7 +578,7 @@ rebuild_resolution_combo (App *app)
height = gnome_rr_mode_get_height (modes[i]);
add_key (app->resolution_combo,
- idle_free (g_strdup_printf (_("%d x %d"), width, height)),
+ idle_free (make_resolution_string (width, height)),
width, height, 0, -1);
if (width * height > best_w * best_h)
@@ -582,15 +588,12 @@ rebuild_resolution_combo (App *app)
}
}
- current = idle_free (g_strdup_printf (_("%d x %d"),
- app->current_output->width,
- app->current_output->height));
+ current = idle_free (make_resolution_string (app->current_output->width, app->current_output->height));
if (!combo_select (app->resolution_combo, current))
{
combo_select (app->resolution_combo,
- idle_free (
- g_strdup_printf (_("%d x %d"), best_w, best_h)));
+ idle_free (make_resolution_string (best_w, best_h)));
}
}
--
1.6.0.2
From 318055c73956437472b319cbfb419d6bb7a0648b Mon Sep 17 00:00:00 2001
From: Federico Mena Quintero <federico@novell.com>
Date: Wed, 15 Jul 2009 18:52:50 -0500
Subject: [PATCH 2/4] RANDR - when turning an output on, default to its preferred resolution
Previously we were picking the output's highest-supported resolution, which is not
always the same as its preferred resolution. We also do this while actually turning
the output on, not as a side effect of rebuilding the resolution combo.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
---
capplets/display/xrandr-capplet.c | 64 +++++++++++++++++++++++++++++-------
1 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 81a6384..23cb713 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -551,7 +551,6 @@ rebuild_resolution_combo (App *app)
{
int i;
GnomeRRMode **modes;
- int best_w, best_h;
const char *current;
clear_combo (app->resolution_combo);
@@ -565,11 +564,10 @@ rebuild_resolution_combo (App *app)
}
g_assert (app->current_output != NULL);
+ g_assert (app->current_output->width != 0 && app->current_output->height != 0);
gtk_widget_set_sensitive (app->resolution_combo, TRUE);
- best_w = 0;
- best_h = 0;
for (i = 0; modes[i] != NULL; ++i)
{
int width, height;
@@ -580,21 +578,12 @@ rebuild_resolution_combo (App *app)
add_key (app->resolution_combo,
idle_free (make_resolution_string (width, height)),
width, height, 0, -1);
-
- if (width * height > best_w * best_h)
- {
- best_w = width;
- best_h = height;
- }
}
current = idle_free (make_resolution_string (app->current_output->width, app->current_output->height));
if (!combo_select (app->resolution_combo, current))
- {
- combo_select (app->resolution_combo,
- idle_free (make_resolution_string (best_w, best_h)));
- }
+ g_assert_not_reached ();
}
static void
@@ -700,6 +689,52 @@ on_rate_changed (GtkComboBox *box, gpointer data)
}
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)
+{
+ GnomeRRMode **modes;
+ int width, height;
+
+ if (app->current_output->pref_width != 0 && app->current_output->pref_height != 0)
+ {
+ app->current_output->width = app->current_output->pref_width;
+ app->current_output->height = app->current_output->pref_height;
+ return;
+ }
+
+ modes = get_current_modes (app);
+ if (!modes)
+ return;
+
+ find_best_mode (modes, &width, &height);
+
+ app->current_output->width = width;
+ app->current_output->height = height;
+}
+
+static void
monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data)
{
App *app = data;
@@ -723,6 +758,9 @@ monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data)
app->current_output->on = is_on;
+ if (is_on)
+ select_resolution_for_current_output (app); /* The refresh rate will be picked in rebuild_rate_combo() */
+
rebuild_gui (app);
foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
}
--
1.6.0.2
From 2bec43726ce34397480631c9d93ef646014d9f86 Mon Sep 17 00:00:00 2001
From: Federico Mena Quintero <federico@novell.com>
Date: Wed, 15 Jul 2009 18:55:24 -0500
Subject: [PATCH 3/4] RANDR - Factor out function to generate strings for refresh rate like '60 Hz'
Signed-off-by: Federico Mena Quintero <federico@novell.com>
---
capplets/display/xrandr-capplet.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 23cb713..75073f1 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -378,6 +378,12 @@ rebuild_rotation_combo (App *app)
combo_select (app->rotation_combo, _("Normal"));
}
+static char *
+make_rate_string (int hz)
+{
+ return g_strdup_printf (_("%d Hz"), hz);
+}
+
static void
rebuild_rate_combo (App *app)
{
@@ -412,7 +418,7 @@ rebuild_rate_combo (App *app)
height == app->current_output->height)
{
add_key (app->refresh_combo,
- idle_free (g_strdup_printf (_("%d Hz"), rate)),
+ idle_free (make_rate_string (rate)),
0, 0, rate, -1);
if (rate > best)
@@ -420,8 +426,8 @@ rebuild_rate_combo (App *app)
}
}
- if (!combo_select (app->refresh_combo, idle_free (g_strdup_printf (_("%d Hz"), app->current_output->rate))))
- combo_select (app->refresh_combo, idle_free (g_strdup_printf (_("%d Hz"), best)));
+ if (!combo_select (app->refresh_combo, idle_free (make_rate_string (app->current_output->rate))))
+ combo_select (app->refresh_combo, idle_free (make_rate_string (best)));
}
static int
--
1.6.0.2
From 7caeae3fd8e4c78ed96d1b451db0cbec465029df Mon Sep 17 00:00:00 2001
From: Federico Mena Quintero <federico@novell.com>
Date: Thu, 16 Jul 2009 11:27:30 -0500
Subject: [PATCH 4/4] RANDR - Don't realign outputs if the current output didn't change resolutions
Signed-off-by: Federico Mena Quintero <federico@novell.com>
---
capplets/display/xrandr-capplet.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 75073f1..2284f49 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -786,6 +786,9 @@ realign_outputs_after_resolution_change (App *app, GnomeOutputInfo *output_that_
g_assert (app->current_configuration != NULL);
+ if (output_that_changed->width == old_width && output_that_changed->height == old_height)
+ return;
+
old_right_edge = output_that_changed->x + old_width;
old_bottom_edge = output_that_changed->y + old_height;
--
1.6.0.2