Check for XSetIOErrorExitHandler so old Xlib versions can work just fine

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2022-05-08 14:27:42 +02:00
parent 6808f31cd6
commit 28f0868caa
2 changed files with 13 additions and 1 deletions

View File

@ -19,6 +19,7 @@ find_package(LZ4 REQUIRED)
find_package(FFMPEG REQUIRED)
find_package(FreeImage REQUIRED)
include_directories(
${X11_INCLUDE_DIR}
${XRANDR_INCLUDE_DIR}
@ -205,3 +206,12 @@ target_link_libraries(wallengine
${FFMPEG_LIBRARIES}
${FREEIMAGE_LIBRARIES}
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()

View File

@ -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);