nuclear@9: #include nuclear@9: #include "xerr.h" nuclear@9: #include "logger.h" nuclear@9: nuclear@9: static std::stack func_stack; nuclear@9: nuclear@9: void push_xerr_handler(xerr_handler_type func) nuclear@9: { nuclear@9: func_stack.push(func); nuclear@9: XSetErrorHandler(func); nuclear@9: } nuclear@9: nuclear@9: void pop_xerr_handler() nuclear@9: { nuclear@9: if(func_stack.empty()) { nuclear@9: log_error("attempt to pop_xerr_handler with an empty stack\n"); nuclear@9: return; nuclear@9: } nuclear@9: xerr_handler_type prev = func_stack.top(); nuclear@9: func_stack.pop(); nuclear@9: XSetErrorHandler(prev); nuclear@9: } nuclear@9: nuclear@9: int xerr_debug(Display *dpy, XErrorEvent *err) nuclear@9: { nuclear@9: char errstr[512]; nuclear@9: XGetErrorText(dpy, err->error_code, errstr, sizeof errstr); nuclear@9: printf("X error caught:\n%s\n", errstr); nuclear@9: return 0; nuclear@9: } nuclear@9: nuclear@9: int xerr_ignore(Display *dpy, XErrorEvent *err) nuclear@9: { nuclear@9: return 0; nuclear@9: }