[Xfce4-commits] [xfce/xfce4-power-manager] 01/01: Use a reasonable step value for keyboard brightness

noreply at xfce.org noreply at xfce.org
Mon Jun 16 19:59:11 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit eec71db49f61b7c68dd11ab2b078d9d20d0241be
Author: Carl Simonson <simonsonc at gmail.com>
Date:   Thu Jun 5 20:52:15 2014 -0500

    Use a reasonable step value for keyboard brightness
    
    Some keyboard brightness controllers have different ranges for levels.
    Some have a few discreet values. Others are more like a percent. This
    change uses a step based on the maximum level. If less than 20, use 1.
    Else, divide by 20.
    
    This logic is the same as used in gnome-settings-daemon. It comes from
    the BRIGHTNESS_STEP_AMOUND macro in plugins/power/gpm-common.h.
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 src/xfpm-kbd-backlight.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/xfpm-kbd-backlight.c b/src/xfpm-kbd-backlight.c
index d37a8b4..a55aeec 100644
--- a/src/xfpm-kbd-backlight.c
+++ b/src/xfpm-kbd-backlight.c
@@ -60,6 +60,16 @@ struct XfpmKbdBacklightPrivate
 G_DEFINE_TYPE (XfpmKbdBacklight, xfpm_kbd_backlight, G_TYPE_OBJECT)
 
 
+static gint
+calculate_step( gint max_level )
+{
+    if ( max_level < 20 )
+        return 1;
+    else
+        return max_level / 20;
+}
+
+
 static void
 xfpm_kbd_backlight_on_battery_changed_cb (XfpmPower *power, gboolean on_battery, XfpmKbdBacklight *backlight)
 {
@@ -265,7 +275,7 @@ xfpm_kbd_backlight_init (XfpmKbdBacklight *backlight)
     if ( backlight->priv->max_level == 0 )
         goto out;
 
-    backlight->priv->step = backlight->priv->max_level / 5;
+    backlight->priv->step = calculate_step (backlight->priv->max_level);
     backlight->priv->power = xfpm_power_get ();
     backlight->priv->button = xfpm_button_new ();
     backlight->priv->notify = xfpm_notify_new ();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list