summaryrefslogtreecommitdiff
path: root/src/gpm-common.c
diff options
context:
space:
mode:
authorMartin Wimpress <[email protected]>2015-07-28 14:47:01 +0100
committerMartin Wimpress <[email protected]>2015-07-28 14:47:01 +0100
commit0d50ed798d6c52977d557a2d6857a8f4318ccda1 (patch)
treee93e99739802f0097482c08c730cc17d206b99b6 /src/gpm-common.c
parent17f44d0183ab7ac083dc9800b2c44c65f1f789e3 (diff)
parent8352686d856b164432732668afed24f248c17323 (diff)
downloadmate-power-manager-0d50ed798d6c52977d557a2d6857a8f4318ccda1.tar.bz2
mate-power-manager-0d50ed798d6c52977d557a2d6857a8f4318ccda1.tar.xz
Merge pull request #157 from mesouug/master
Unable to change keyboard back light #108
Diffstat (limited to 'src/gpm-common.c')
-rw-r--r--src/gpm-common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gpm-common.c b/src/gpm-common.c
index f71aada..c0c3c94 100644
--- a/src/gpm-common.c
+++ b/src/gpm-common.c
@@ -91,6 +91,9 @@ gpm_get_timestring (guint time_secs)
guint
gpm_discrete_from_percent (guint percentage, guint levels)
{
+ /* for levels < 10 min value is 0 */
+ gint factor;
+ factor = levels < 10 ? 0 : 1;
/* check we are in range */
if (percentage > 100)
return levels;
@@ -98,7 +101,7 @@ gpm_discrete_from_percent (guint percentage, guint levels)
g_warning ("levels is 0!");
return 0;
}
- return (guint) ((((gfloat) percentage * (gfloat) (levels - 1)) / 100.0f) + 0.5f);
+ return (guint) ((((gfloat) percentage * (gfloat) (levels - factor)) / 100.0f) + 0.5f);
}
/**
@@ -113,6 +116,9 @@ gpm_discrete_from_percent (guint percentage, guint levels)
guint
gpm_discrete_to_percent (guint discrete, guint levels)
{
+ /* for levels < 10 min value is 0 */
+ gint factor;
+ factor = levels < 10 ? 0 : 1;
/* check we are in range */
if (discrete > levels)
return 100;
@@ -120,7 +126,7 @@ gpm_discrete_to_percent (guint discrete, guint levels)
g_warning ("levels is 0!");
return 0;
}
- return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - 1))) + 0.5f);
+ return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - factor))) + 0.5f);
}