[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/kwin
From:       Thomas Lübking <thomas.luebking () web ! de>
Date:       2010-11-27 15:27:55
Message-ID: 20101127152755.260EAAC8A2 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1201396 by luebking:

support nvidias proprietary refreshrate through asking nvidia-settgins

 M  +3 -24     composite.cpp  
 M  +5 -5      events.cpp  
 M  +47 -0     options.cpp  


--- trunk/KDE/kdebase/workspace/kwin/composite.cpp #1201395:1201396
@@ -77,6 +77,8 @@
 namespace KWin
 {
 
+extern int currentRefreshRate();
+
 //****************************************
 // Workspace
 //****************************************
@@ -195,30 +197,7 @@
         delete cm_selection;
         return;
         }
-    int rate = 0;
-    if( options->refreshRate > 0 )
-        { // use manually configured refresh rate
-        rate = options->refreshRate;
-        }
-#ifdef HAVE_XRANDR
-    else
-        { // autoconfigure refresh rate based on XRandR info
-        if( Extensions::randrAvailable() )
-            {
-            XRRScreenConfiguration *config = XRRGetScreenInfo( display(), \
                rootWindow() );
-            rate = xrrRefreshRate = XRRConfigCurrentRate( config );
-            XRRFreeScreenConfigInfo( config );
-            }
-        }
-#endif
-    // 0Hz or less is invalid, so we fallback to a default rate
-    if( rate <= 0 )
-        rate = 50;
-    // QTimer gives us 1msec (1000Hz) at best, so we ignore anything higher;
-    // however, additional throttling prevents very high rates from taking place \
                anyway
-    else if( rate > 1000 )
-        rate = 1000;
-    kDebug( 1212 ) << "Refresh rate " << rate << "Hz";
+    int rate = xrrRefreshRate = KWin::currentRefreshRate();
     compositeRate = 1000 / rate;
     lastCompositePaint.start();
     // fake a previous paint, so that the next starts right now
--- trunk/KDE/kdebase/workspace/kwin/events.cpp #1201395:1201396
@@ -55,6 +55,8 @@
 namespace KWin
 {
 
+extern int currentRefreshRate();
+    
 // ****************************************
 // WinInfo
 // ****************************************
@@ -510,18 +512,16 @@
                 {
 #ifdef HAVE_XRANDR
                 XRRUpdateConfiguration( e );
+#endif
                 if( compositing() )
                     {
                     // desktopResized() should take care of when the size or
                     // shape of the desktop has changed, but we also want to
                     // catch refresh rate changes
-                    XRRScreenConfiguration *config = XRRGetScreenInfo( display(), \
                rootWindow() );
-                    bool changed = ( xrrRefreshRate != XRRConfigCurrentRate( config \
                ));
-                    XRRFreeScreenConfigInfo( config );
-                    if( changed )
+                    if( xrrRefreshRate != currentRefreshRate() )
                         compositeResetTimer.start( 0 );
                     }
-#endif
+
                 }
             else if( e->type == Extensions::syncAlarmNotifyEvent() && \
Extensions::syncAvailable())  {
--- trunk/KDE/kdebase/workspace/kwin/options.cpp #1201395:1201396
@@ -25,6 +25,7 @@
 
 #include <QPalette>
 #include <QPixmap>
+#include <QProcess>
 #include <kapplication.h>
 #include <kconfig.h>
 #include <kglobal.h>
@@ -37,13 +38,58 @@
 
 #include <kephal/screens.h>
 
+#ifdef HAVE_XRANDR
+#include <X11/extensions/Xrandr.h>
 #endif
 
+
+#endif
+
 namespace KWin
 {
 
 #ifndef KCMRULES
 
+static bool rrNvidia = false;
+int currentRefreshRate()
+    {
+    int rate = -1;
+    if( options->refreshRate > 0 ) // use manually configured refresh rate
+        rate = options->refreshRate;
+    else if ( rrNvidia )
+        {
+        QProcess nvidia_settings;
+        nvidia_settings.start( "nvidia-settings", QStringList() << "-t" << "-q" << \
"RefreshRate", QIODevice::ReadOnly ); +        nvidia_settings.waitForFinished();
+        if ( nvidia_settings.exitStatus() == QProcess::NormalExit )
+            {
+            QString reply = QString::fromLocal8Bit( \
nvidia_settings.readAllStandardOutput() ); +            bool ok;
+            rate = reply.split(' ').first().split(',').first().toUInt( &ok );
+            if ( !ok )
+                rate = -1;
+            }
+        }
+#ifdef HAVE_XRANDR
+    else if( Extensions::randrAvailable() )
+        {
+        XRRScreenConfiguration *config = XRRGetScreenInfo( display(), rootWindow() \
); +        rate = XRRConfigCurrentRate( config );
+        XRRFreeScreenConfigInfo( config );
+        }
+#endif    
+        
+    // 0Hz or less is invalid, so we fallback to a default rate
+    if( rate <= 0 )
+        rate = 50;
+    // QTimer gives us 1msec (1000Hz) at best, so we ignore anything higher;
+    // however, additional throttling prevents very high rates from taking place \
anyway +    else if( rate > 1000 )
+        rate = 1000;
+    kDebug( 1212 ) << "Refresh rate " << rate << "Hz";
+    return rate;
+    }
+
 Options::Options()
     : electric_borders( 0 )
     , electric_border_delay( 0 )
@@ -248,6 +294,7 @@
     // Compositing settings
     CompositingPrefs prefs;
     prefs.detect();
+    rrNvidia = prefs.driver() == "nvidia";
     useCompositing = config.readEntry( "Enabled" , prefs.recommendCompositing());
 
     QString compositingBackend = config.readEntry("Backend", "OpenGL");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic