@ -150,7 +150,8 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
BAT_WARN_ICON_Timer = new TQTimer ( this ) ;
connect ( BAT_WARN_ICON_Timer , TQT_SIGNAL ( timeout ( ) ) , this , TQT_SLOT ( do_setIconBG ( ) ) ) ;
AUTODIMM_Timer = new TQTimer ( this ) ;
m_autoDimmTimer = new TQTimer ( this ) ;
connect ( m_autoDimmTimer , TQT_SIGNAL ( timeout ( ) ) , this , TQT_SLOT ( do_dimm ( ) ) ) ;
initMenu ( ) ;
update ( ) ;
@ -169,6 +170,7 @@ tdepowersave::~tdepowersave(){
delete display ;
delete settings ;
delete autoSuspend ;
delete m_autoDimmTimer ;
# ifdef ENABLE_YAST_ENTRY
delete yast2 ;
# endif
@ -1074,25 +1076,22 @@ void tdepowersave::do_downDimm() {
kdDebugFuncIn ( trace ) ;
if ( hwinfo - > supportBrightness ( ) ) {
if ( ! AUTODIMM_ Timer- > isActive ( ) ) {
if ( ! m_autoDimm Timer- > isActive ( ) ) {
int dimmToLevel = ( int ) round ( hwinfo - > getMaxBrightnessLevel ( ) * settings - > autoDimmTo / 100.0 ) ;
// check if we really need to dimm down
if ( dimmToLevel < hwinfo - > getCurrentBrightnessLevel ( ) ) {
int steps = hwinfo - > getCurrentBrightnessLevel ( ) - dimmToLevel ;
int timePerStep = ( 1500 / steps ) ;
m_dimmRequestedLevel = dimmToLevel ;
m_dimmStep = ( hwinfo - > getCurrentBrightnessLevel ( ) - dimmToLevel ) / 10 + 1 ;
m_dimmTimeoutCounter = 0 ;
autoDimmDown = true ;
AUTODIMM_Timer = new TQTimer ( this ) ;
connect ( AUTODIMM_Timer , TQT_SIGNAL ( timeout ( ) ) , this , TQT_SLOT ( do_dimm ( ) ) ) ;
AUTODIMM_Timer - > start ( timePerStep , false ) ;
m_autoDimmTimer - > start ( 100 , false ) ;
} else {
kdWarning ( ) < < " Don't dimm down, current level is already lower than requested Level " < < endl ;
}
} else {
// wait until the timer is stopped, try later!
TQTimer : : singleShot ( 15 00, this , TQT_SLOT ( do_downDimm ( ) ) ) ;
TQTimer : : singleShot ( 20 00, this , TQT_SLOT ( do_downDimm ( ) ) ) ;
}
}
@ -1113,28 +1112,24 @@ void tdepowersave::do_upDimm() {
//NOTE we go back to the value of the scheme and not the last on, to reduce trouble with the scheme
if ( hwinfo - > supportBrightness ( ) ) {
if ( ! AUTODIMM_ Timer- > isActive ( ) ) {
int dimmToLevel = ( int ) round ( hwinfo - > getMaxBrightnessLevel ( ) * settings - > autoDimmTo / 100.0 ) ;
if ( ! m_autoDimm Timer- > isActive ( ) ) {
int dimmToLevel = ( int ) round ( hwinfo - > getMaxBrightnessLevel ( ) * settings - > brightnessValue / 100.0 ) ;
// check if we really need to dimm up
if ( dimmToLevel > hwinfo - > getCurrentBrightnessLevel ( ) ) {
int steps = dimmToLevel - hwinfo - > getCurrentBrightnessLevel ( ) ;
int timePerStep = ( 750 / steps ) ;
m_dimmRequestedLevel = dimmToLevel ;
m_dimmStep = ( dimmToLevel - hwinfo - > getCurrentBrightnessLevel ( ) ) / 10 + 1 ;
m_dimmTimeoutCounter = 0 ;
autoDimmDown = false ;
AUTODIMM_Timer = new TQTimer ( this ) ;
connect ( AUTODIMM_Timer , TQT_SIGNAL ( timeout ( ) ) , this , TQT_SLOT ( do_dimm ( ) ) ) ;
AUTODIMM_Timer - > start ( timePerStep , false ) ;
// start autodimm again
setAutoDimm ( false ) ;
m_autoDimmTimer - > start ( 100 , false ) ;
} else {
kdWarning ( ) < < " Don't dimm up, current level is already above requested Level " < < endl ;
}
// start autodimm again
setAutoDimm ( false ) ;
} else {
// wait until the timer is stopped, try later!
TQTimer : : singleShot ( 75 0, this , TQT_SLOT ( do_downDimm ( ) ) ) ;
TQTimer : : singleShot ( 200 0, this , TQT_SLOT ( do_downDimm ( ) ) ) ;
}
}
@ -1151,14 +1146,22 @@ void tdepowersave::do_upDimm() {
void tdepowersave : : do_dimm ( ) {
kdDebugFuncIn ( trace ) ;
if ( m_dimmStep < = 0 | | m_dimmTimeoutCounter > 30 )
{
m_autoDimmTimer - > stop ( ) ;
return ;
}
+ + m_dimmTimeoutCounter ;
int current = hwinfo - > getCurrentBrightnessLevel ( ) ;
if ( autoDimmDown ) {
// dimm the display down
if ( current > ( int ) round ( hwinfo - > getMaxBrightnessLevel ( ) * settings - > autoDimmTo / 100.0 ) ) {
hwinfo - > setBrightnessLevel ( current - 1 ) ;
if ( current > 0 & & current > ( m_dimmRequestedLevel * 1.005 ) ) {
hwinfo - > setBrightnessLevel ( current - m_dimmStep ) ;
} else {
AUTODIMM_Timer - > stop ( ) ;
m_autoDimmTimer - > stop ( ) ;
m_dimmStep = 0 ;
// start checking if the user get active again
// NOTE: we start this here because the X-Server detect brightness changes as
@ -1167,10 +1170,11 @@ void tdepowersave::do_dimm() {
}
} else {
// dimm the display up
if ( current < ( int ) round ( hwinfo - > getMaxBrightnessLevel ( ) * settings - > autoDimmTo / 100.0 ) ) {
hwinfo - > setBrightnessLevel ( current + 1 ) ;
if ( current < ( m_dimmRequestedLevel * 0.995 ) ) {
hwinfo - > setBrightnessLevel ( current + m_dimmStep ) ;
} else {
AUTODIMM_Timer - > stop ( ) ;
m_autoDimmTimer - > stop ( ) ;
m_dimmStep = 0 ;
}
}