support nvidias proprietary refreshrate through asking nvidia-settgins
svn path=/trunk/KDE/kdebase/workspace/; revision=1201396
This commit is contained in:
parent
b4b97dde95
commit
c7a3a21116
3 changed files with 55 additions and 29 deletions
|
@ -77,6 +77,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
extern int currentRefreshRate();
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// Workspace
|
// Workspace
|
||||||
//****************************************
|
//****************************************
|
||||||
|
@ -195,30 +197,7 @@ void Workspace::setupCompositing()
|
||||||
delete cm_selection;
|
delete cm_selection;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int rate = 0;
|
int rate = xrrRefreshRate = KWin::currentRefreshRate();
|
||||||
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";
|
|
||||||
compositeRate = 1000 / rate;
|
compositeRate = 1000 / rate;
|
||||||
lastCompositePaint.start();
|
lastCompositePaint.start();
|
||||||
// fake a previous paint, so that the next starts right now
|
// fake a previous paint, so that the next starts right now
|
||||||
|
|
10
events.cpp
10
events.cpp
|
@ -55,6 +55,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
extern int currentRefreshRate();
|
||||||
|
|
||||||
// ****************************************
|
// ****************************************
|
||||||
// WinInfo
|
// WinInfo
|
||||||
// ****************************************
|
// ****************************************
|
||||||
|
@ -510,18 +512,16 @@ bool Workspace::workspaceEvent( XEvent * e )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
XRRUpdateConfiguration( e );
|
XRRUpdateConfiguration( e );
|
||||||
|
#endif
|
||||||
if( compositing() )
|
if( compositing() )
|
||||||
{
|
{
|
||||||
// desktopResized() should take care of when the size or
|
// desktopResized() should take care of when the size or
|
||||||
// shape of the desktop has changed, but we also want to
|
// shape of the desktop has changed, but we also want to
|
||||||
// catch refresh rate changes
|
// catch refresh rate changes
|
||||||
XRRScreenConfiguration *config = XRRGetScreenInfo( display(), rootWindow() );
|
if( xrrRefreshRate != currentRefreshRate() )
|
||||||
bool changed = ( xrrRefreshRate != XRRConfigCurrentRate( config ));
|
|
||||||
XRRFreeScreenConfigInfo( config );
|
|
||||||
if( changed )
|
|
||||||
compositeResetTimer.start( 0 );
|
compositeResetTimer.start( 0 );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if( e->type == Extensions::syncAlarmNotifyEvent() && Extensions::syncAvailable())
|
else if( e->type == Extensions::syncAlarmNotifyEvent() && Extensions::syncAvailable())
|
||||||
{
|
{
|
||||||
|
|
47
options.cpp
47
options.cpp
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QProcess>
|
||||||
#include <kapplication.h>
|
#include <kapplication.h>
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
|
@ -37,6 +38,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <kephal/screens.h>
|
#include <kephal/screens.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_XRANDR
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -44,6 +50,46 @@ namespace KWin
|
||||||
|
|
||||||
#ifndef KCMRULES
|
#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()
|
Options::Options()
|
||||||
: electric_borders( 0 )
|
: electric_borders( 0 )
|
||||||
, electric_border_delay( 0 )
|
, electric_border_delay( 0 )
|
||||||
|
@ -248,6 +294,7 @@ void Options::reloadCompositingSettings()
|
||||||
// Compositing settings
|
// Compositing settings
|
||||||
CompositingPrefs prefs;
|
CompositingPrefs prefs;
|
||||||
prefs.detect();
|
prefs.detect();
|
||||||
|
rrNvidia = prefs.driver() == "nvidia";
|
||||||
useCompositing = config.readEntry( "Enabled" , prefs.recommendCompositing());
|
useCompositing = config.readEntry( "Enabled" , prefs.recommendCompositing());
|
||||||
|
|
||||||
QString compositingBackend = config.readEntry("Backend", "OpenGL");
|
QString compositingBackend = config.readEntry("Backend", "OpenGL");
|
||||||
|
|
Loading…
Reference in a new issue