File kde-auto-comp.diff of Package compiz

Index: compiz-0.8.6/kde/window-decorator-kde4/decorator.cpp
===================================================================
--- compiz-0.8.6.orig/kde/window-decorator-kde4/decorator.cpp
+++ compiz-0.8.6/kde/window-decorator-kde4/decorator.cpp
@@ -83,6 +83,15 @@ KWD::PluginManager::PluginManager (KShar
             "kwin3_oxygen" : "kwin3_plastik";
 }
 
+static int redirectError;
+
+static int
+redirectErrorHandler (Display     *dpy,
+                      XErrorEvent *e)
+{
+    redirectError++;
+    return 0;
+}
 
 KWD::Decorator::Decorator () :
     KApplication (),
@@ -164,8 +173,16 @@ KWD::Decorator::Decorator () :
     XChangeProperty (QX11Info::display(), mCompositeWindow, Atoms::enlightmentDesktop,
 		      XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1);
 
+    redirectError = 0;
+    int (*oldErrorHandler) (Display *, XErrorEvent *) =
+        XSetErrorHandler (redirectErrorHandler);
     XCompositeRedirectSubwindows (QX11Info::display(), mCompositeWindow,
-				  CompositeRedirectManual);
+                                  CompositeRedirectManual);
+    syncX ();
+    XSetErrorHandler (oldErrorHandler);
+    if (redirectError)
+        XCompositeRedirectSubwindows (QX11Info::display(), mCompositeWindow,
+                                      CompositeRedirectAutomatic);
 
     XMapWindow (QX11Info::display(), mCompositeWindow);
 }
Index: compiz-0.8.6/kde/window-decorator/decorator.cpp
===================================================================
--- compiz-0.8.6.orig/kde/window-decorator/decorator.cpp
+++ compiz-0.8.6/kde/window-decorator/decorator.cpp
@@ -188,6 +188,16 @@ dbusHandleMessage (DBusConnection *conne
     return result;
 }
 
+static int redirectError;
+
+static int
+redirectErrorHandler (Display     *dpy,
+                      XErrorEvent *e)
+{
+    redirectError++;
+    return 0;
+}
+
 KWD::Decorator::Decorator (void) : DCOPObject ("KWinInterface"),
     KApplication (),
     mConfig (0),
@@ -242,8 +252,16 @@ KWD::Decorator::Decorator (void) : DCOPO
 				      CopyFromParent,
 				      CWOverrideRedirect, &attr);
 
+    redirectError = 0;
+    int (*oldErrorHandler) (Display *, XErrorEvent *) =
+        XSetErrorHandler (redirectErrorHandler);
     XCompositeRedirectSubwindows (qt_xdisplay (), mCompositeWindow,
 				  CompositeRedirectManual);
+    syncX ();
+    XSetErrorHandler (oldErrorHandler);
+    if (redirectError)
+        XCompositeRedirectSubwindows (qt_xdisplay (), mCompositeWindow,
+                                      CompositeRedirectAutomatic);
 
     XMapWindow (qt_xdisplay (), mCompositeWindow);
 }
openSUSE Build Service is sponsored by