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