xglcomp
view src/xerr.cc @ 9:245dd960f0b3
added xerror handling helpers
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 02 Feb 2016 12:54:02 +0200 |
parents | |
children | be18500d76d1 |
line source
1 #include <stack>
2 #include "xerr.h"
3 #include "logger.h"
5 static std::stack<xerr_handler_type> func_stack;
7 void push_xerr_handler(xerr_handler_type func)
8 {
9 func_stack.push(func);
10 XSetErrorHandler(func);
11 }
13 void pop_xerr_handler()
14 {
15 if(func_stack.empty()) {
16 log_error("attempt to pop_xerr_handler with an empty stack\n");
17 return;
18 }
19 xerr_handler_type prev = func_stack.top();
20 func_stack.pop();
21 XSetErrorHandler(prev);
22 }
24 int xerr_debug(Display *dpy, XErrorEvent *err)
25 {
26 char errstr[512];
27 XGetErrorText(dpy, err->error_code, errstr, sizeof errstr);
28 printf("X error caught:\n%s\n", errstr);
29 return 0;
30 }
32 int xerr_ignore(Display *dpy, XErrorEvent *err)
33 {
34 return 0;
35 }