Force disable xrandr if it is unavailable

lwjgl2 optionally requires the xrandr command line utility on linux, but
does not check if the executable actually exists before trying to use
it. We can force it to fall back to the xf86videomode implementation
by checking for the executable ourselves, and force disabling xrandr
with this boolean [1] if it does not exist.

Link: 2df01dd762/src/java/org/lwjgl/opengl/LinuxDisplay.java (L214) [1]
Signed-off-by: Blake Batson <bbatson101@gmail.com>
This commit is contained in:
Blake Batson
2025-12-24 22:43:31 -05:00
parent 76d1cd1b4e
commit e0c2fbbcde

View File

@@ -91,6 +91,7 @@
#include <QActionGroup>
#include <QMainWindow>
#include <QScreen>
#include <QStandardPaths>
#include <QWindow>
#ifdef Q_OS_LINUX
@@ -588,6 +589,16 @@ QStringList MinecraftInstance::javaArguments()
"minecraft.exe.heapdump");
#endif
// LWJGL2 reads `LWJGL_DISABLE_XRANDR` to force disable xrandr usage and fall back to xf86videomode.
// It *SHOULD* check for the executable to exist before trying to use it for queries but it doesnt,
// so WE can and force disable xrandr if it is not available.
#ifdef Q_OS_LINUX
// LWJGL2 is "org.lwjgl" LWJGL3 is "org.lwjgl3"
if (m_components->getComponent("org.lwjgl") != nullptr && QStandardPaths::findExecutable("xrandr").isEmpty()) {
args << QString("-DLWJGL_DISABLE_XRANDR=true");
}
#endif
int min = settings()->get("MinMemAlloc").toInt();
int max = settings()->get("MaxMemAlloc").toInt();
if (min < max) {