summaryrefslogtreecommitdiffstats
path: root/src/tdepowersave.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tdepowersave.cpp')
-rw-r--r--src/tdepowersave.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index b57bfef..41ade35 100644
--- a/src/tdepowersave.cpp
+++ b/src/tdepowersave.cpp
@@ -23,6 +23,8 @@
#include <config.h>
#endif
+#include <math.h>
+
// KDE headers:
#include <tdeaboutapplication.h>
#include <tdeapplication.h>
@@ -1073,7 +1075,7 @@ void tdepowersave::do_downDimm() {
if (hwinfo->supportBrightness()) {
if (!AUTODIMM_Timer->isActive()) {
- int dimmToLevel = (int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->autoDimmTo/100.0));
+ int dimmToLevel = (int)round(hwinfo->getMaxBrightnessLevel() * settings->autoDimmTo / 100.0);
// check if we really need to dimm down
if (dimmToLevel < hwinfo->getCurrentBrightnessLevel()) {
@@ -1112,7 +1114,7 @@ void tdepowersave::do_upDimm() {
if (hwinfo->supportBrightness()) {
if (!AUTODIMM_Timer->isActive()) {
- int dimmToLevel = (int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->brightnessValue/100.0));
+ int dimmToLevel = (int)round(hwinfo->getMaxBrightnessLevel() * settings->autoDimmTo / 100.0);
// check if we really need to dimm up
if (dimmToLevel > hwinfo->getCurrentBrightnessLevel()) {
@@ -1153,8 +1155,7 @@ void tdepowersave::do_dimm() {
if (autoDimmDown) {
// dimm the display down
- if (current > 0 &&
- current > ((int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->autoDimmTo/100.0))-1)) {
+ if (current > (int)round(hwinfo->getMaxBrightnessLevel() * settings->autoDimmTo / 100.0)) {
hwinfo->setBrightnessLevel(current -1);
} else {
AUTODIMM_Timer->stop();
@@ -1166,7 +1167,7 @@ void tdepowersave::do_dimm() {
}
} else {
// dimm the display up
- if (current < ((int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->brightnessValue/100.0))-1)) {
+ if (current < (int)round(hwinfo->getMaxBrightnessLevel() * settings->autoDimmTo / 100.0)) {
hwinfo->setBrightnessLevel(current +1);
} else {
AUTODIMM_Timer->stop();
@@ -2938,7 +2939,7 @@ int tdepowersave::brightnessGet() {
int retval = -1;
if (hwinfo->supportBrightness()) {
- retval = (int)(100.0 * hwinfo->getCurrentBrightnessLevel() / hwinfo->getMaxBrightnessLevel());
+ retval = (int)round(100.0 * hwinfo->getCurrentBrightnessLevel() / hwinfo->getMaxBrightnessLevel());
}
kdDebugFuncOut(trace);
@@ -2951,10 +2952,7 @@ void tdepowersave::brightnessSet(int percentage)
{
kdDebugFuncIn(trace);
- if (hwinfo->supportBrightness() && percentage >= 0 && percentage <= 100)
- {
- hwinfo->setBrightnessPercentage(percentage);
- }
+ hwinfo->setBrightnessPercentage(percentage);
kdDebugFuncOut(trace);
}