From f6eee0e999e4a982abce80a3d710f95406e8d0a3 Mon Sep 17 00:00:00 2001 From: patata Date: Sun, 18 Jan 2026 15:42:39 +0100 Subject: [PATCH] Add error message to GLEW init failure + make it not die on Wayland (but warn and recommend Xwayland) --- src/Toast.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Toast.cpp b/src/Toast.cpp index 93a67a48..b9355c04 100644 --- a/src/Toast.cpp +++ b/src/Toast.cpp @@ -186,11 +186,23 @@ Toast::Toast(int argc, const char **argv) { glfwSwapInterval(1); // enable VSync #if defined(USING_GLEW) - if (glewInit() != GLEW_OK) { + if (GLenum glewInitResult = glewInit(); glewInitResult == GLEW_ERROR_NO_GLX_DISPLAY) { + Logging::warn("[Toast::Toast] No GLX display; either running under Wayland or something is very wrong with your X11 server"); + tinyfd_messageBox( + "Running under Wayland?", + "Running toast under Wayland can lead to some stuff not working as it should. (blame glew/glfw)\n" + "Consider using Xwayland by setting environment variable XDG_SESSION_TYPE=x11", + "ok", + "warning", + 1 + ); + } else if (glewInitResult != GLEW_OK) { + std::string errorMesg ("Toast::Toast: Failed to init GLEW: "); + errorMesg.append(reinterpret_cast(glewGetErrorString(glewInitResult))); glfwDestroyWindow(mGlfwWindowHndl); glfwTerminate(); - throw std::runtime_error("Toast::Toast: Failed to init GLEW!"); + throw std::runtime_error(errorMesg); } #endif