|
|
|
@ -30,6 +30,7 @@
|
|
|
|
|
|
|
|
|
|
// include global header
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
// include QT header
|
|
|
|
|
#include <tqtimer.h>
|
|
|
|
@ -956,7 +957,6 @@ bool HardwareInfo::setBrightnessPercentage(int percent)
|
|
|
|
|
if (trace) kdDebug() << funcinfo << "IN: " << " percent: " << percent << endl;
|
|
|
|
|
|
|
|
|
|
bool retval = false;
|
|
|
|
|
int maxBrightness = getMaxBrightnessLevel();
|
|
|
|
|
|
|
|
|
|
// Use the first backlight in the list
|
|
|
|
|
TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
|
|
|
|
@ -969,22 +969,24 @@ bool HardwareInfo::setBrightnessPercentage(int percent)
|
|
|
|
|
checkBrightness();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure percentage is within valid range
|
|
|
|
|
if (percent < 0) {
|
|
|
|
|
percent = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (percent > 100) {
|
|
|
|
|
percent = 100;
|
|
|
|
|
}
|
|
|
|
|
int level = (int)(maxBrightness * percent / 100.0);
|
|
|
|
|
|
|
|
|
|
if (!brightness) {
|
|
|
|
|
kdError() << "Change brightness not supported " << endl;
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Make sure percentage is within valid range
|
|
|
|
|
if (percent < 0) {
|
|
|
|
|
percent = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (percent > 100) {
|
|
|
|
|
percent = 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int level = (int)round(getMaxBrightnessLevel() * percent / 100.0);
|
|
|
|
|
if (currentBrightnessLevel == level) {
|
|
|
|
|
kdDebug() << "Brightness level not changed, requested level == current level" << endl;
|
|
|
|
|
retval = true;
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
backlightdevice->setRawBrightness(level);
|
|
|
|
|
retval = true;
|
|
|
|
|
}
|
|
|
|
@ -1181,10 +1183,9 @@ bool HardwareInfo::setBrightnessUp(int percentageStep) {
|
|
|
|
|
|
|
|
|
|
checkCurrentBrightness();
|
|
|
|
|
|
|
|
|
|
if (supportBrightness() && getCurrentBrightnessLevel() < getMaxBrightnessLevel() &&
|
|
|
|
|
percentageStep > 0)
|
|
|
|
|
if (supportBrightness() && percentageStep > 0)
|
|
|
|
|
{
|
|
|
|
|
int currentPerc = (int)(100.0 * getCurrentBrightnessLevel() / getMaxBrightnessLevel());
|
|
|
|
|
int currentPerc = (int)round(100.0 * getCurrentBrightnessLevel() / getMaxBrightnessLevel());
|
|
|
|
|
retval = setBrightnessPercentage(currentPerc + percentageStep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1206,8 +1207,8 @@ bool HardwareInfo::setBrightnessDown(int percentageStep) {
|
|
|
|
|
|
|
|
|
|
checkCurrentBrightness();
|
|
|
|
|
|
|
|
|
|
if (supportBrightness() && getCurrentBrightnessLevel() > 0 && percentageStep > 0) {
|
|
|
|
|
int currentPerc = (int)(100.0 * getCurrentBrightnessLevel() / getMaxBrightnessLevel());
|
|
|
|
|
if (supportBrightness() && percentageStep > 0) {
|
|
|
|
|
int currentPerc = (int)round(100.0 * getCurrentBrightnessLevel() / getMaxBrightnessLevel());
|
|
|
|
|
retval = setBrightnessPercentage(currentPerc - percentageStep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1245,7 +1246,7 @@ bool HardwareInfo::getLidclose() const {
|
|
|
|
|
*/
|
|
|
|
|
int HardwareInfo::getMaxBrightnessLevel() const {
|
|
|
|
|
if (brightness)
|
|
|
|
|
return availableBrightnessLevels;
|
|
|
|
|
return availableBrightnessLevels - 1;
|
|
|
|
|
else
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|