From 0e55f109c58cdb96c3ab52c40736e79e98c5f61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 18 Oct 2007 17:58:08 +0000 Subject: [PATCH] Don't do any compositing when nothing is visible anyway (e.g. when switched away from the X session). svn path=/trunk/KDE/kdebase/workspace/; revision=726713 --- composite.cpp | 4 +++- events.cpp | 10 +++++++++- workspace.cpp | 1 + workspace.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/composite.cpp b/composite.cpp index 6be611eecc..c63decd292 100644 --- a/composite.cpp +++ b/composite.cpp @@ -271,7 +271,8 @@ void Workspace::performCompositing() if( lastCompositePaint.elapsed() < 1 ) return; checkCursorPos(); - if( repaints_region.isEmpty() && !windowRepaintsPending()) // no damage + if(( repaints_region.isEmpty() && !windowRepaintsPending()) // no damage + || !overlay_visible ) // nothing is visible anyway { scene->idle(); return; @@ -365,6 +366,7 @@ void Workspace::setupOverlay( Window w ) XMapWindow( display(), w ); } XMapRaised( display(), overlay ); + XSelectInput( display(), overlay, VisibilityChangeMask ); } void Workspace::destroyOverlay() diff --git a/events.cpp b/events.cpp index 922387010f..d6bb856677 100644 --- a/events.cpp +++ b/events.cpp @@ -455,8 +455,16 @@ bool Workspace::workspaceEvent( XEvent * e ) return true; break; case Expose: - if( e->xexpose.window == rootWindow() && compositing()) // root window needs repainting + if( compositing() + && ( e->xexpose.window == rootWindow() // root window needs repainting + || overlay != None && e->xexpose.window == overlay )) // overlay needs repainting + { addRepaint( e->xexpose.x, e->xexpose.y, e->xexpose.width, e->xexpose.height ); + } + break; + case VisibilityNotify: + if( compositing() && overlay != None && e->xvisibility.window == overlay ) + overlay_visible = ( e->xvisibility.state != VisibilityFullyObscured ); break; default: if( e->type == Extensions::randrNotifyEvent() && Extensions::randrAvailable() ) diff --git a/workspace.cpp b/workspace.cpp index a383bd15b7..9bcdd767f1 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -128,6 +128,7 @@ Workspace::Workspace( bool restore ) cm_selection( NULL ), compositeRate( 0 ), overlay( None ), + overlay_visible( true ), transSlider( NULL ), transButton( NULL ) { diff --git a/workspace.h b/workspace.h index e7733ee370..c038be6b3f 100644 --- a/workspace.h +++ b/workspace.h @@ -715,6 +715,7 @@ class Workspace : public QObject, public KDecorationDefines int compositeRate; QRegion repaints_region; Window overlay; // XComposite overlay window + bool overlay_visible; QSlider *transSlider; QPushButton *transButton;