gnome-power-manager r2789 - in trunk: . src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r2789 - in trunk: . src
- Date: Fri, 9 May 2008 12:50:58 +0100 (BST)
Author: rhughes
Date: Fri May 9 11:50:58 2008
New Revision: 2789
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2789&view=rev
Log:
2008-05-09 Richard Hughes <richard hughsie com>
* src/gpm-brightness-hal.c: (gpm_brightness_hal_dim_hw),
(gpm_brightness_hal_up), (gpm_brightness_hal_down):
* src/gpm-brightness-xrandr.c: (gpm_brightness_xrandr_output_down),
(gpm_brightness_xrandr_output_up), (gpm_brightness_xrandr_up),
(gpm_brightness_xrandr_down):
* src/gpm-brightness.c: (gpm_brightness_get_step):
* src/gpm-brightness.h:
Use the same logic for xrandr as hal when we have a large number of brightness steps.
Modified:
trunk/ChangeLog
trunk/src/gpm-brightness-hal.c
trunk/src/gpm-brightness-xrandr.c
trunk/src/gpm-brightness.c
trunk/src/gpm-brightness.h
Modified: trunk/src/gpm-brightness-hal.c
==============================================================================
--- trunk/src/gpm-brightness-hal.c (original)
+++ trunk/src/gpm-brightness-hal.c Fri May 9 11:50:58 2008
@@ -224,30 +224,6 @@
}
/**
- * gpm_brightness_hal_get_step:
- * @brightness: This brightness class instance
- * Return value: the amount of hardware steps to do on each update or
- * zero for error.
- **/
-static guint
-gpm_brightness_hal_get_step (GpmBrightnessHal *brightness)
-{
- int step;
-
- g_return_val_if_fail (brightness != NULL, 0);
- g_return_val_if_fail (GPM_IS_BRIGHTNESS_HAL (brightness), 0);
-
- if (brightness->priv->levels < 20) {
- /* less than 20 states should do every state */
- step = 1;
- } else {
- /* macbook pro has a bazzillion brightness levels, do in 5% steps */
- step = brightness->priv->levels / 20;
- }
- return step;
-}
-
-/**
* gpm_brightness_hal_dim_hw:
* @brightness: This brightness class instance
* @new_level_hw: The new hardware level
@@ -262,7 +238,7 @@
gpm_debug ("new_level_hw=%i", new_level_hw);
/* macbook pro has a bazzillion brightness levels, be a bit clever */
- step = gpm_brightness_hal_get_step (brightness);
+ step = gpm_brightness_get_step (brightness->priv->levels);
return gpm_brightness_hal_dim_hw_step (brightness, new_level_hw, step);
}
@@ -343,7 +319,7 @@
brightness->priv->last_set_hw = current_hw;
} else {
/* macbook pro has a bazzillion brightness levels, be a bit clever */
- step = gpm_brightness_hal_get_step (brightness);
+ step = gpm_brightness_get_step (brightness->priv->levels);
/* don't overflow */
if (brightness->priv->last_set_hw + step > brightness->priv->levels - 1) {
step = (brightness->priv->levels - 1) - brightness->priv->last_set_hw;
@@ -385,7 +361,7 @@
gpm_brightness_hal_get_hw (brightness, &brightness->priv->last_set_hw);
} else {
/* macbook pro has a bazzillion brightness levels, be a bit clever */
- step = gpm_brightness_hal_get_step (brightness);
+ step = gpm_brightness_get_step (brightness->priv->levels);
/* don't underflow */
if (brightness->priv->last_set_hw < step) {
step = brightness->priv->last_set_hw;
Modified: trunk/src/gpm-brightness-xrandr.c
==============================================================================
--- trunk/src/gpm-brightness-xrandr.c (original)
+++ trunk/src/gpm-brightness-xrandr.c Fri May 9 11:50:58 2008
@@ -250,7 +250,7 @@
gpm_debug ("already min");
return TRUE;
}
- cur -= brightness->priv->shared_value;
+ cur -= gpm_brightness_get_step ((max-min)+1);
if (cur < min) {
gpm_debug ("truncating to %i", min);
cur = min;
@@ -284,7 +284,7 @@
gpm_debug ("already max");
return TRUE;
}
- cur += brightness->priv->shared_value;
+ cur += gpm_brightness_get_step ((max-min)+1);
if (cur > max) {
gpm_debug ("truncating to %i", max);
cur = max;
@@ -487,9 +487,6 @@
g_return_val_if_fail (GPM_IS_BRIGHTNESS_XRANDR (brightness), FALSE);
g_return_val_if_fail (hw_changed != NULL, FALSE);
- /* single step */
- brightness->priv->shared_value = 1;
-
/* reset to not-changed */
brightness->priv->hw_changed = FALSE;
ret = gpm_brightness_xrandr_foreach_screen (brightness, ACTION_BACKLIGHT_INC);
@@ -515,9 +512,6 @@
g_return_val_if_fail (GPM_IS_BRIGHTNESS_XRANDR (brightness), FALSE);
g_return_val_if_fail (hw_changed != NULL, FALSE);
- /* single step */
- brightness->priv->shared_value = 1;
-
/* reset to not-changed */
brightness->priv->hw_changed = FALSE;
ret = gpm_brightness_xrandr_foreach_screen (brightness, ACTION_BACKLIGHT_DEC);
Modified: trunk/src/gpm-brightness.c
==============================================================================
--- trunk/src/gpm-brightness.c (original)
+++ trunk/src/gpm-brightness.c Fri May 9 11:50:58 2008
@@ -66,6 +66,21 @@
static gpointer gpm_brightness_object = NULL;
/**
+ * gpm_brightness_get_step:
+ * @levels: The number of levels supported
+ * Return value: the amount of hardware steps to do on each increment or decrement
+ **/
+guint
+gpm_brightness_get_step (guint levels)
+{
+ if (levels > 20) {
+ /* macbook pro has a bazzillion brightness levels, do in 5% steps */
+ return levels / 20;
+ }
+ return 1;
+}
+
+/**
* gpm_brightness_trust_cache:
* @brightness: This brightness class instance
* Return value: if we can trust the cache
Modified: trunk/src/gpm-brightness.h
==============================================================================
--- trunk/src/gpm-brightness.h (original)
+++ trunk/src/gpm-brightness.h Fri May 9 11:50:58 2008
@@ -64,6 +64,9 @@
guint percentage,
gboolean *hw_changed);
+/* not designed to be used outside of gpm-brightness-*.c */
+guint gpm_brightness_get_step (guint levels);
+
G_END_DECLS
#endif /* __GPM_BRIGHTNESS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]