From 79116b0431e3be95f5abcac0c456361e486824d8 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 27 Aug 2021 21:13:30 +0000 Subject: X11: Check for XRandR extension before usage It happens in practice that XRandR is enabled in the build but is not available at runtime, particularly with X11 forwarding over SSH. This properly queries the extension first to avoid crashing in such situations. --- src/x11.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/x11.c b/src/x11.c index 57dbea5..455ee20 100644 --- a/src/x11.c +++ b/src/x11.c @@ -366,12 +366,15 @@ puglRealize(PuglView* const view) } #ifdef HAVE_XRANDR - // Set refresh rate hint to the real refresh rate - XRRScreenConfiguration* conf = XRRGetScreenInfo(display, parent); - short current_rate = XRRConfigCurrentRate(conf); - - view->hints[PUGL_REFRESH_RATE] = current_rate; - XRRFreeScreenConfigInfo(conf); + int ignored = 0; + if (XRRQueryExtension(display, &ignored, &ignored)) { + // Set refresh rate hint to the real refresh rate + XRRScreenConfiguration* conf = XRRGetScreenInfo(display, parent); + short current_rate = XRRConfigCurrentRate(conf); + + view->hints[PUGL_REFRESH_RATE] = current_rate; + XRRFreeScreenConfigInfo(conf); + } #endif updateSizeHints(view); -- cgit v1.2.1