summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-11-08 01:11:20 +0100
committerinfirit <[email protected]>2014-11-28 08:51:50 +0100
commitb653937eee2ca1613f8226ae5f5a5a284232e8a0 (patch)
tree7d685e61eeff9dc537cb6bc3ddcccc2c48c4fad7
parent1e96f8af8cdaae801102dad3b5c425248e8977f8 (diff)
downloadmate-desktop-b653937eee2ca1613f8226ae5f5a5a284232e8a0.tar.bz2
mate-desktop-b653937eee2ca1613f8226ae5f5a5a284232e8a0.tar.xz
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. Based on gnome-desktop commit: 4da0756ef2e42b8040d8043029057b08e85efcec From: Federico Mena Quintero <[email protected]>
-rw-r--r--libmate-desktop/mate-rr.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libmate-desktop/mate-rr.c b/libmate-desktop/mate-rr.c
index e49707b..48d801d 100644
--- a/libmate-desktop/mate-rr.c
+++ b/libmate-desktop/mate-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,
@@ -454,9 +462,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);
@@ -514,9 +521,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);
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -702,7 +708,7 @@ mate_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, MATE_RR_ERROR, MATE_RR_ERROR_NO_RANDR_EXTENSION,
"RANDR extension is too old (must be at least 1.2)");
return FALSE;
@@ -1614,8 +1620,7 @@ mate_rr_screen_set_primary_output (MateRRScreen *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)
@@ -1623,11 +1628,9 @@ mate_rr_screen_set_primary_output (MateRRScreen *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 */
}
/* MateRRCrtc */