Add build checks for XComposite, XDamage, XRender, OpenGL, and XShm.
KWin should now build and run with/without any or all of the above. svn path=/branches/work/kwin_composite/; revision=633387
This commit is contained in:
parent
8f8c6d049b
commit
8299541652
11 changed files with 94 additions and 13 deletions
|
@ -66,11 +66,16 @@ set(kwin_KDEINIT_SRCS
|
|||
effects/zoom.cpp
|
||||
effects/test_input.cpp
|
||||
effects/presentwindows.cpp
|
||||
effects/wavywindows.cpp
|
||||
effects/minimizeanimation.cpp
|
||||
effects/desktopchangeslide.cpp
|
||||
)
|
||||
|
||||
if(HAVE_OPENGL)
|
||||
set(kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
|
||||
effects/wavywindows.cpp
|
||||
)
|
||||
endif(HAVE_OPENGL)
|
||||
|
||||
qt4_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.KWin.xml workspace.h KWinInternal::Workspace )
|
||||
|
||||
kde4_automoc(kwin ${kwin_KDEINIT_SRCS})
|
||||
|
@ -79,9 +84,11 @@ kde4_automoc(kwin ${kwin_KDEINIT_SRCS})
|
|||
kde4_add_kdeinit_executable( kwin ${kwin_KDEINIT_SRCS})
|
||||
|
||||
target_link_libraries(kdeinit_kwin ${KDE4_KDEUI_LIBS} kdecorations ${X11_LIBRARIES} ${QT_QT3SUPPORT_LIBRARY} )
|
||||
target_link_libraries(kdeinit_kwin -lGL)
|
||||
# -ldl used by OpenGL code
|
||||
target_link_libraries(kdeinit_kwin -ldl)
|
||||
if(OPENGL_FOUND)
|
||||
target_link_libraries(kdeinit_kwin ${OPENGL_gl_LIBRARY})
|
||||
# -ldl used by OpenGL code
|
||||
target_link_libraries(kdeinit_kwin -ldl)
|
||||
endif(OPENGL_FOUND)
|
||||
if (X11_Xrandr_FOUND)
|
||||
target_link_libraries(kdeinit_kwin ${X11_Xrandr_LIB})
|
||||
endif (X11_Xrandr_FOUND)
|
||||
|
|
|
@ -49,9 +49,9 @@ namespace KWinInternal
|
|||
// Workspace
|
||||
//****************************************
|
||||
|
||||
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
|
||||
void Workspace::setupCompositing()
|
||||
{
|
||||
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
|
||||
if( !options->useTranslucency )
|
||||
return;
|
||||
if( !Extensions::compositeAvailable() || !Extensions::damageAvailable())
|
||||
|
@ -70,13 +70,20 @@ void Workspace::setupCompositing()
|
|||
{
|
||||
case 'B':
|
||||
scene = new SceneBasic( this );
|
||||
kDebug( 1212 ) << "X compositing" << endl;
|
||||
break;
|
||||
#ifdef HAVE_XRENDER
|
||||
case 'X':
|
||||
scene = new SceneXrender( this );
|
||||
kDebug( 1212 ) << "XRender compositing" << endl;
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
case 'O':
|
||||
scene = new SceneOpenGL( this );
|
||||
kDebug( 1212 ) << "OpenGL compositing" << endl;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
kDebug( 1212 ) << "No compositing" << endl;
|
||||
return;
|
||||
|
@ -112,12 +119,6 @@ void Workspace::setupCompositing()
|
|||
compositeTimer.start( compositeRate );
|
||||
lastCompositePaint.start();
|
||||
XCompositeRedirectSubwindows( display(), rootWindow(), CompositeRedirectManual );
|
||||
if( dynamic_cast< SceneOpenGL* >( scene ))
|
||||
kDebug( 1212 ) << "OpenGL compositing" << endl;
|
||||
else if( dynamic_cast< SceneXrender* >( scene ))
|
||||
kDebug( 1212 ) << "XRender compositing" << endl;
|
||||
else if( dynamic_cast< SceneBasic* >( scene ))
|
||||
kDebug( 1212 ) << "X compositing" << endl;
|
||||
new EffectsHandler(); // sets also the 'effects' pointer
|
||||
addRepaintFull();
|
||||
foreach( Client* c, clients )
|
||||
|
@ -134,10 +135,12 @@ void Workspace::setupCompositing()
|
|||
scene->windowAdded( c );
|
||||
delete popup; // force re-creation of the Alt+F3 popup (opacity option)
|
||||
popup = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Workspace::finishCompositing()
|
||||
{
|
||||
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
|
||||
if( scene == NULL )
|
||||
return;
|
||||
delete cm_selection;
|
||||
|
@ -176,6 +179,7 @@ void Workspace::finishCompositing()
|
|||
}
|
||||
delete popup; // force re-creation of the Alt+F3 popup (opacity option)
|
||||
popup = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Workspace::lostCMSelection()
|
||||
|
@ -207,6 +211,7 @@ void Workspace::addRepaintFull()
|
|||
|
||||
void Workspace::performCompositing()
|
||||
{
|
||||
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
|
||||
// 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
|
||||
|
@ -258,6 +263,7 @@ void Workspace::performCompositing()
|
|||
compositeTimer.start( compositeRate - paintTime );
|
||||
}
|
||||
lastCompositePaint.start();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Workspace::windowRepaintsPending() const
|
||||
|
@ -320,6 +326,7 @@ void Workspace::destroyOverlay()
|
|||
|
||||
void Toplevel::setupCompositing()
|
||||
{
|
||||
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
|
||||
if( !compositing())
|
||||
return;
|
||||
if( damage_handle != None )
|
||||
|
@ -328,10 +335,12 @@ void Toplevel::setupCompositing()
|
|||
damage_region = QRegion( 0, 0, width(), height());
|
||||
effect_window = new EffectWindow();
|
||||
effect_window->setWindow( this );
|
||||
#endif
|
||||
}
|
||||
|
||||
void Toplevel::finishCompositing()
|
||||
{
|
||||
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
|
||||
if( damage_handle == None )
|
||||
return;
|
||||
if( effect_window->window() == this ) // otherwise it's already passed to Deleted, don't free data
|
||||
|
@ -344,6 +353,7 @@ void Toplevel::finishCompositing()
|
|||
damage_region = QRegion();
|
||||
repaints_region = QRegion();
|
||||
effect_window = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Toplevel::discardWindowPixmap()
|
||||
|
@ -357,10 +367,15 @@ void Toplevel::discardWindowPixmap()
|
|||
|
||||
Pixmap Toplevel::createWindowPixmap() const
|
||||
{
|
||||
#ifdef HAVE_XCOMPOSITE
|
||||
assert( compositing());
|
||||
return XCompositeNameWindowPixmap( display(), frameId());
|
||||
#else
|
||||
return None;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_XDAMAGE
|
||||
void Toplevel::damageNotifyEvent( XDamageNotifyEvent* e )
|
||||
{
|
||||
addDamage( e->area.x, e->area.y, e->area.width, e->area.height );
|
||||
|
@ -379,6 +394,7 @@ void Toplevel::damageNotifyEvent( XDamageNotifyEvent* e )
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Toplevel::addDamage( const QRect& r )
|
||||
{
|
||||
|
@ -434,6 +450,4 @@ void Toplevel::resetRepaints( const QRect& r )
|
|||
repaints_region -= r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -28,7 +28,9 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include "effects/shakymove.h"
|
||||
#include "effects/shiftworkspaceup.h"
|
||||
#include "effects/showfps.h"
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "effects/wavywindows.h"
|
||||
#endif
|
||||
#include "effects/zoom.h"
|
||||
|
||||
#include "effects/test_input.h"
|
||||
|
@ -129,7 +131,9 @@ EffectsHandler::EffectsHandler()
|
|||
registerEffect("ShowFps", new GenericEffectFactory<ShowFpsEffect>);
|
||||
registerEffect("Zoom", new GenericEffectFactory<ZoomEffect>);
|
||||
registerEffect("PresentWindows", new GenericEffectFactory<PresentWindowsEffect>);
|
||||
#ifdef HAVE_OPENGL
|
||||
registerEffect("WavyWindows", new GenericEffectFactory<WavyWindowsEffect>);
|
||||
#endif
|
||||
registerEffect("MinimizeAnimation", new GenericEffectFactory<MinimizeAnimationEffect>);
|
||||
registerEffect("Howto", new GenericEffectFactory<HowtoEffect>);
|
||||
registerEffect("MakeTransparent", new GenericEffectFactory<MakeTransparentEffect>);
|
||||
|
|
|
@ -16,7 +16,9 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include <scene_opengl.h>
|
||||
#include <scene_xrender.h>
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
@ -73,12 +75,14 @@ void ShowFpsEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
|
|||
++fps; // count all frames in the last second
|
||||
if( fps > MAX_TIME )
|
||||
fps = MAX_TIME; // keep it the same height
|
||||
#ifdef HAVE_OPENGL
|
||||
if( dynamic_cast< SceneOpenGL* >( scene ))
|
||||
{
|
||||
paintGL( fps );
|
||||
glFinish(); // make sure all rendering is done
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
paintX( fps );
|
||||
XSync( display(), False ); // make sure all rendering is done
|
||||
|
@ -87,6 +91,7 @@ void ShowFpsEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
|
|||
|
||||
void ShowFpsEffect::paintGL( int fps )
|
||||
{
|
||||
#ifdef HAVE_OPENGL
|
||||
int x = this->x;
|
||||
int y = this->y;
|
||||
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
||||
|
@ -141,6 +146,7 @@ void ShowFpsEffect::paintGL( int fps )
|
|||
}
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -150,6 +156,7 @@ void ShowFpsEffect::paintGL( int fps )
|
|||
*/
|
||||
void ShowFpsEffect::paintX( int fps )
|
||||
{
|
||||
#ifdef HAVE_XRENDER
|
||||
Pixmap pixmap = XCreatePixmap( display(), rootWindow(), NUM_PAINTS + FPS_WIDTH, MAX_TIME, 32 );
|
||||
XRenderPictFormat* format = XRenderFindStandardFormat( display(), PictStandardARGB32 );
|
||||
Picture p = XRenderCreatePicture( display(), pixmap, format, 0, NULL );
|
||||
|
@ -209,6 +216,7 @@ void ShowFpsEffect::paintX( int fps )
|
|||
XRenderComposite( display(), alpha != 1.0 ? PictOpOver : PictOpSrc, p, None,
|
||||
static_cast< SceneXrender* >( scene )->bufferPicture(), 0, 0, 0, 0, x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME );
|
||||
XRenderFreePicture( display(), p );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShowFpsEffect::postPaintScreen()
|
||||
|
|
|
@ -701,8 +701,10 @@ bool Client::windowEvent( XEvent* e )
|
|||
}
|
||||
if( e->xany.window == frameId())
|
||||
{
|
||||
#ifdef HAVE_XDAMAGE
|
||||
if( e->type == Extensions::damageNotifyEvent())
|
||||
damageNotifyEvent( reinterpret_cast< XDamageNotifyEvent* >( e ));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1636,8 +1638,10 @@ bool Unmanaged::windowEvent( XEvent* e )
|
|||
if( scene != NULL )
|
||||
scene->windowGeometryShapeChanged( this );
|
||||
}
|
||||
#ifdef HAVE_XDAMAGE
|
||||
if( e->type == Extensions::damageNotifyEvent())
|
||||
damageNotifyEvent( reinterpret_cast< XDamageNotifyEvent* >( e ));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
11
glutils.cpp
11
glutils.cpp
|
@ -33,6 +33,7 @@ int glTextureUnitsCount;
|
|||
// Functions
|
||||
void initGLX()
|
||||
{
|
||||
#ifdef HAVE_OPENGL
|
||||
// Get GLX version
|
||||
int major, minor;
|
||||
glXQueryVersion( display(), &major, &minor );
|
||||
|
@ -42,10 +43,14 @@ void initGLX()
|
|||
display(), DefaultScreen( display()))).split(" ");
|
||||
|
||||
glxResolveFunctions();
|
||||
#else
|
||||
glXVersion = MAKE_GL_VERSION( 0, 0, 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void initGL()
|
||||
{
|
||||
#ifdef HAVE_OPENGL
|
||||
// Get OpenGL version
|
||||
QString glversionstring = QString((const char*)glGetString(GL_VERSION));
|
||||
QStringList glversioninfo = glversionstring.left(glversionstring.indexOf(' ')).split('.');
|
||||
|
@ -56,6 +61,9 @@ void initGL()
|
|||
|
||||
// handle OpenGL extensions functions
|
||||
glResolveFunctions();
|
||||
#else
|
||||
glVersion = MAKE_GL_VERSION( 0, 0, 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool hasGLVersion(int major, int minor, int release)
|
||||
|
@ -74,6 +82,7 @@ bool hasGLExtension(const QString& extension)
|
|||
}
|
||||
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
GLShader::GLShader(const QString& vertexfile, const QString& fragmentfile)
|
||||
{
|
||||
|
@ -273,4 +282,6 @@ bool GLShader::setAttribute(const QString& name, float value)
|
|||
return (location >= 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -16,8 +16,10 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include <QStringList>
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
|
||||
#include "glutils_funcs.h"
|
||||
|
||||
|
@ -48,6 +50,7 @@ bool hasGLExtension(const QString& extension);
|
|||
|
||||
inline bool isPowerOfTwo( int x ) { return (( x & ( x - 1 )) == 0 ); }
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
class GLShader
|
||||
{
|
||||
|
@ -76,6 +79,8 @@ class GLShader
|
|||
QHash< QString, int >* mVariableLocations;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
if( !function ) \
|
||||
function = (function ## _func)getProcAddress( #backup );
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
|
@ -213,3 +215,4 @@ void glResolveFunctions()
|
|||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,8 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_GLUTILS_FUNCS_H
|
||||
#define KWIN_GLUTILS_FUNCS_H
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
|
@ -164,3 +166,4 @@ extern glGetAttribLocation_func glGetAttribLocation;
|
|||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -67,6 +67,8 @@ Sources and other compositing managers:
|
|||
#include <sys/shm.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
|
@ -93,7 +95,9 @@ bool SceneOpenGL::supports_npot_textures;
|
|||
bool SceneOpenGL::supports_fbo;
|
||||
bool SceneOpenGL::supports_saturation;
|
||||
bool SceneOpenGL::shm_mode;
|
||||
#ifdef HAVE_XSHM
|
||||
XShmSegmentInfo SceneOpenGL::shm;
|
||||
#endif
|
||||
|
||||
|
||||
// detect OpenGL error (add to various places in code to pinpoint the place)
|
||||
|
@ -226,6 +230,7 @@ bool SceneOpenGL::initTfp()
|
|||
|
||||
bool SceneOpenGL::initShm()
|
||||
{
|
||||
#ifdef HAVE_XSHM
|
||||
int major, minor;
|
||||
Bool pixmaps;
|
||||
if( !XShmQueryVersion( display(), &major, &minor, &pixmaps ) || !pixmaps )
|
||||
|
@ -260,13 +265,18 @@ bool SceneOpenGL::initShm()
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SceneOpenGL::cleanupShm()
|
||||
{
|
||||
#ifdef HAVE_XSHM
|
||||
shmdt( shm.shmaddr );
|
||||
#ifndef __linux__
|
||||
shmctl( shm.shmid, IPC_RMID, 0 );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -902,6 +912,7 @@ void SceneOpenGL::Window::bindTexture()
|
|||
glXWaitX();
|
||||
if( shm_mode )
|
||||
{ // non-tfp case, copy pixmap contents to a texture
|
||||
#ifdef HAVE_XSHM
|
||||
findTextureTarget();
|
||||
if( texture == None )
|
||||
{
|
||||
|
@ -941,6 +952,7 @@ void SceneOpenGL::Window::bindTexture()
|
|||
texture_y_inverted = true;
|
||||
texture_can_use_mipmaps = true;
|
||||
toplevel->resetDamage( toplevel->rect());
|
||||
#endif
|
||||
}
|
||||
else if( tfp_mode )
|
||||
{ // tfp mode, simply bind the pixmap to texture
|
||||
|
@ -1370,3 +1382,5 @@ void SceneOpenGL::Window::restoreRenderStates( int mask, WindowPaintData data )
|
|||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,11 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "glutils.h"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
#ifdef HAVE_XSHM
|
||||
#include <X11/extensions/XShm.h>
|
||||
#endif
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
@ -76,7 +80,9 @@ class SceneOpenGL
|
|||
static bool supports_fbo;
|
||||
static bool supports_saturation;
|
||||
QMap< Toplevel*, Window > windows;
|
||||
#ifdef HAVE_XSHM
|
||||
static XShmSegmentInfo shm;
|
||||
#endif
|
||||
};
|
||||
|
||||
class SceneOpenGL::Window
|
||||
|
@ -160,3 +166,5 @@ class SceneOpenGL::Window
|
|||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue