[gnome-color-manager] Fallback to the per-screen methods for xorg drivers that do not support Xrandr 1.3
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Fallback to the per-screen methods for xorg drivers that do not support Xrandr 1.3
- Date: Thu, 5 Nov 2009 14:38:21 +0000 (UTC)
commit b56122ce6d887f5c9bfed47d20a7f85dccd25ed1
Author: Richard Hughes <richard hughsie com>
Date: Thu Nov 5 14:37:29 2009 +0000
Fallback to the per-screen methods for xorg drivers that do not support Xrandr 1.3
configure.ac | 4 ++
contrib/gnome-color-manager.spec.in | 2 +
src/Makefile.am | 5 +++
src/gcm-utils.c | 53 ++++++++++++++++++++++++++++++++--
4 files changed, 60 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ebde8e2..2b0aee3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,6 +108,10 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 gthread-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
+PKG_CHECK_MODULES(XORG, xxf86vm xrandr)
+AC_SUBST(XORG_CFLAGS)
+AC_SUBST(XORG_LIBS)
+
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
diff --git a/contrib/gnome-color-manager.spec.in b/contrib/gnome-color-manager.spec.in
index 4816b53..0a68e68 100644
--- a/contrib/gnome-color-manager.spec.in
+++ b/contrib/gnome-color-manager.spec.in
@@ -43,6 +43,8 @@ BuildRequires: unique-devel >= %{unique_version}
BuildRequires: intltool
BuildRequires: libgudev1-devel
BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
+BuildRequires: libXxf86vm-devel
+BuildRequires: libXrandr-devel
%description
gnome-color-manager provides a way to control ICC colour profiles.
diff --git a/src/Makefile.am b/src/Makefile.am
index f4ad7c7..69ce1c8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES = \
$(UNIQUE_CFLAGS) \
$(GCONF_CFLAGS) \
$(VTE_CFLAGS) \
+ $(XORG_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
-DG_UDEV_API_IS_SUBJECT_TO_CHANGE \
-DGNOME_DESKTOP_USE_UNSTABLE_API \
@@ -58,6 +59,7 @@ gcm_inspect_LDADD = \
$(GNOMEDESKTOP_LIBS) \
$(GCONF_LIBS) \
$(GUDEV_LIBS) \
+ $(XORG_LIBS) \
$(GTK_LIBS)
gcm_inspect_CFLAGS = \
@@ -72,6 +74,7 @@ gcm_apply_LDADD = \
$(GNOMEDESKTOP_LIBS) \
$(GCONF_LIBS) \
$(GUDEV_LIBS) \
+ $(XORG_LIBS) \
$(GTK_LIBS)
gcm_apply_CFLAGS = \
@@ -86,6 +89,7 @@ gcm_import_LDADD = \
$(GNOMEDESKTOP_LIBS) \
$(GCONF_LIBS) \
$(GUDEV_LIBS) \
+ $(XORG_LIBS) \
$(GTK_LIBS)
gcm_import_CFLAGS = \
@@ -107,6 +111,7 @@ gcm_prefs_LDADD = \
$(VTE_LIBS) \
$(GUDEV_LIBS) \
$(DBUS_GLIB_LIBS) \
+ $(XORG_LIBS) \
$(GTK_LIBS)
gcm_prefs_CFLAGS = \
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 17b1df0..844ee7c 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -26,6 +26,7 @@
#include <gdk/gdkx.h>
#include <libgnomeui/gnome-rr.h>
#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/xf86vmode.h>
#include "gcm-utils.h"
#include "gcm-clut.h"
@@ -68,6 +69,26 @@ gcm_utils_output_is_lcd (const gchar *output_name)
}
/**
+ * gcm_utils_get_gamma_size_fallback:
+ **/
+static guint
+gcm_utils_get_gamma_size_fallback (void)
+{
+ guint size;
+ Bool rc;
+
+ /* this is per-screen, not per output which is less than ideal */
+ gdk_error_trap_push ();
+ egg_warning ("using PER-SCREEN gamma tables as driver is not XRANDR 1.3 compliant");
+ rc = XF86VidModeGetGammaRampSize (GDK_DISPLAY(), gdk_x11_get_default_screen (), (int*) &size);
+ gdk_error_trap_pop ();
+ if (!rc)
+ size = 0;
+
+ return size;
+}
+
+/**
* gcm_utils_get_gamma_size:
*
* Return value: the gamma size, or 0 if error;
@@ -87,6 +108,10 @@ gcm_utils_get_gamma_size (GnomeRRCrtc *crtc, GError **error)
if (gdk_error_trap_pop ())
size = 0;
+ /* some drivers support Xrandr 1.2, not 1.3 */
+ if (size == 0)
+ size = gcm_utils_get_gamma_size_fallback ();
+
/* no size, or X popped an error */
if (size == 0) {
if (error != NULL)
@@ -98,6 +123,23 @@ out:
}
/**
+ * gcm_utils_set_gamma_fallback:
+ **/
+static gboolean
+gcm_utils_set_gamma_fallback (XRRCrtcGamma *gamma, guint size)
+{
+ Bool rc;
+
+ /* this is per-screen, not per output which is less than ideal */
+ gdk_error_trap_push ();
+ egg_warning ("using PER-SCREEN gamma tables as driver is not XRANDR 1.3 compliant");
+ rc = XF86VidModeSetGammaRamp (GDK_DISPLAY(), gdk_x11_get_default_screen (), size, gamma->red, gamma->green, gamma->blue);
+ gdk_error_trap_pop ();
+
+ return rc;
+}
+
+/**
* gcm_utils_set_gamma_for_crtc:
*
* Return value: %TRUE for success;
@@ -146,10 +188,13 @@ gcm_utils_set_gamma_for_crtc (GnomeRRCrtc *crtc, GcmClut *clut, GError **error)
XRRSetCrtcGamma (GDK_DISPLAY(), id, gamma);
gdk_flush ();
if (gdk_error_trap_pop ()) {
- ret = FALSE;
- if (error != NULL)
- *error = g_error_new (1, 0, "failed to set crtc gamma %p (%i) on %i", gamma, array->len, id);
- goto out;
+ /* some drivers support Xrandr 1.2, not 1.3 */
+ ret = gcm_utils_set_gamma_fallback (gamma, array->len);
+ if (!ret) {
+ if (error != NULL)
+ *error = g_error_new (1, 0, "failed to set crtc gamma %p (%i) on %i", gamma, array->len, id);
+ goto out;
+ }
}
out:
if (gamma != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]