[gnome-settings-daemon/gnome-3-30] power: Guard against events from the wrong device type
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-30] power: Guard against events from the wrong device type
- Date: Wed, 26 Sep 2018 11:09:40 +0000 (UTC)
commit fa745cd54e31da8f13acc9479bcf9378c857a22c
Author: Benjamin Berg <bberg redhat com>
Date: Mon Sep 3 15:16:12 2018 +0200
power: Guard against events from the wrong device type
If a new device is added, then the warning level callback is called
unconditionally. Because of this, it could happen that an external
device (like a mouse) could cause the low battery mode in gsd-power to
be entered. In particular, this will result in the screen to be dimmed
very agressively.
Fixes issue #83
plugins/power/gsd-power-manager.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 67d475cf..cad55637 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -340,14 +340,19 @@ engine_ups_discharging (GsdPowerManager *manager, UpDevice *device)
char *icon_name;
gint64 time_to_empty;
GString *message;
+ UpDeviceKind kind;
/* get device properties */
g_object_get (device,
+ "kind", &kind,
"percentage", &percentage,
"time-to-empty", &time_to_empty,
"icon-name", &icon_name,
NULL);
+ if (kind != UP_DEVICE_KIND_UPS)
+ return;
+
/* only show text if there is a valid time */
if (time_to_empty > 0)
remaining_text = gpm_get_timestring (time_to_empty);
@@ -790,8 +795,12 @@ static void
engine_device_warning_changed_cb (UpDevice *device, GParamSpec *pspec, GsdPowerManager *manager)
{
UpDeviceLevel warning;
+ UpDeviceKind kind;
- g_object_get (device, "warning-level", &warning, NULL);
+ g_object_get (device,
+ "warning-level", &warning,
+ "kind", &kind,
+ NULL);
if (warning == UP_DEVICE_LEVEL_DISCHARGING) {
g_debug ("** EMIT: discharging");
@@ -814,7 +823,9 @@ engine_device_warning_changed_cb (UpDevice *device, GParamSpec *pspec, GsdPowerM
notify_close_if_showing (&manager->priv->notification_ups_discharging);
}
- main_battery_or_ups_low_changed (manager, (warning != UP_DEVICE_LEVEL_NONE));
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_UPS)
+ main_battery_or_ups_low_changed (manager, (warning != UP_DEVICE_LEVEL_NONE));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]