[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/raeburn/xrandr 5d02414: Don't use XRANDR 1.3 exten
From: |
Ken Raeburn |
Subject: |
[Emacs-diffs] scratch/raeburn/xrandr 5d02414: Don't use XRANDR 1.3 extensions if the server doesn't support them. |
Date: |
Wed, 09 Mar 2016 03:39:05 +0000 |
branch: scratch/raeburn/xrandr
commit 5d0241498d8347f96a16f0694bf87815dec63f50
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>
Don't use XRANDR 1.3 extensions if the server doesn't support them.
* src/xterm.h (struct x_display_info): Add fields to save XRANDR
version number.
* src/xfns.c (x_get_monitor_attributes): Save the version numbers
after querying the X server.
(x_get_monitor_attributes_xrandr): Don't use XRRGetOutputPrimary or
XRRGetScreenResourcesCurrent if the server doesn't support at least
RANDR version 1.3. Conditionalize the code blocks on compiling
against library version 1.3 or better, rather than feature tests for
each function.
* configure.ac: Stop testing for those two functions.
---
configure.ac | 8 --------
src/xfns.c | 28 +++++++++++++++++++++-------
src/xterm.h | 5 +++++
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/configure.ac b/configure.ac
index d42b42e..afb0a7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3594,14 +3594,6 @@ if test "${HAVE_X11}" = "yes"; then
fi
fi
if test $HAVE_XRANDR = yes; then
- SAVE_CFLAGS="$CFLAGS"
- SAVE_LIBS="$LIBS"
- CFLAGS="$XRANDR_CFLAGS $CFLAGS"
- LIBS="$XRANDR_LIBS $LIBS"
- AC_CHECK_FUNCS(XRRGetOutputPrimary XRRGetScreenResourcesCurrent)
- CFLAGS="$SAVE_CFLAGS"
- LIBS="$SAVE_LIBS"
-
AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
fi
fi
diff --git a/src/xfns.c b/src/xfns.c
index 20ac627..07bd3e9 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4262,8 +4262,19 @@ x_get_monitor_attributes_xrandr (struct x_display_info
*dpyinfo)
RROutput pxid = None;
struct MonitorInfo *monitors;
-#ifdef HAVE_XRRGETSCREENRESOURCESCURRENT
- resources = XRRGetScreenResourcesCurrent (dpy, dpyinfo->root_window);
+#define RANDR13_LIBRARY \
+ (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
+
+#if RANDR13_LIBRARY
+ /* Check if the display supports 1.3 too. */
+ bool randr13_avail = (dpyinfo->xrandr_major_version > 1
+ || (dpyinfo->xrandr_major_version == 1
+ && dpyinfo->xrandr_minor_version >= 3));
+
+ if (randr13_avail)
+ resources = XRRGetScreenResourcesCurrent (dpy, dpyinfo->root_window);
+ else
+ resources = XRRGetScreenResources (dpy, dpyinfo->root_window);
#else
resources = XRRGetScreenResources (dpy, dpyinfo->root_window);
#endif
@@ -4276,8 +4287,9 @@ x_get_monitor_attributes_xrandr (struct x_display_info
*dpyinfo)
n_monitors = resources->noutput;
monitors = xzalloc (n_monitors * sizeof *monitors);
-#ifdef HAVE_XRRGETOUTPUTPRIMARY
- pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window);
+#ifdef RANDR13_LIBRARY
+ if (randr13_avail)
+ pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window);
#endif
for (i = 0; i < n_monitors; ++i)
@@ -4360,9 +4372,11 @@ x_get_monitor_attributes (struct x_display_info *dpyinfo)
xrr_ok = XRRQueryExtension (dpy, &xrr_event_base, &xrr_error_base);
if (xrr_ok)
{
- int xrr_major, xrr_minor;
- XRRQueryVersion (dpy, &xrr_major, &xrr_minor);
- xrr_ok = (xrr_major == 1 && xrr_minor >= 2) || xrr_major > 1;
+ XRRQueryVersion (dpy, &dpyinfo->xrandr_major_version,
+ &dpyinfo->xrandr_minor_version);
+ xrr_ok = ((dpyinfo->xrandr_major_version == 1
+ && dpyinfo->xrandr_minor_version >= 2)
+ || dpyinfo->xrandr_major_version > 1);
}
if (xrr_ok)
diff --git a/src/xterm.h b/src/xterm.h
index 3a78292..3211b59 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -459,6 +459,11 @@ struct x_display_info
/* SM */
Atom Xatom_SM_CLIENT_ID;
+#ifdef HAVE_XRANDR
+ int xrandr_major_version;
+ int xrandr_minor_version;
+#endif
+
#ifdef USE_CAIRO
XExtCodes *ext_codes;
#endif