Browse Source

Check for XSetIOErrorExitHandler so old Xlib versions can work just fine

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez 4 years ago
parent
commit
28f0868caa
2 changed files with 13 additions and 1 deletions
  1. 11 1
      CMakeLists.txt
  2. 2 0
      src/WallpaperEngine/Render/CContext.cpp

+ 11 - 1
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,13 @@ target_link_libraries(wallengine
     ${SDL_MIXER_LIBRARIES}
     ${FFMPEG_LIBRARIES}
     ${FREEIMAGE_LIBRARIES}
-    glfw)
+    glfw)
+
+set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES})
+
+# make sure some of the X11 functions we'll use are available
+check_function_exists(XSetIOErrorExitHandler HAVE_XSETIOERROREXITHANDLER)
+
+if(HAVE_XSETIOERROREXITHANDLER)
+    add_compile_definitions(HAVE_XSETIOERROREXITHANDLER=1)
+endif()

+ 2 - 0
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);