diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index c181dcf8fa..f2aedb4b57 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -165,6 +165,13 @@ static Bool glx_wait_notify(Display *d, XEvent *e, char *arg) return e->type == MapNotify && e->xmap.window == g_win; } +static int nul_handler(Display *dpy, XErrorEvent *event) +{ + (void)dpy; + (void)event; + return 0; +} + static void gfx_ctx_get_video_size(unsigned *width, unsigned *height); static void gfx_ctx_destroy(void); @@ -440,8 +447,6 @@ static bool gfx_ctx_set_video_mode( XEvent event; XIfEvent(g_dpy, &event, glx_wait_notify, NULL); - XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); - g_ctx = glXCreateNewContext(g_dpy, g_fbc, GLX_RGBA_TYPE, 0, True); if (!g_ctx) { @@ -475,6 +480,11 @@ static bool gfx_ctx_set_video_mode( gfx_ctx_swap_interval(g_interval); + // This can blow up on some drivers. It's not fatal, so override errors for this call. + int (*old_handler)(Display*, XErrorEvent*) = XSetErrorHandler(nul_handler); + XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); + XSetErrorHandler(old_handler); + XFree(vi); g_has_focus = true; g_inited = true; diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index e4bd6f76d1..8f4653cfa0 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -64,6 +64,13 @@ static Bool egl_wait_notify(Display *d, XEvent *e, char *arg) return e->type == MapNotify && e->xmap.window == g_win; } +static int nul_handler(Display *dpy, XErrorEvent *event) +{ + (void)dpy; + (void)event; + return 0; +} + static void gfx_ctx_get_video_size(unsigned *width, unsigned *height); static void gfx_ctx_destroy(void); @@ -393,7 +400,6 @@ static bool gfx_ctx_set_video_mode( XEvent event; XIfEvent(g_dpy, &event, egl_wait_notify, NULL); - XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False); if (g_quit_atom) @@ -401,6 +407,11 @@ static bool gfx_ctx_set_video_mode( gfx_ctx_swap_interval(g_interval); + // This can blow up on some drivers. It's not fatal, so override errors for this call. + int (*old_handler)(Display*, XErrorEvent*) = XSetErrorHandler(nul_handler); + XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); + XSetErrorHandler(old_handler); + XFree(vi); g_has_focus = true; g_inited = true;