[gnome-settings-daemon/fix-errors-on-kbd-unplug] power: Do not compute percentage on keyboard disappearing




commit 13d403a64f94470c826cf2e60d76a7572b1f75b6
Author: Carlo Caione <carlo endlessm com>
Date:   Wed Jan 3 18:23:25 2018 +0000

    power: Do not compute percentage on keyboard disappearing
    
    When the module in charge of the keyboard backlight is rmmod-ed, upower
    emits a new signal to communicate to gsd that we don't have backlight
    anymore. This signal is carrying (value == -1, max == 0).
    In this case we do not want to calculate the new brightness.
    
    Signed-off-by: Carlo Caione <carlo endlessm com>
    
    Note 2020-09-03: Based on discussion on the Endless bug tracker, the
    steps to reproduce this are to unplug a Filco USB keyboard from a
    Mission One, but perhaps it's applicable on other hardware as well.
    The original PR for this was
    https://github.com/endlessm/gnome-settings-daemon/pull/43
    - mwleeds

 plugins/power/gsd-power-manager.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 0e65bd2a..c6630929 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -1547,10 +1547,12 @@ upower_kbd_proxy_signal_cb (GDBusProxy  *proxy,
                 return;
 
         manager->kbd_brightness_now = brightness;
-        percentage = ABS_TO_PERCENTAGE (0,
-                                        manager->kbd_brightness_max,
-                                        manager->kbd_brightness_now);
-        backlight_iface_emit_changed (manager, GSD_POWER_DBUS_INTERFACE_KEYBOARD, percentage, source);
+        if (brightness != -1) {
+                percentage = ABS_TO_PERCENTAGE (0,
+                                                manager->kbd_brightness_max,
+                                                manager->kbd_brightness_now);
+                backlight_iface_emit_changed (manager, GSD_POWER_DBUS_INTERFACE_KEYBOARD, percentage, 
source);
+        }
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]