Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches
InteractiveEditorX11Guard.hpp
Go to the documentation of this file.
1#ifndef INTERACTIVEEDITORX11GUARD_H
2#define INTERACTIVEEDITORX11GUARD_H
3
4#include <Rtypes.h>
5#include <dlfcn.h>
6
28
31typedef int (*AUXErrorHandler)(void *display, void *event);
32
35
38inline int AUIgnoreXError(void *, void *) { return 0; }
39
51
72 s.set_fn = (AUXSetErrorHandlerFn)dlsym(RTLD_DEFAULT, "XSetErrorHandler");
73 if (!s.set_fn) {
74 // libX11 may have been brought in with local scope; promote and retry.
75 void *h = dlopen("libX11.so.6", RTLD_NOW | RTLD_GLOBAL | RTLD_NOLOAD);
76 if (h) {
77 s.set_fn = (AUXSetErrorHandlerFn)dlsym(h, "XSetErrorHandler");
78 }
79 }
81 return s;
82}
83
91 if (s.set_fn) {
92 s.set_fn(s.prev);
93 }
94}
95
96#endif
AUXErrorHandler(* AUXSetErrorHandlerFn)(AUXErrorHandler)
Signature of XSetErrorHandler itself, resolved via dlsym.
AUXErrorHandlerSave AUInstallTolerantXErrorHandler()
Install the tolerant X error handler for the duration of an event loop.
int AUIgnoreXError(void *, void *)
The tolerant handler: ignores the error and reports success.
int(* AUXErrorHandler)(void *display, void *event)
Xlib error handler signature, with opaque pointers so that no libX11 headers are needed here.
void AURestoreXErrorHandler(AUXErrorHandlerSave s)
Put back the handler that was in place before the tolerant one.
What AUInstallTolerantXErrorHandler() needs in order to undo itself.
AUXErrorHandler prev
Handler that was installed before, to be put back on restore.
AUXSetErrorHandlerFn set_fn
Resolved XSetErrorHandler, or null if it could not be found.