[gnome-desktop/gobject-gnomerr] Turn the RANDR version checks into macros



commit 4da0756ef2e42b8040d8043029057b08e85efcec
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Jan 5 15:40:39 2011 -0600

    Turn the RANDR version checks into macros
    
    This makes them less error-prone to use.  Also, fixes the
    master check for RANDR 1.2 in gnome_rr_screen_initable_init(), which
    wouldn't handle RANDR versions above 1.x.
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 libgnome-desktop/gnome-rr.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index 75fb335..4b70321 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -60,6 +60,14 @@ typedef int Rotation;
 #define RR_Reflect_Y		32
 #endif
 
+#ifdef HAVE_RANDR
+#define RANDR_LIBRARY_IS_AT_LEAST_1_3 (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
+#else
+#define RANDR_LIBRARY_IS_AT_LEAST_1_3 0
+#endif
+
+#define SERVERS_RANDR_IS_AT_LEAST_1_3(priv) (priv->rr_major_version > 1 || (priv->rr_major_version == 1 && priv->rr_minor_version >= 3))
+
 enum {
     SCREEN_PROP_0,
     SCREEN_PROP_GDK_SCREEN,
@@ -453,9 +461,8 @@ fill_out_screen_info (Display *xdisplay,
 	 * XRRGetScreenResources, however it is available only
 	 * in RandR 1.3 or higher
 	 */
-#if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
-        /* Runtime check for RandR 1.3 or higher */
-        if (priv->rr_major_version == 1 && priv->rr_minor_version >= 3)
+#if RANDR_LIBRARY_IS_AT_LEAST_1_3
+        if (SERVERS_RANDR_IS_AT_LEAST_1_3 (priv))
             resources = XRRGetScreenResourcesCurrent (xdisplay, xroot);
         else
             resources = XRRGetScreenResources (xdisplay, xroot);
@@ -513,9 +520,8 @@ fill_out_screen_info (Display *xdisplay,
     }
 
     info->primary = None;
-#if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
-    /* Runtime check for RandR 1.3 or higher */
-    if (priv->rr_major_version == 1 && priv->rr_minor_version >= 3) {
+#if RANDR_LIBRARY_IS_AT_LEAST_1_3
+    if (SERVERS_RANDR_IS_AT_LEAST_1_3 (priv)) {
         gdk_error_trap_push ();
         info->primary = XRRGetOutputPrimary (xdisplay, xroot);
 	gdk_error_trap_pop_ignored ();
@@ -695,7 +701,7 @@ gnome_rr_screen_initable_init (GInitable *initable, GCancellable *canc, GError *
         priv->randr_event_base = event_base;
 
         XRRQueryVersion (dpy, &priv->rr_major_version, &priv->rr_minor_version);
-        if (priv->rr_major_version > 1 || (priv->rr_major_version == 1 && priv->rr_minor_version < 2)) {
+        if (priv->rr_major_version < 1 || (priv->rr_major_version == 1 && priv->rr_minor_version < 2)) {
             g_set_error (error, GNOME_RR_ERROR, GNOME_RR_ERROR_NO_RANDR_EXTENSION,
                     "RANDR extension is too old (must be at least 1.2)");
             return FALSE;
@@ -1603,8 +1609,7 @@ gnome_rr_screen_set_primary_output (GnomeRRScreen *screen,
 
     priv = screen->priv;
 
-#ifdef HAVE_RANDR
-#if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
+#if RANDR_LIBRARY_IS_AT_LEAST_1_3
     RROutput id;
 
     if (output)
@@ -1612,11 +1617,9 @@ gnome_rr_screen_set_primary_output (GnomeRRScreen *screen,
     else
         id = None;
 
-    /* Runtime check for RandR 1.3 or higher */
-    if (priv->rr_major_version > 1  || (priv->rr_major_version == 1 && priv->rr_minor_version >= 3))
+    if (SERVERS_RANDR_IS_AT_LEAST_1_3 (priv))
         XRRSetOutputPrimary (priv->xdisplay, priv->xroot, id);
 #endif
-#endif /* HAVE_RANDR */
 }
 
 /* GnomeRRCrtc */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]