summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-06 21:20:23 +0100
committerwm4 <wm4@nowhere>2015-11-06 21:20:23 +0100
commitb984ec52aaf569a9be4acfe6fdd056f309a3b40e (patch)
tree46bf89c2b9e697b4f68f3b34eda4b053e15ad068 /video/out/x11_common.c
parent9693e0f57ac75bd5c5d8313dd933989dd3e64d31 (diff)
downloadmpv-b984ec52aaf569a9be4acfe6fdd056f309a3b40e.tar.bz2
mpv-b984ec52aaf569a9be4acfe6fdd056f309a3b40e.tar.xz
vo_opengl: x11: silence error messages when using legacy GL context
glXCreateContextAttribsARB() by design can throw some X11 errors. We ignore these, but we generally still print error messages to the terminal. This was confusing/annoying users, so silence it. The stupid part is that the Xlib error handler is global, so we have to be slightly careful here.
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r--video/out/x11_common.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 0aa49a4257..62d66fd730 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -37,6 +37,7 @@
#include "vo.h"
#include "win_state.h"
+#include "osdep/atomics.h"
#include "osdep/timer.h"
#include "osdep/subprocess.h"
@@ -125,6 +126,7 @@ static const char x11_icon[] =
;
static struct mp_log *x11_error_output;
+static atomic_int x11_error_silence;
static void vo_x11_update_geometry(struct vo *vo);
static void vo_x11_fullscreen(struct vo *vo);
@@ -262,8 +264,11 @@ static void vo_set_cursor_hidden(struct vo *vo, bool cursor_hidden)
static int x11_errorhandler(Display *display, XErrorEvent *event)
{
struct mp_log *log = x11_error_output;
- char msg[60];
+ if (atomic_load(&x11_error_silence))
+ return 0;
+
+ char msg[60];
XGetErrorText(display, event->error_code, (char *) &msg, sizeof(msg));
mp_err(log, "X11 error: %s\n", msg);
@@ -276,6 +281,11 @@ static int x11_errorhandler(Display *display, XErrorEvent *event)
return 0;
}
+void vo_x11_silence_xlib(int dir)
+{
+ atomic_fetch_add(&x11_error_silence, dir);
+}
+
static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
{
#define NET_WM_STATE_TEST(x) { \