From f4cd24c5de6d0e1b23f8770070bf58c6ae3c1c75 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 12 Feb 2013 09:10:03 +0100 Subject: [PATCH] xfpm_backlight_button_pressed_cb: fix popup display With /xfce4-power-manager/change-brightness-on-key-events=false, the level variable is used uninitialized and the popup's level gauge is wrong. Slight Code reformatting included, to avoid duplicating most of the code. --- src/xfpm-backlight.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/xfpm-backlight.c b/src/xfpm-backlight.c index 73bd5f6..bdb9855 100644 --- a/src/xfpm-backlight.c +++ b/src/xfpm-backlight.c @@ -294,22 +294,21 @@ xfpm_backlight_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBa SHOW_BRIGHTNESS_POPUP, &show_popup, NULL); - if ( type == BUTTON_MON_BRIGHTNESS_UP ) + if ( type != BUTTON_MON_BRIGHTNESS_UP && type != BUTTON_MON_BRIGHTNESS_DOWN ) + return; /* sanity check, can this ever happen? */ + + backlight->priv->block = TRUE; + if ( !enable_brightness ) + ret = xfpm_brightness_get_level (backlight->priv->brightness, &level); + else { - backlight->priv->block = TRUE; - if ( enable_brightness ) + if ( type == BUTTON_MON_BRIGHTNESS_UP ) ret = xfpm_brightness_up (backlight->priv->brightness, &level); - if ( ret && show_popup) - xfpm_backlight_show (backlight, level); - } - else if ( type == BUTTON_MON_BRIGHTNESS_DOWN ) - { - backlight->priv->block = TRUE; - if ( enable_brightness ) + else ret = xfpm_brightness_down (backlight->priv->brightness, &level); - if ( ret && show_popup) - xfpm_backlight_show (backlight, level); } + if ( ret && show_popup) + xfpm_backlight_show (backlight, level); } static void -- 1.8.1.2