diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-05-03 19:22:47 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-05-05 16:32:21 +0200 |
commit | cb655c963114dc5744ac0d14b81827f572236fe5 (patch) | |
tree | 5f27caaac85309123932fe0b15ead447ca368456 | |
parent | 1a763e619b10d4e89c12498933cd26fe53e34a52 (diff) | |
download | gnome-settings-daemon-cb655c963114dc5744ac0d14b81827f572236fe5.tar.gz |
power: discretize the set backlight value
Most firmware backlight devices only allow a limited number of
backlight settings (around 10 or 15), but we previously sometime
failed to map the value from outside onto the discrete set of allowed
percentages.
https://bugzilla.gnome.org/show_bug.cgi?id=729500
-rw-r--r-- | plugins/power/gpm-common.c | 14 | ||||
-rw-r--r-- | plugins/power/gpm-common.h | 2 | ||||
-rw-r--r-- | plugins/power/gsd-power-manager.c | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c index a16846e6..dbe610ee 100644 --- a/plugins/power/gpm-common.c +++ b/plugins/power/gpm-common.c @@ -576,7 +576,7 @@ backlight_get_max (GnomeRRScreen *rr_screen, GError **error) gboolean backlight_set_percentage (GnomeRRScreen *rr_screen, - guint value, + gint *value, GError **error) { GnomeRROutput *output; @@ -587,17 +587,23 @@ backlight_set_percentage (GnomeRRScreen *rr_screen, /* prefer xbacklight */ output = get_primary_output (rr_screen); - if (output != NULL) - return gnome_rr_output_set_backlight (output, value, error); + if (output != NULL) { + if (!gnome_rr_output_set_backlight (output, *value, error)) + return ret; + *value = gnome_rr_output_get_backlight (output); + return TRUE; + } /* fall back to the polkit helper */ max = backlight_helper_get_value ("get-max-brightness", error); if (max < 0) return ret; - discrete = PERCENTAGE_TO_ABS (min, max, value); + discrete = PERCENTAGE_TO_ABS (min, max, *value); ret = backlight_helper_set_value ("set-brightness", discrete, error); + if (ret) + *value = ABS_TO_PERCENTAGE (min, max, discrete); return ret; } diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h index 422f1306..675dfeb9 100644 --- a/plugins/power/gpm-common.h +++ b/plugins/power/gpm-common.h @@ -50,7 +50,7 @@ int backlight_get_percentage (GnomeRRScreen *rr_scree int backlight_get_min (GnomeRRScreen *rr_screen); int backlight_get_max (GnomeRRScreen *rr_screen, GError **error); gboolean backlight_set_percentage (GnomeRRScreen *rr_screen, - guint value, + gint *value, GError **error); int backlight_step_up (GnomeRRScreen *rr_screen, GError **error); int backlight_step_down (GnomeRRScreen *rr_screen, GError **error); diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c index 54e37824..d4c15bea 100644 --- a/plugins/power/gsd-power-manager.c +++ b/plugins/power/gsd-power-manager.c @@ -2647,7 +2647,7 @@ handle_set_property_other (GsdPowerManager *manager, if (g_strcmp0 (interface_name, GSD_POWER_DBUS_INTERFACE_SCREEN) == 0) { g_variant_get (value, "i", &brightness_value); - if (backlight_set_percentage (manager->priv->rr_screen, brightness_value, error)) { + if (backlight_set_percentage (manager->priv->rr_screen, &brightness_value, error)) { backlight_iface_emit_changed (manager, GSD_POWER_DBUS_INTERFACE_SCREEN, brightness_value); return TRUE; } else { |