diff --git a/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp b/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp index 06f9176..af87ed1 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp +++ b/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp @@ -40,6 +40,11 @@ WindowCtrlUnix::WindowCtrlUnix( QObject *parent ) : QObject( parent ) m_tb_window_states = QMap< quint64, Preferences::WindowState >(); m_tb_window_hints = QMap< quint64, SizeHints >(); + /* + * Set the X11 error handler + */ + SetErrorHandler(); + /* * Get the base display and window */ diff --git a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp index a924cb6..a972c0b 100644 --- a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp +++ b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp @@ -3,6 +3,7 @@ /* * System includes */ +#include #include #include @@ -457,3 +458,27 @@ void MoveWindow( void* display, quint64 window, int x, int y ) { XMoveWindow( (Display*)display, window, x, y ); } + + +/* + * The error handler + */ +int ErrorHandler( Display* display, XErrorEvent* event ) +{ + fprintf( stderr, "Error code: %x", event->error_code ); + + char buf[ 1024 ]; + XGetErrorText( display, event->error_code, buf, 1024 ); + fprintf( stderr, "%s\n", buf ); + + return 0; +} + + +/* + * Set the error handler + */ +void SetErrorHandler() +{ + XSetErrorHandler( ErrorHandler ); +} diff --git a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h index a989676..5e7456c 100644 --- a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h +++ b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h @@ -261,4 +261,9 @@ void GetWindowPosition( void *display, quint64 window, long* pos_x, long* pos */ void MoveWindow( void* display, quint64 window, int x, int y ); +/** + * @brief SetErrorHandler. Set the x11 error handler. + */ +void SetErrorHandler(); + #endif // SYSTRAY_X_LIB_H