backlight: Fix incr/decr with percent value of 0
This now does nothing instead of incr/decr by 10% MFC After: 3 days PR: 253736
This commit is contained in:
parent
5842073a9b
commit
3b005d51bd
@ -98,7 +98,7 @@ main(int argc, char *argv[])
|
|||||||
BACKLIGHTGETSTATUS,
|
BACKLIGHTGETSTATUS,
|
||||||
BACKLIGHTUPDATESTATUS,
|
BACKLIGHTUPDATESTATUS,
|
||||||
BACKLIGHTGETINFO};
|
BACKLIGHTGETINFO};
|
||||||
long percent = 0;
|
long percent = -1;
|
||||||
const char *percent_error;
|
const char *percent_error;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
bool setname;
|
bool setname;
|
||||||
@ -188,15 +188,20 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BACKLIGHT_SET_BRIGHTNESS:
|
case BACKLIGHT_SET_BRIGHTNESS:
|
||||||
|
if (percent == -1)
|
||||||
|
usage();
|
||||||
props.brightness = percent;
|
props.brightness = percent;
|
||||||
if (ioctl(fd, BACKLIGHTUPDATESTATUS, &props) == -1)
|
if (ioctl(fd, BACKLIGHTUPDATESTATUS, &props) == -1)
|
||||||
errx(1, "Cannot update the backlight device");
|
errx(1, "Cannot update the backlight device");
|
||||||
break;
|
break;
|
||||||
case BACKLIGHT_INCR:
|
case BACKLIGHT_INCR:
|
||||||
case BACKLIGHT_DECR:
|
case BACKLIGHT_DECR:
|
||||||
|
if (percent == 0)
|
||||||
|
/* Avoid any ioctl if we don't have anything to do */
|
||||||
|
break;
|
||||||
if (ioctl(fd, BACKLIGHTGETSTATUS, &props) == -1)
|
if (ioctl(fd, BACKLIGHTGETSTATUS, &props) == -1)
|
||||||
errx(1, "Cannot query the backlight device");
|
errx(1, "Cannot query the backlight device");
|
||||||
percent = percent == 0 ? 10 : percent;
|
percent = percent == -1 ? 10 : percent;
|
||||||
percent = action == BACKLIGHT_INCR ? percent : -percent;
|
percent = action == BACKLIGHT_INCR ? percent : -percent;
|
||||||
props.brightness += percent;
|
props.brightness += percent;
|
||||||
if ((int)props.brightness < 0)
|
if ((int)props.brightness < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user