diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/x11_util.cc | 18 | ||||
-rw-r--r-- | app/x11_util.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/app/x11_util.cc b/app/x11_util.cc index 78e09fc..934e824 100644 --- a/app/x11_util.cc +++ b/app/x11_util.cc @@ -52,8 +52,26 @@ CachedPictFormats* get_cached_pict_formats() { // Maximum number of CachedPictFormats we keep around. const size_t kMaxCacheSize = 5; +int X11ErrorHandler(Display* d, XErrorEvent* e) { + LOG(FATAL) << "X Error detected: serial " << e->serial + << " error_code " << static_cast<unsigned int>(e->error_code) + << " request_code " << static_cast<unsigned int>(e->request_code) + << " minor_code " << static_cast<unsigned int>(e->minor_code); + return 0; +} + +int X11IOErrorHandler(Display* d) { + LOG(FATAL) << "X IO Error detected"; + return 0; +} + } // namespace +void SetX11ErrorHandlers() { + XSetErrorHandler(X11ErrorHandler); + XSetIOErrorHandler(X11IOErrorHandler); +} + bool XDisplayExists() { return (gdk_display_get_default() != NULL); } diff --git a/app/x11_util.h b/app/x11_util.h index 5c202f3..b85061c 100644 --- a/app/x11_util.h +++ b/app/x11_util.h @@ -170,6 +170,9 @@ void GrabWindowSnapshot(GtkWindow* gdk_window, // Change desktop for |window| to the desktop of |destination| window. bool ChangeWindowDesktop(XID window, XID destination); +// Sets the X Error Handlers so we can catch X errors and crash. +void SetX11ErrorHandlers(); + } // namespace x11_util #endif // APP_X11_UTIL_H_ |