[gnome-settings-daemon/gnome-3-2] color: Use a heuristic to set the screen atom when there is no primary device
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-2] color: Use a heuristic to set the screen atom when there is no primary device
- Date: Fri, 6 Jan 2012 15:34:33 +0000 (UTC)
commit e2d1d9ec0f624865949948ad15c687a07ef12d09
Author: Richard Hughes <richard hughsie com>
Date: Thu Jan 5 11:01:36 2012 +0000
color: Use a heuristic to set the screen atom when there is no primary device
In GNOME 2.32 we used a heuristic to work out what output profile should be set
screen-wide.
When converting the color process to g-s-d for GNOME 3, we switched to using the
primary display as the key to which monitor is the most important. This works
for most people, but some video drivers do not set a primary display when using
'xrandr --auto' and hence do not get a screen atom set.
In this case, fall back to the old heuristic when there are no primary monitors
displayed. This fixes applications like GIMP that expect a screen atom to be set
to properly color manage the display.
NOTE: We can't change GnomeRR to always return a primary monitor using the
same heuristic, otherwise it stops the screen control center capplet from
assigning the primary device correctly.
plugins/color/gsd-color-manager.c | 42 ++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/plugins/color/gsd-color-manager.c b/plugins/color/gsd-color-manager.c
index 2474040..d9147c1 100644
--- a/plugins/color/gsd-color-manager.c
+++ b/plugins/color/gsd-color-manager.c
@@ -959,6 +959,45 @@ out:
return output;
}
+/* this function is more complicated than it should be, due to the
+ * fact that XOrg sometimes assigns no primary devices when using
+ * "xrandr --auto" or when the version of RANDR is < 1.3 */
+static gboolean
+gcm_session_use_output_profile_for_screen (GsdColorManager *manager,
+ GnomeRROutput *output)
+{
+ gboolean has_laptop = FALSE;
+ gboolean has_primary = FALSE;
+ GnomeRROutput **outputs;
+ guint i;
+
+ /* do we have any screens marked as primary */
+ outputs = gnome_rr_screen_list_outputs (manager->priv->x11_screen);
+ if (outputs == NULL || outputs[0] == NULL) {
+ g_warning ("failed to get outputs");
+ return FALSE;
+ }
+ for (i = 0; outputs[i] != NULL; i++) {
+ if (!gnome_rr_output_is_connected (outputs[i]))
+ continue;
+ if (gnome_rr_output_get_is_primary (outputs[i]))
+ has_primary = TRUE;
+ if (gnome_rr_output_is_laptop (outputs[i]))
+ has_laptop = TRUE;
+ }
+
+ /* we have an assigned primary device, are we that? */
+ if (has_primary)
+ return gnome_rr_output_get_is_primary (output);
+
+ /* choosing the internal panel is probably sane */
+ if (has_laptop)
+ return gnome_rr_output_is_laptop (output);
+
+ /* we have to choose one, so go for the first listed device */
+ return gnome_rr_output_get_id (outputs[0]) == gnome_rr_output_get_id (output);
+}
+
static void
gcm_session_device_assign_profile_connect_cb (GObject *object,
GAsyncResult *res,
@@ -993,7 +1032,8 @@ gcm_session_device_assign_profile_connect_cb (GObject *object,
goto out;
/* set the _ICC_PROFILE atom */
- if (gnome_rr_output_get_is_primary (output)) {
+ ret = gcm_session_use_output_profile_for_screen (manager, output);
+ if (ret) {
ret = gcm_session_screen_set_icc_profile (manager,
filename,
&error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]