* Enable composite redirects for all top-level windows, if the
  composite extension is detected and CONFIG_USE_COMPOSITE is set.
  This tiny change makes wmx enormously faster on certain modern
  video cards (most noticeably the ATI card I'm using at the moment,
  which is appallingly bad at normal accelerated window operations).
  It will probably make things slower on other systems, so may need
  more testing.
4 files changed, 106 insertions(+), 0 deletions(-)

M Config.h
M Manager.C
M configure
M configure.in
M Config.h +8 -0
@@ 148,6 148,14 @@ private:
 
 #define CONFIG_RESIZE_UPDATE      True
 
+// If USE_COMPOSITE is true, wmx will enable composite redirects for
+// all windows if the Composite extension is present.  This should
+// make no difference at all to the appearance or behaviour of wmx,
+// but it may make it substantially faster with modern video cards
+// that optimise rendering more than old-fashioned window operations.
+
+#define CONFIG_USE_COMPOSITE      True
+
 // If RAISELOWER_ON_CLICK is True, clicking on the title of the
 // topmost window will lower instead of raising it (patch due to
 // Kazushi (Jam) Marukawa)

          
M Manager.C +15 -0
@@ 15,6 15,10 @@ 
 #include "Cursors.h"
 #include <X11/cursorfont.h>
 
+#ifdef CONFIG_USE_COMPOSITE
+#include <X11/extensions/Xcomposite.h>
+#endif
+
 Atom    Atoms::wm_state;
 Atom    Atoms::wm_changeState;
 Atom    Atoms::wm_protocols;

          
@@ 225,6 229,17 @@ WindowManager::WindowManager(int argc, c
 
     fprintf(stderr, "\n     NETWM compliant.");
 
+#ifdef CONFIG_USE_COMPOSITE
+    int ev, er;
+    if (XCompositeQueryExtension(m_display, &ev, &er)) {
+        fprintf(stderr, "  Composite extension enabled.");
+        for (int i = 0; i < m_screensTotal; ++i) {
+            XCompositeRedirectSubwindows(m_display, RootWindow(m_display, i),
+                                         CompositeRedirectAutomatic);
+        }
+    }
+#endif
+
     fprintf(stderr, "\n     Command menu taken from ");
     if (wmxdir == NULL) {
 	fprintf(stderr, "%s/%s.\n", home, CONFIG_COMMAND_MENU);

          
M configure +77 -0
@@ 3020,6 3020,83 @@ fi
 
 
 
+{ echo "$as_me:$LINENO: checking for XCompositeQueryExtension in -lXcomposite" >&5
+echo $ECHO_N "checking for XCompositeQueryExtension in -lXcomposite... $ECHO_C" >&6; }
+if test "${ac_cv_lib_Xcomposite_XCompositeQueryExtension+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXcomposite  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char XCompositeQueryExtension ();
+int
+main ()
+{
+return XCompositeQueryExtension ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_Xcomposite_XCompositeQueryExtension=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_Xcomposite_XCompositeQueryExtension=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xcomposite_XCompositeQueryExtension" >&5
+echo "${ECHO_T}$ac_cv_lib_Xcomposite_XCompositeQueryExtension" >&6; }
+if test $ac_cv_lib_Xcomposite_XCompositeQueryExtension = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBXCOMPOSITE 1
+_ACEOF
+
+  LIBS="-lXcomposite $LIBS"
+
+else
+
+    echo "Warning: Xcomposite library not found"
+    echo "Please either install the Xcomposite library and headers, or ensure you have CONFIG_USE_COMPOSITE set to False in Config.h"
+
+fi
+
+
+
 { echo "$as_me:$LINENO: checking for SmcOpenConnection in -lSM" >&5
 echo $ECHO_N "checking for SmcOpenConnection in -lSM... $ECHO_C" >&6; }
 if test "${ac_cv_lib_SM_SmcOpenConnection+set}" = set; then

          
M configure.in +6 -0
@@ 39,6 39,12 @@ AC_CHECK_LIB(Xpm, XpmCreatePixmapFromDat
     echo "Please either install the Xpm library and headers, or ensure you have CONFIG_USE_PIXMAPS set to False in Config.h"
     ])
 
+dnl Composite is necessary if CONFIG_USE_COMPOSITE
+AC_CHECK_LIB(Xcomposite, XCompositeQueryExtension, [], [
+    echo "Warning: Xcomposite library not found"
+    echo "Please either install the Xcomposite library and headers, or ensure you have CONFIG_USE_COMPOSITE set to False in Config.h"
+    ])
+
 dnl SM and ICE are necessary if CONFIG_USE_SESSION_MANAGER
 AC_CHECK_LIB(SM, SmcOpenConnection)
 AC_CHECK_LIB(ICE, IceConnectionNumber)