summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrej Valek <[email protected]>2020-04-19 19:16:55 +0200
committerraveit65 <[email protected]>2020-05-25 15:31:45 +0200
commita926d698616666c52586b5778b8cf7fd9ced5b96 (patch)
tree022b401b9ca94c4e7e338946c4a9f5284e659550
parente564d451d9646a7bfefe59b1a70caae1b6162743 (diff)
downloadmate-power-manager-a926d698616666c52586b5778b8cf7fd9ced5b96.tar.bz2
mate-power-manager-a926d698616666c52586b5778b8cf7fd9ced5b96.tar.xz
gpm-kbd-backlight: do not change keyboard back-light, when disabled
Automatically change keyboard back-light only when enabled on battery. Keep previous brightness level between state change. Signed-off-by: Andrej Valek <[email protected]>
-rw-r--r--src/gpm-kbd-backlight.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c
index 6f363e8..4f5a69b 100644
--- a/src/gpm-kbd-backlight.c
+++ b/src/gpm-kbd-backlight.c
@@ -444,18 +444,24 @@ gpm_kbd_backlight_evaluate_power_source_and_set (GpmKbdBacklight *backlight)
battery_reduce = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE);
- if (on_battery && battery_reduce) {
- value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT);
+ if (on_battery) {
+ if (battery_reduce) {
+ value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT);
- if (value > 100) {
- g_warning ("Cannot scale brightness down by more than 100%%. Scaling by 50%%");
- value = 50;
- }
+ if (value > 100) {
+ g_warning ("Cannot scale brightness down by more than 100%%. Scaling by 50%%");
+ value = 50;
+ }
- scale = (100 - value) / 100.0f;
- brightness *= scale;
+ scale = (100 - value) / 100.0f;
+ brightness *= scale;
- value = (guint) brightness;
+ value = (guint) brightness;
+
+ } else {
+ // do not change keyboard backlight
+ return TRUE;
+ }
} else {
value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_ON_AC);
@@ -584,6 +590,7 @@ gpm_kbd_backlight_idle_changed_cb (GpmIdle *idle,
enable_action = on_battery
? g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT)
+ && g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE)
: g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_AC);
if (!enable_action)