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