From ffa693286118db1eee607753a3f14a6ee991b044 Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Sun, 8 May 2022 14:27:42 +0200 Subject: [PATCH] Check for XSetIOErrorExitHandler so old Xlib versions can work just fine Signed-off-by: Alexis Maiquez --- CMakeLists.txt | 8 +++++++- src/WallpaperEngine/Render/CContext.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ecee81..fcb1117 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ find_package(LZ4 REQUIRED) find_package(FFMPEG REQUIRED) find_package(FreeImage REQUIRED) + include_directories( ${X11_INCLUDE_DIR} ${XRANDR_INCLUDE_DIR} @@ -204,4 +205,9 @@ target_link_libraries(wallengine ${SDL_MIXER_LIBRARIES} ${FFMPEG_LIBRARIES} ${FREEIMAGE_LIBRARIES} - glfw) \ No newline at end of file + glfw) + +set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES}) + +# make sure some of the X11 functions we'll use are available +check_function_exists(XSetIOErrorExitHandler "Xlib.h" HAVE_XSETIOERROREXITHANDLER) diff --git a/src/WallpaperEngine/Render/CContext.cpp b/src/WallpaperEngine/Render/CContext.cpp index b2750bb..3fc06f1 100644 --- a/src/WallpaperEngine/Render/CContext.cpp +++ b/src/WallpaperEngine/Render/CContext.cpp @@ -62,7 +62,9 @@ void CContext::initializeViewports () this->m_display = XOpenDisplay (nullptr); // set the error handling to try and recover from X disconnections +#ifdef HAVE_XSETIOERROREXITHANDLER XSetIOErrorExitHandler (this->m_display, CustomXIOErrorExitHandler, this); +#endif /* HAVE_XSETIOERROREXITHANDLER */ XSetErrorHandler (CustomXErrorHandler); XSetIOErrorHandler (CustomXIOErrorHandler);