Setup x11 error handler

This commit is contained in:
Ximi1970
2021-01-16 13:28:06 +01:00
parent 49b81c3517
commit 573159a495
3 changed files with 35 additions and 0 deletions

View File

@@ -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
*/

View File

@@ -3,6 +3,7 @@
/*
* System includes
*/
#include <stdio.h>
#include <limits.h>
#include <string.h>
@@ -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 );
}

View File

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