gnome-power-manager r2771 - in trunk: . src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r2771 - in trunk: . src
- Date: Thu, 10 Apr 2008 12:07:56 +0100 (BST)
Author: rhughes
Date: Thu Apr 10 12:07:56 2008
New Revision: 2771
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2771&view=rev
Log:
2008-04-10 Richard Hughes <richard hughsie com>
reviewed by: <delete if not using a buddy>
* src/gpm-backlight.c: (gpm_backlight_brightness_evaluate_and_set):
Don't let the user supply invalid gconf values to upset the brightness calculation.
* src/gpm-brightness-xrandr.c:
(gpm_brightness_xrandr_output_get_internal),
(gpm_brightness_xrandr_output_set_internal),
(gpm_brightness_xrandr_init):
Fix some warnings in the current code.
Modified:
trunk/ChangeLog
trunk/src/gpm-backlight.c
trunk/src/gpm-brightness-xrandr.c
Modified: trunk/src/gpm-backlight.c
==============================================================================
--- trunk/src/gpm-backlight.c (original)
+++ trunk/src/gpm-backlight.c Thu Apr 10 12:07:56 2008
@@ -377,6 +377,10 @@
gpm_conf_get_bool (backlight->priv->conf, GPM_CONF_BACKLIGHT_BATTERY_REDUCE, &battery_reduce);
if (on_ac == FALSE && battery_reduce == TRUE) {
gpm_conf_get_uint (backlight->priv->conf, GPM_CONF_BACKLIGHT_BRIGHTNESS_BATT, &value);
+ if (value > 100) {
+ gpm_warning ("cannot use battery brightness value %i, correcting to 50", value);
+ value = 50;
+ }
scale = (100 - value) / 100.0f;
brightness *= scale;
} else {
@@ -392,6 +396,10 @@
}
if (enable_action == TRUE && backlight->priv->system_is_idle == TRUE) {
gpm_conf_get_uint (backlight->priv->conf, GPM_CONF_BACKLIGHT_IDLE_BRIGHTNESS, &value);
+ if (value > 100) {
+ gpm_warning ("cannot use idle brightness value %i, correcting to 50", value);
+ value = 50;
+ }
scale = value / 100.0f;
brightness *= scale;
} else {
@@ -431,7 +439,6 @@
/* only show dialog if interactive */
if (interactive == TRUE) {
- gpm_warning ("moo %f", brightness);
gpm_feedback_display_value (backlight->priv->feedback, (float) brightness);
}
Modified: trunk/src/gpm-brightness-xrandr.c
==============================================================================
--- trunk/src/gpm-brightness-xrandr.c (original)
+++ trunk/src/gpm-brightness-xrandr.c Thu Apr 10 12:07:56 2008
@@ -98,9 +98,7 @@
gpm_debug ("failed to get property");
return FALSE;
}
- if (actual_type != XA_INTEGER || nitems != 1 || actual_format != 32) {
- gpm_debug ("wrong format");
- } else {
+ if (actual_type == XA_INTEGER && nitems == 1 && actual_format == 32) {
*cur = *((int *) prop);
ret = TRUE;
}
@@ -114,15 +112,18 @@
static void
gpm_brightness_xrandr_output_set_internal (GpmBrightnessXRandR *brightness, RROutput output, guint value)
{
- int value_int;
g_return_if_fail (GPM_IS_BRIGHTNESS_XRANDR (brightness));
g_return_if_fail (value >= 0);
- value_int = (int) value;
- gpm_debug ("value=%u", value);
+ /* don't abort on error */
+ gdk_error_trap_push ();
XRRChangeOutputProperty (brightness->priv->dpy, output, brightness->priv->backlight, XA_INTEGER, 32,
- PropModeReplace, &value_int, 1);
+ PropModeReplace, (unsigned char *) &value, 1);
XFlush (brightness->priv->dpy);
+ gdk_flush ();
+ if (gdk_error_trap_pop ()) {
+ gpm_warning ("failed to XRRChangeOutputProperty for brightness %i", value);
+ }
}
/**
@@ -543,6 +544,7 @@
{
GdkScreen *screen;
GdkWindow *window;
+ GdkDisplay *display;
int event_base;
int ignore;
@@ -553,12 +555,13 @@
screen = gdk_screen_get_default ();
window = gdk_screen_get_root_window (screen);
+ display = gdk_display_get_default ();
/* as we a filtering by a window, we have to add an event type */
if (!XRRQueryExtension (GDK_DISPLAY(), &event_base, &ignore)) {
gpm_error ("can't get event_base for XRR");
}
- gdk_x11_register_standard_event_type (GDK_DISPLAY(), event_base, RRNotify + 1);
+ gdk_x11_register_standard_event_type (display, event_base, RRNotify + 1);
gdk_window_add_filter (window, gpm_brightness_xrandr_filter_xevents, (gpointer) brightness);
/* don't abort on error */
@@ -568,7 +571,7 @@
RROutputPropertyNotifyMask); /* <--- the only one we need, but see rh:345551 */
gdk_flush ();
if (gdk_error_trap_pop ()) {
- gpm_error ("failed to select XRRSelectInput");
+ gpm_warning ("failed to select XRRSelectInput");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]