X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=pager.c;h=a8f0e8d01d7e546caad8d0502453a059bbe2d916;hb=7cec174ea28986ff9f0de1b9a5e7ec19378bba0f;hp=cab6b42a78ff088ac9541475c012fac4d301c9db;hpb=4368b9c4544687792b23d4083fdc0a2fa261a905;p=pager.git diff --git a/pager.c b/pager.c index cab6b42..a8f0e8d 100644 --- a/pager.c +++ b/pager.c @@ -15,6 +15,26 @@ static Atom num_desktops_atom, current_desktop_atom, client_list_atom, client_de static Atom shaded_state, skip_pager_state, hidden_state; static long desktop = -1; +int error_handler(Display *display, XErrorEvent *event) { + char buffer[512]; + int length; + + switch (event->error_code) { + case BadWindow: + /* The window may have gone away since we queried the window manager. */ + break; + + default: + if (XGetErrorText(display, event->error_code, buffer, sizeof(buffer))) { + fprintf(stderr, "%s\n", buffer); + exit(100); + } + break; + } + + return 0; +} + void setup_atom(Atom *atom, const char *prop) { *atom = XInternAtom(DADisplay, prop, True); if (*atom == None) exit(111); @@ -231,6 +251,7 @@ int main(int argc, char **argv) { exit(111); } + XSetErrorHandler(error_handler); setup_GCs(); DAShow(); DAEventLoop();