diff options
Diffstat (limited to 'src/gpm-kbd-backlight.c')
| -rw-r--r-- | src/gpm-kbd-backlight.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c index 7adf0a8..bb7e9c0 100644 --- a/src/gpm-kbd-backlight.c +++ b/src/gpm-kbd-backlight.c @@ -383,6 +383,11 @@ gpm_kbd_backlight_evaluate_power_source_and_set (GpmKbdBacklight *backlight) guint value; guint dim_by = 0; + if (g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_ENABLE) == FALSE) { + g_debug ("policy is no dimming"); + return TRUE; + } + if (up_client_get_on_battery (backlight->priv->client) && g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE)) { dim_by = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT); @@ -440,19 +445,9 @@ gpm_kbd_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmKbdBacklight *backlight) { - static guint saved_brightness = ~0u; + static guint saved_brightness; gboolean ret; - if (saved_brightness == ~0u) { - saved_brightness = backlight->priv->brightness_percent; - /* If the initial value is 0, which probably means we saved on_ac=0, we - * try and restore some arbitrary value for the toggle not to seem - * broken */ - if (saved_brightness == 0) { - saved_brightness = 100u; - } - } - if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_UP) == 0) { ret = gpm_kbd_backlight_brightness_up (backlight); @@ -475,7 +470,13 @@ gpm_kbd_backlight_button_pressed_cb (GpmButton *button, } else if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_TOGGLE) == 0) { if (backlight->priv->brightness_percent == 0) { - /* backlight is off turn it back on */ + /* backlight is off turn it back on. + * If the initial value is 0, which probably means we saved on_ac=0, we + * try and restore some arbitrary value for the toggle not to seem + * broken. */ + if (saved_brightness == 0) { + saved_brightness = 100u; + } gpm_kbd_backlight_set (backlight, saved_brightness, TRUE); } else { /* backlight is on, turn it off and save current value */ |
