diff --git a/effects/boxswitch.cpp b/effects/boxswitch.cpp
index 58a5141883..bf2e67b8d5 100644
--- a/effects/boxswitch.cpp
+++ b/effects/boxswitch.cpp
@@ -344,25 +344,13 @@ void BoxSwitchEffect::setInactive()
if( w != selected_window )
w->addRepaintFull();
}
- foreach( ItemInfo* i, windows )
- {
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- if( effects->compositingType() == XRenderCompositing )
- {
- if( i->iconPicture != None )
- XRenderFreePicture( display(), i->iconPicture );
- i->iconPicture = None;
- }
-#endif
- delete i;
- }
+ qDeleteAll( windows );
windows.clear();
setSelectedWindow( 0 );
}
else
{ // DesktopMode
- foreach( ItemInfo* i, desktops )
- delete i;
+ qDeleteAll( windows );
desktops.clear();
}
effects->addRepaint( frame_area );
@@ -601,8 +589,6 @@ void BoxSwitchEffect::paintWindowIcon( EffectWindow* w )
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( effects->compositingType() == XRenderCompositing )
{
- if( windows[ w ]->iconPicture != None )
- XRenderFreePicture( display(), windows[ w ]->iconPicture );
windows[ w ]->iconPicture = XRenderCreatePicture( display(),
windows[ w ]->icon.handle(), alphaFormat, 0, NULL );
}
diff --git a/effects/boxswitch.h b/effects/boxswitch.h
index cfe7c34378..4bf01e1e17 100644
--- a/effects/boxswitch.h
+++ b/effects/boxswitch.h
@@ -31,6 +31,7 @@ along with this program. If not, see .
#include
#include
+#include
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
#include
@@ -112,7 +113,7 @@ class BoxSwitchEffect::ItemInfo
GLTexture iconTexture;
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- Picture iconPicture;
+ XRenderPicture iconPicture;
#endif
};
diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp
index 28d4a0e8ed..26d3635f0e 100644
--- a/effects/presentwindows.cpp
+++ b/effects/presentwindows.cpp
@@ -1046,8 +1046,6 @@ void PresentWindowsEffect::paintWindowIcon( EffectWindow* w, WindowPaintData& pa
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if( effects->compositingType() == XRenderCompositing )
{
- if( data.iconPicture != None )
- XRenderFreePicture( display(), data.iconPicture );
data.iconPicture = XRenderCreatePicture( display(),
data.icon.handle(), alphaFormat, 0, NULL );
}
diff --git a/effects/presentwindows.h b/effects/presentwindows.h
index d9f3c83c58..08e940b256 100644
--- a/effects/presentwindows.h
+++ b/effects/presentwindows.h
@@ -24,6 +24,7 @@ along with this program. If not, see .
// Include with base class for effects.
#include
#include
+#include
#include
@@ -121,7 +122,7 @@ class PresentWindowsEffect
KSharedPtr< GLTexture > iconTexture;
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- Picture iconPicture;
+ XRenderPicture iconPicture;
#endif
};
typedef QHash DataHash;
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index bf2658a103..6468315c99 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -33,6 +33,7 @@ set(kwin_EFFECTSLIB_SRCS
kwinglutils.cpp
kwinglutils_funcs.cpp
kwinshadereffect.cpp
+ kwinxrenderutils.cpp
)
kde4_add_library(kwineffects SHARED ${kwin_EFFECTSLIB_SRCS})
@@ -72,5 +73,6 @@ install( FILES
kwinglutils.h
kwinglutils_funcs.h
kwinshadereffect.h
+ kwinxrenderutils.h
${CMAKE_CURRENT_BINARY_DIR}/kwinconfig.h
DESTINATION ${INCLUDE_INSTALL_DIR})
diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp
index 444c106f5a..2286854912 100644
--- a/lib/kwineffects.cpp
+++ b/lib/kwineffects.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include "kwineffects.h"
#include "kwinglutils.h"
+#include "kwinxrenderutils.h"
#include
#include
@@ -979,27 +980,4 @@ void TimeLine::setCurveShape(CurveShape curveShape)
m_CurveShape = curveShape;
}
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
-// Convert QRegion to XserverRegion. All code uses XserverRegion
-// only when really necessary as the shared implementation uses
-// QRegion.
-XserverRegion toXserverRegion( QRegion region )
- {
- QVector< QRect > rects = region.rects();
- XRectangle* xr = new XRectangle[ rects.count() ];
- for( int i = 0;
- i < rects.count();
- ++i )
- {
- xr[ i ].x = rects[ i ].x();
- xr[ i ].y = rects[ i ].y();
- xr[ i ].width = rects[ i ].width();
- xr[ i ].height = rects[ i ].height();
- }
- XserverRegion ret = XFixesCreateRegion( display(), xr, rects.count());
- delete[] xr;
- return ret;
- }
-#endif
-
} // namespace
diff --git a/lib/kwineffects.h b/lib/kwineffects.h
index 737111e80e..6b62278a0b 100644
--- a/lib/kwineffects.h
+++ b/lib/kwineffects.h
@@ -41,10 +41,6 @@ along with this program. If not, see .
#include
#include
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
-#include
-#endif
-
class KLibrary;
class KConfigGroup;
class KActionCollection;
@@ -179,13 +175,6 @@ QRect infiniteRegion()
return QRect( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
}
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
-/**
- * Convert QRegion to XserverRegion.
- */
-KWIN_EXPORT XserverRegion toXserverRegion( QRegion region );
-#endif
-
/**
* @short Base class for all KWin effects
*
diff --git a/lib/kwinxrenderutils.cpp b/lib/kwinxrenderutils.cpp
new file mode 100644
index 0000000000..00ff05056d
--- /dev/null
+++ b/lib/kwinxrenderutils.cpp
@@ -0,0 +1,53 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2008 Lubos Lunak
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*********************************************************************/
+
+#include "kwinxrenderutils.h"
+
+#ifdef KWIN_HAVE_XRENDER_COMPOSITING
+
+#include
+
+namespace KWin
+{
+
+// Convert QRegion to XserverRegion. All code uses XserverRegion
+// only when really necessary as the shared implementation uses
+// QRegion.
+XserverRegion toXserverRegion( QRegion region )
+ {
+ QVector< QRect > rects = region.rects();
+ XRectangle* xr = new XRectangle[ rects.count() ];
+ for( int i = 0;
+ i < rects.count();
+ ++i )
+ {
+ xr[ i ].x = rects[ i ].x();
+ xr[ i ].y = rects[ i ].y();
+ xr[ i ].width = rects[ i ].width();
+ xr[ i ].height = rects[ i ].height();
+ }
+ XserverRegion ret = XFixesCreateRegion( display(), xr, rects.count());
+ delete[] xr;
+ return ret;
+ }
+
+} // namespace
+
+#endif
diff --git a/lib/kwinxrenderutils.h b/lib/kwinxrenderutils.h
new file mode 100644
index 0000000000..85fded1c4c
--- /dev/null
+++ b/lib/kwinxrenderutils.h
@@ -0,0 +1,112 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2008 Lubos Lunak
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*********************************************************************/
+
+#ifndef KWIN_XRENDERUTILS_H
+#define KWIN_XRENDERUTILS_H
+
+#include
+
+#ifdef KWIN_HAVE_XRENDER_COMPOSITING
+
+#include
+#include
+
+#include
+
+#include
+#include
+
+/** @addtogroup kwineffects */
+/** @{ */
+
+namespace KWin
+{
+
+/**
+ * Convert QRegion to XserverRegion.
+ */
+KWIN_EXPORT XserverRegion toXserverRegion( QRegion region );
+
+/** @internal */
+class KWIN_EXPORT XRenderPictureData
+ : public QSharedData
+ {
+ public:
+ XRenderPictureData( Picture pic = None );
+ ~XRenderPictureData();
+ Picture value();
+ private:
+ Picture picture;
+ Q_DISABLE_COPY( XRenderPictureData )
+ };
+
+/**
+ * @short Wrapper around XRender Picture.
+ *
+ * This class wraps XRender's Picture, providing proper initialization
+ * and freeing of resources. It should otherwise act exactly like the Picture type.
+ */
+class KWIN_EXPORT XRenderPicture
+ {
+ public:
+ XRenderPicture( Picture pic = None );
+ operator Picture();
+ private:
+ KSharedPtr< XRenderPictureData > d;
+ };
+
+inline
+XRenderPictureData::XRenderPictureData( Picture pic )
+ : picture( pic )
+ {
+ }
+
+inline
+XRenderPictureData::~XRenderPictureData()
+ {
+ if( picture != None )
+ XRenderFreePicture( display(), picture );
+ }
+
+inline
+Picture XRenderPictureData::value()
+ {
+ return picture;
+ }
+
+inline
+XRenderPicture::XRenderPicture( Picture pic )
+ : d( new XRenderPictureData( pic ))
+ {
+ }
+
+inline
+XRenderPicture::operator Picture()
+ {
+ return d->value();
+ }
+
+} // namespace
+
+#endif
+
+/** @} */
+
+#endif
diff --git a/scene_xrender.cpp b/scene_xrender.cpp
index b68db4fc71..eb8f614029 100644
--- a/scene_xrender.cpp
+++ b/scene_xrender.cpp
@@ -45,6 +45,7 @@ along with this program. If not, see .
#include "client.h"
#include "deleted.h"
#include "effects.h"
+#include "kwinxrenderutils.h"
#include