diff --git a/main.cpp b/main.cpp index c32512ca9b..a485b5fef5 100644 --- a/main.cpp +++ b/main.cpp @@ -57,6 +57,10 @@ Atoms* atoms; int screen_number = -1; static bool initting = false; +// Whether to run Xlib in synchronous mode and print backtraces for X errors. +// Note that you most probably need to configure cmake with "-D__KDE_HAVE_GCC_VISIBILITY=0" +// and -rdynamic in CXXFLAGS for kBacktrace() to work. +static bool kwin_sync = false; static int x11ErrorHandler(Display *d, XErrorEvent *e) @@ -84,6 +88,9 @@ int x11ErrorHandler(Display *d, XErrorEvent *e) fprintf(stderr, "kwin: %s(0x%lx): %s\n", req, e->resourceid, msg); + if( kwin_sync ) + kDebug() << kBacktrace(); + if (initting) { fputs(i18n("kwin: failure during initialization; aborting").toLocal8Bit(), stderr); @@ -140,6 +147,12 @@ int Application::crashes = 0; Application::Application( ) : KApplication( ), owner( screen_number ) { + if( KCmdLineArgs::parsedArgs( "qt" )->isSet( "sync" )) + { + kwin_sync = true; + XSynchronize( display(), True ); + kDebug() << "Running KWin in sync mode"; + } KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); KSharedConfig::Ptr config = KGlobal::config(); if (!config->isImmutable() && args->isSet("lock"))