diff --git a/compositingprefs.cpp b/compositingprefs.cpp index 79f922ad2d..82055f7097 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -20,11 +20,14 @@ namespace KWin { CompositingPrefs::CompositingPrefs() + : mXgl( false ) + , mEnableCompositing( false ) + , mEnableVSync( true ) + , mEnableDirectRendering( true ) + , mStrictBinding( true ) { - mEnableCompositing = false; - mEnableVSync = true; - mEnableDirectRendering = true; } + CompositingPrefs::~CompositingPrefs() { } @@ -163,26 +166,28 @@ void CompositingPrefs::detectDriverAndVersion() mGLVendor = QString((const char*)glGetString( GL_VENDOR )); mGLRenderer = QString((const char*)glGetString( GL_RENDERER )); mGLVersion = QString((const char*)glGetString( GL_VERSION )); + mXgl = detectXgl(); kDebug() << "GL vendor is" << mGLVendor; kDebug() << "GL renderer is" << mGLRenderer; kDebug() << "GL version is" << mGLVersion; + kDebug() << "XGL:" << ( mXgl ? "yes" : "no" ); if( mGLRenderer.contains( "Intel" )) - { + { mDriver = "intel"; QStringList words = mGLRenderer.split(" "); mVersion = Version( words[ words.count() - 2 ] ); - } + } else if( mGLVendor.contains( "NVIDIA" )) - { + { mDriver = "nvidia"; QStringList words = mGLVersion.split(" "); mVersion = Version( words[ words.count() - 1 ] ); - } + } else - { + { mDriver = "unknown"; - } + } kDebug() << "Detected driver" << mDriver << ", version" << mVersion.join("."); #endif @@ -190,7 +195,13 @@ void CompositingPrefs::detectDriverAndVersion() void CompositingPrefs::applyDriverSpecificOptions() { - if( mDriver == "intel") + if( mXgl ) + { + kDebug() << "xgl, enabling"; + mEnableCompositing = true; + mStrictBinding = false; + } + else if( mDriver == "intel") { kDebug() << "intel driver, disabling vsync, enabling direct"; mEnableVSync = false; @@ -205,6 +216,7 @@ void CompositingPrefs::applyDriverSpecificOptions() { kDebug() << "nvidia driver, disabling vsync"; mEnableVSync = false; + mStrictBinding = false; if( mVersion >= Version( "96.39" )) { kDebug() << "nvidia >= 96.39, enabling compositing"; @@ -214,6 +226,11 @@ void CompositingPrefs::applyDriverSpecificOptions() } +bool CompositingPrefs::detectXgl() + { // Xgl apparently uses only this specific X version + return VendorRelease(display()) == 70000001; + } + CompositingPrefs::Version::Version( const QString& str ) : QStringList() { diff --git a/compositingprefs.h b/compositingprefs.h index 427e834204..9f924cecf3 100644 --- a/compositingprefs.h +++ b/compositingprefs.h @@ -44,17 +44,20 @@ public: bool enableCompositing() const { return mEnableCompositing; } bool enableVSync() const { return mEnableVSync; } bool enableDirectRendering() const { return mEnableDirectRendering; } + bool strictBinding() const { return mStrictBinding; } void detect(); QString driver() const { return mDriver; } Version version() const { return mVersion; } + bool xgl() const { return mXgl; } protected: void detectDriverAndVersion(); void applyDriverSpecificOptions(); + static bool detectXgl(); bool createGLXContext(); void deleteGLXContext(); @@ -66,10 +69,12 @@ private: QString mGLVersion; QString mDriver; Version mVersion; + bool mXgl; bool mEnableCompositing; bool mEnableVSync; bool mEnableDirectRendering; + bool mStrictBinding; #ifdef HAVE_OPENGL GLXContext mGLContext; diff --git a/options.cpp b/options.cpp index 065508709c..fa9b09bf7a 100644 --- a/options.cpp +++ b/options.cpp @@ -180,7 +180,6 @@ unsigned long Options::updateSettings() config.changeGroup("Translucency"); refreshRate = config.readEntry( "RefreshRate", 0 ); - glStrictBinding = config.readEntry( "GLStrictBinding", false ); const HiddenPreviews hps[] = { HiddenPreviewsNever, HiddenPreviewsKeep, HiddenPreviewUpdate, HiddenPreviewsActive }; hiddenPreviews = hps[ qBound( 0, config.readEntry( "HiddenPreviews", 3 ), 3 ) ]; @@ -231,6 +230,7 @@ void Options::reloadCompositingSettings(const CompositingPrefs& prefs) glDirect = config.readEntry("GLDirect", prefs.enableDirectRendering() ); glVSync = config.readEntry("GLVSync", prefs.enableVSync() ); smoothScale = qBound( -1, config.readEntry( "GLTextureFilter", -1 ), 2 ); + glStrictBinding = config.readEntry( "GLStrictBinding", prefs.strictBinding()); xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false ); }