From 7a14e3dac45683093ec3f7caab1b4aa944fb3f99 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 17 May 2024 20:22:55 +0200 Subject: [PATCH] fix: Wayland error discarding build errors with older GLFW versions --- main/gui/source/init/splash_window.cpp | 11 ++++++++--- main/gui/source/window/window.cpp | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 0f5697d28..001e1ee0d 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -398,11 +398,16 @@ namespace hex::init { void WindowSplash::initGLFW() { glfwSetErrorCallback([](int errorCode, const char *desc) { - if (errorCode == GLFW_PLATFORM_ERROR || errorCode == GLFW_FEATURE_UNAVAILABLE) { + bool isWaylandError = errorCode == GLFW_PLATFORM_ERROR; + #if defined(GLFW_FEATURE_UNAVAILABLE) + isWaylandError = isWaylandError || (errorCode == GLFW_FEATURE_UNAVAILABLE); + #endif + isWaylandError = isWaylandError && std::string_view(desc).contains("Wayland"); + + if (isWaylandError) { // Ignore error spam caused by Wayland not supporting moving or resizing // windows or querying their position and size. - if (std::string_view(desc).contains("Wayland")) - return; + return; } lastGlfwError.errorCode = errorCode; diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 2ec67f9fe..66b721779 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -698,11 +698,16 @@ namespace hex { void Window::initGLFW() { auto initialWindowProperties = ImHexApi::System::getInitialWindowProperties(); glfwSetErrorCallback([](int error, const char *desc) { - if (error == GLFW_PLATFORM_ERROR || error == GLFW_FEATURE_UNAVAILABLE) { + bool isWaylandError = error == GLFW_PLATFORM_ERROR; + #if defined(GLFW_FEATURE_UNAVAILABLE) + isWaylandError = isWaylandError || (error == GLFW_FEATURE_UNAVAILABLE); + #endif + isWaylandError = isWaylandError && std::string_view(desc).contains("Wayland"); + + if (isWaylandError) { // Ignore error spam caused by Wayland not supporting moving or resizing // windows or querying their position and size. - if (std::string_view(desc).contains("Wayland")) - return; + return; } try {