diff framework/MainWindowBase.cpp @ 255:3240925e00ef

Move X11 stuff here, from svcore
author Chris Cannam
date Wed, 18 Jan 2012 18:13:25 +0000
parents c469f8d8208e
children f3f9e3d647c1
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Fri Jan 13 17:43:12 2012 +0000
+++ b/framework/MainWindowBase.cpp	Wed Jan 18 18:13:25 2012 +0000
@@ -108,6 +108,27 @@
 using std::map;
 using std::set;
 
+#ifdef Q_WS_X11
+#define Window X11Window
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/SM/SMlib.h>
+
+static int handle_x11_error(Display *dpy, XErrorEvent *err)
+{
+    char errstr[256];
+    XGetErrorText(dpy, err->error_code, errstr, 256);
+    if (err->error_code != BadWindow) {
+	std::cerr << "Sonic Visualiser: X Error: "
+		  << errstr << " " << int(err->error_code)
+		  << "\nin major opcode:  "
+		  << int(err->request_code) << std::endl;
+    }
+    return 0;
+}
+#undef Window
+#endif
 
 MainWindowBase::MainWindowBase(bool withAudioOutput,
                                bool withOSCSupport,
@@ -132,6 +153,10 @@
 {
     Profiler profiler("MainWindowBase::MainWindowBase");
 
+#ifdef Q_WS_X11
+    XSetErrorHandler(handle_x11_error);
+#endif
+
     connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()),
 	    this, SLOT(documentModified()));
     connect(CommandHistory::getInstance(), SIGNAL(documentRestored()),