diff --git a/composite.cpp b/composite.cpp index c7378fb4dd..e014f46ab3 100644 --- a/composite.cpp +++ b/composite.cpp @@ -51,8 +51,9 @@ void Workspace::setupCompositing() default: kDebug() << "No compositing" << endl; return; - } + } compositeTimer.start( 20 ); + lastCompositePaint.start(); XCompositeRedirectSubwindows( display(), rootWindow(), CompositeRedirectManual ); if( dynamic_cast< SceneOpenGL* >( scene )) kDebug() << "OpenGL compositing" << endl; @@ -121,6 +122,13 @@ void Workspace::compositeTimeout() { if( damage_region.isEmpty()) // no damage return; + // The event loop apparently tries to fire a QTimer as often as possible, even + // at the expense of not processing many X events. This means that the composite + // repaints can seriously impact performance of everything else, therefore throttle + // them - leave at least 5msec time after one repaint is finished and next one + // is started. + if( lastCompositePaint.elapsed() < 5 ) + return; ToplevelList windows; Window* children; unsigned int children_count; @@ -142,6 +150,7 @@ void Workspace::compositeTimeout() foreach( Toplevel* c, windows ) c->resetDamage(); damage_region = QRegion(); + lastCompositePaint.start(); } //**************************************** diff --git a/workspace.h b/workspace.h index 0279baf3d0..8e37e4188f 100644 --- a/workspace.h +++ b/workspace.h @@ -18,6 +18,7 @@ License. See the file "COPYING" for the exact licensing terms. #include #include #include +#include #include "utils.h" #include "kdecoration.h" @@ -669,6 +670,7 @@ class Workspace : public QObject, public KDecorationDefines bool forced_global_mouse_grab; friend class StackingUpdatesBlocker; QTimer compositeTimer; + QTime lastCompositePaint; QRegion damage_region; QSlider *transSlider; QPushButton *transButton;