diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe2acb0ec..1bb075ece8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR} ########### next target ############### set(kwin_KDEINIT_SRCS - kwinadaptor.cpp + kwinadaptor.cpp workspace.cpp client.cpp placement.cpp @@ -60,6 +60,9 @@ endif (X11_Xcomposite_FOUND) if (X11_Xdamage_FOUND) target_link_libraries(kdeinit_kwin ${X11_Xdamage_LIB}) endif (X11_Xdamage_FOUND) +if (X11_Xrender_FOUND) + target_link_libraries(kdeinit_kwin ${X11_Xrender_LIB}) +endif (X11_Xrender_FOUND) install(TARGETS kdeinit_kwin DESTINATION ${LIB_INSTALL_DIR} ) diff --git a/composite.cpp b/composite.cpp index d5e8d869dc..c21914b4ad 100644 --- a/composite.cpp +++ b/composite.cpp @@ -14,6 +14,7 @@ License. See the file "COPYING" for the exact licensing terms. #include "unmanaged.h" #include "scene.h" #include "scene_basic.h" +#include "scene_xrender.h" namespace KWinInternal { @@ -33,7 +34,8 @@ void Workspace::setupCompositing() compositeTimer.start( 20 ); XCompositeRedirectSubwindows( display(), rootWindow(), CompositeRedirectManual ); setDamaged(); - scene = new SceneBasic( this ); +// scene = new SceneBasic( this ); + scene = new SceneXrender( this ); } void Workspace::finishCompositing() diff --git a/scene_basic.h b/scene_basic.h index ddd2d3dfe2..0210da92c5 100644 --- a/scene_basic.h +++ b/scene_basic.h @@ -25,7 +25,6 @@ class SceneBasic virtual void paint(); }; - } // namespace #endif diff --git a/scene_xrender.cpp b/scene_xrender.cpp index d420e84393..6918ec668a 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -10,6 +10,10 @@ License. See the file "COPYING" for the exact licensing terms. #include "scene_xrender.h" +#ifdef HAVE_XRENDER + +#include "toplevel.h" + namespace KWinInternal { @@ -17,4 +21,58 @@ namespace KWinInternal // SceneXrender //**************************************** +SceneXrender::SceneXrender( Workspace* ws ) + : Scene( ws ) + { + format = XRenderFindVisualFormat( display(), DefaultVisual( display(), DefaultScreen( display()))); + XRenderPictureAttributes pa; + pa.subwindow_mode = IncludeInferiors; + front = XRenderCreatePicture( display(), rootWindow(), format, CPSubwindowMode, &pa ); + createBuffer(); + } + +SceneXrender::~SceneXrender() + { + XRenderFreePicture( display(), front ); + XRenderFreePicture( display(), buffer ); + } + +// TODO handle xrandr changes + +void SceneXrender::createBuffer() + { + if( buffer != None ) + XRenderFreePicture( display(), buffer ); + Pixmap pixmap = XCreatePixmap( display(), rootWindow(), displayWidth(), displayHeight(), QX11Info::appDepth()); + buffer = XRenderCreatePicture( display(), pixmap, format, 0, 0 ); + XFreePixmap( display(), pixmap ); // The picture owns the pixmap now + } + +void SceneXrender::paint() + { + XRenderColor col = { 0xffff, 0xffff, 0xffff, 0xffff }; + XRenderFillRectangle( display(), PictOpSrc, buffer, &col, 0, 0, displayWidth(), displayHeight()); + for( ToplevelList::ConstIterator it = windows.begin(); + it != windows.end(); + ++it ) + { + QRect r = (*it)->geometry().intersect( QRect( 0, 0, displayWidth(), displayHeight())); + if( !r.isEmpty()) + { + XWindowAttributes attrs; + if( !XGetWindowAttributes( display(), (*it)->handle(), &attrs )) + continue; + if( XRenderPictFormat* clientFormat = XRenderFindVisualFormat( display(), attrs.visual )) + { + Picture picture = XRenderCreatePicture( display(), (*it)->windowPixmap(), clientFormat, 0, 0 ); + XRenderComposite( display(), PictOpSrc, picture, None, buffer, 0, 0, 0, 0, + (*it)->x(), (*it)->y(), (*it)->width(), (*it)->height()); + } + } + } + XRenderComposite( display(), PictOpSrc, buffer, None, front, 0, 0, 0, 0, 0, 0, displayWidth(), displayHeight()); + XFlush( display()); + } + } // namespace +#endif diff --git a/scene_xrender.h b/scene_xrender.h index a4bf6a4bf7..220799279a 100644 --- a/scene_xrender.h +++ b/scene_xrender.h @@ -11,9 +11,32 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_SCENE_XRENDER_H #define KWIN_SCENE_XRENDER_H +#include "config.h" + +#ifdef HAVE_XRENDER +#include + +#include "scene.h" + namespace KWinInternal { +class SceneXrender + : public Scene + { + public: + SceneXrender( Workspace* ws ); + virtual ~SceneXrender(); + virtual void paint(); + private: + void createBuffer(); + XRenderPictFormat* format; + Picture front; + Picture buffer; + }; + } // namespace #endif + +#endif