Browse Source

X11: Try to load libXrandr.so.3 if libXrandr.so.2 isn't found

All Linux distros, and FreeBSD and OpenBSD seem to have libXrandr.so.2,
but for some reason recent NetBSD versions seem to have libXrandr.so.3 now.
Rémi Verschelde 4 years ago
parent
commit
413ff7938d
1 changed files with 6 additions and 1 deletions
  1. 6 1
      platform/linuxbsd/display_server_x11.cpp

+ 6 - 1
platform/linuxbsd/display_server_x11.cpp

@@ -3575,7 +3575,12 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
 	xrandr_handle = dlopen("libXrandr.so.2", RTLD_LAZY);
 	xrandr_handle = dlopen("libXrandr.so.2", RTLD_LAZY);
 	if (!xrandr_handle) {
 	if (!xrandr_handle) {
 		err = dlerror();
 		err = dlerror();
-		fprintf(stderr, "could not load libXrandr.so.2, Error: %s\n", err);
+		// For some arcane reason, NetBSD now ships libXrandr.so.3 while the rest of the world has libXrandr.so.2...
+		// In case this happens for other X11 platforms in the future, let's give it a try too before failing.
+		xrandr_handle = dlopen("libXrandr.so.3", RTLD_LAZY);
+		if (!xrandr_handle) {
+			fprintf(stderr, "could not load libXrandr.so.2, Error: %s\n", err);
+		}
 	} else {
 	} else {
 		XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor);
 		XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor);
 		if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) {
 		if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) {