support nvidias proprietary refreshrate through asking nvidia-settgins

svn path=/trunk/KDE/kdebase/workspace/; revision=1201396
icc-effect-5.14.5
Thomas Lübking 2010-11-27 15:27:54 +00:00
parent b4b97dde95
commit c7a3a21116
3 changed files with 55 additions and 29 deletions

View File

@ -77,6 +77,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
extern int currentRefreshRate();
//****************************************
// Workspace
//****************************************
@ -195,30 +197,7 @@ void Workspace::setupCompositing()
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

View File

@ -55,6 +55,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
extern int currentRefreshRate();
// ****************************************
// WinInfo
// ****************************************
@ -510,18 +512,16 @@ bool Workspace::workspaceEvent( XEvent * e )
{
#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())
{

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QPalette>
#include <QPixmap>
#include <QProcess>
#include <kapplication.h>
#include <kconfig.h>
#include <kglobal.h>
@ -37,6 +38,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kephal/screens.h>
#ifdef HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
#endif
namespace KWin
@ -44,6 +50,46 @@ 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 @@ void Options::reloadCompositingSettings()
// Compositing settings
CompositingPrefs prefs;
prefs.detect();
rrNvidia = prefs.driver() == "nvidia";
useCompositing = config.readEntry( "Enabled" , prefs.recommendCompositing());
QString compositingBackend = config.readEntry("Backend", "OpenGL");