aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn2016-03-08 22:17:16 -0500
committerKen Raeburn2016-03-10 14:28:54 -0500
commit8b8a6ad3e3239eb2cff325e72e29dc30fdaa58c5 (patch)
treefab743803408a7c0fcf1f1416a187f863505b2d1
parent985dacfa0f0186531fdae13718d720cf7e27425f (diff)
downloademacs-8b8a6ad3e3239eb2cff325e72e29dc30fdaa58c5.tar.gz
emacs-8b8a6ad3e3239eb2cff325e72e29dc30fdaa58c5.zip
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.
-rw-r--r--configure.ac8
-rw-r--r--src/xfns.c28
-rw-r--r--src/xterm.h5
3 files changed, 26 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac
index 370cb54fe2c..075f6119ead 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3594,14 +3594,6 @@ if test "${HAVE_X11}" = "yes"; then
3594 fi 3594 fi
3595 fi 3595 fi
3596 if test $HAVE_XRANDR = yes; then 3596 if test $HAVE_XRANDR = yes; then
3597 SAVE_CFLAGS="$CFLAGS"
3598 SAVE_LIBS="$LIBS"
3599 CFLAGS="$XRANDR_CFLAGS $CFLAGS"
3600 LIBS="$XRANDR_LIBS $LIBS"
3601 AC_CHECK_FUNCS(XRRGetOutputPrimary XRRGetScreenResourcesCurrent)
3602 CFLAGS="$SAVE_CFLAGS"
3603 LIBS="$SAVE_LIBS"
3604
3605 AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.]) 3597 AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
3606 fi 3598 fi
3607fi 3599fi
diff --git a/src/xfns.c b/src/xfns.c
index 9ef7cb980fe..0a4a09ef285 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4262,8 +4262,19 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo)
4262 RROutput pxid = None; 4262 RROutput pxid = None;
4263 struct MonitorInfo *monitors; 4263 struct MonitorInfo *monitors;
4264 4264
4265#ifdef HAVE_XRRGETSCREENRESOURCESCURRENT 4265#define RANDR13_LIBRARY \
4266 resources = XRRGetScreenResourcesCurrent (dpy, dpyinfo->root_window); 4266 (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
4267
4268#if RANDR13_LIBRARY
4269 /* Check if the display supports 1.3 too. */
4270 bool randr13_avail = (dpyinfo->xrandr_major_version > 1
4271 || (dpyinfo->xrandr_major_version == 1
4272 && dpyinfo->xrandr_minor_version >= 3));
4273
4274 if (randr13_avail)
4275 resources = XRRGetScreenResourcesCurrent (dpy, dpyinfo->root_window);
4276 else
4277 resources = XRRGetScreenResources (dpy, dpyinfo->root_window);
4267#else 4278#else
4268 resources = XRRGetScreenResources (dpy, dpyinfo->root_window); 4279 resources = XRRGetScreenResources (dpy, dpyinfo->root_window);
4269#endif 4280#endif
@@ -4276,8 +4287,9 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo)
4276 n_monitors = resources->noutput; 4287 n_monitors = resources->noutput;
4277 monitors = xzalloc (n_monitors * sizeof *monitors); 4288 monitors = xzalloc (n_monitors * sizeof *monitors);
4278 4289
4279#ifdef HAVE_XRRGETOUTPUTPRIMARY 4290#ifdef RANDR13_LIBRARY
4280 pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window); 4291 if (randr13_avail)
4292 pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window);
4281#endif 4293#endif
4282 4294
4283 for (i = 0; i < n_monitors; ++i) 4295 for (i = 0; i < n_monitors; ++i)
@@ -4360,9 +4372,11 @@ x_get_monitor_attributes (struct x_display_info *dpyinfo)
4360 xrr_ok = XRRQueryExtension (dpy, &xrr_event_base, &xrr_error_base); 4372 xrr_ok = XRRQueryExtension (dpy, &xrr_event_base, &xrr_error_base);
4361 if (xrr_ok) 4373 if (xrr_ok)
4362 { 4374 {
4363 int xrr_major, xrr_minor; 4375 XRRQueryVersion (dpy, &dpyinfo->xrandr_major_version,
4364 XRRQueryVersion (dpy, &xrr_major, &xrr_minor); 4376 &dpyinfo->xrandr_minor_version);
4365 xrr_ok = (xrr_major == 1 && xrr_minor >= 2) || xrr_major > 1; 4377 xrr_ok = ((dpyinfo->xrandr_major_version == 1
4378 && dpyinfo->xrandr_minor_version >= 2)
4379 || dpyinfo->xrandr_major_version > 1);
4366 } 4380 }
4367 4381
4368 if (xrr_ok) 4382 if (xrr_ok)
diff --git a/src/xterm.h b/src/xterm.h
index 06cd2e75a8b..8e1fc788bc1 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -459,6 +459,11 @@ struct x_display_info
459 /* SM */ 459 /* SM */
460 Atom Xatom_SM_CLIENT_ID; 460 Atom Xatom_SM_CLIENT_ID;
461 461
462#ifdef HAVE_XRANDR
463 int xrandr_major_version;
464 int xrandr_minor_version;
465#endif
466
462#ifdef USE_CAIRO 467#ifdef USE_CAIRO
463 XExtCodes *ext_codes; 468 XExtCodes *ext_codes;
464#endif 469#endif