X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=cd6ca7916bf1fd852c135badcbfc75856eed4b79;hb=6b514cb540c0ec6e6c8a8b8a07f466d1dfbb372f;hp=56b63b3e5eb7be3de4a742bf1b6662f2535fd1de;hpb=60c97b0934142917929bbdbc4af8a4d10f38618f;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 56b63b3..cd6ca79 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -256,6 +256,7 @@ volatile sig_atomic_t running = 1; volatile sig_atomic_t restart_wm = 0; int outputs = 0; /*int last_focus_event = FocusOut;*/ +int (*xerrorxlib)(Display *, XErrorEvent *); int other_wm; int ss_enabled = 0; int xrandr_support; @@ -1841,7 +1842,7 @@ bar_refresh(void) void bar_setup(struct swm_region *r) { - char *bar_font; + char *font; xcb_screen_t *screen = get_screen(r->s->idx); uint32_t wa[3]; @@ -1853,19 +1854,19 @@ bar_setup(struct swm_region *r) if ((r->bar = calloc(1, sizeof(struct swm_bar))) == NULL) err(1, "bar_setup: calloc: failed to allocate memory."); - while ((bar_font = strsep(&bar_fonts, " ,")) != NULL) { - if (*bar_font == '\0') + while ((font = strsep(&bar_fonts, " ,")) != NULL) { + if (*font == '\0') continue; - DNPRINTF(SWM_D_INIT, "bar_setup: try font %s\n", bar_font); + DNPRINTF(SWM_D_INIT, "bar_setup: try font %s\n", font); bar_font = XftFontOpenName(display, DefaultScreen(display), - bar_font); + font); if (!bar_font) { - warnx("unable to load font %s", bar_font); + warnx("unable to load font %s", font); continue; } else { DNPRINTF(SWM_D_INIT, "successfully opened font %s\n", - bar_font); + font); break; } } @@ -7621,6 +7622,17 @@ event_handle(xcb_generic_event_t *evt) screenchange((void *)evt); } +xerror(Display *d, XErrorEvent *ee) +{ +#ifdef SWM_DEBUG + char error_text[1024]; + XGetErrorText(display, ee->error_code, error_text, sizeof(error_text)); + DNPRINTF(SWM_D_MISC, "xerror: error_code: %u, error_text: %s\n", + ee->error_code, error_text); +#endif + return -1; +} + int main(int argc, char *argv[]) { @@ -7659,6 +7671,9 @@ main(int argc, char *argv[]) if (!(display = XOpenDisplay(0))) errx(1, "can not open display"); + /* prevent xlib from exiting on an error */ + xerrorxlib = XSetErrorHandler(xerror); + conn = XGetXCBConnection(display); if (xcb_connection_has_error(conn)) errx(1, "can not get XCB connection");