mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
backend: Reset idletime when unplugging the power cable
Avoid having laptops suspend or lock as soon as the power cable is unplugged as the timeout for those actions when on battery are smaller than the timeouts when on AC. - laptop is plugged in, and hasn't been used for X minutes - laptop is unplugged - the gnome-settings-daemon power plugin sets up its timeouts for inactivity for the "on battery" case - those X minutes of inactivity are still counting, and are above the level of one of the timeouts (say, suspend or lock screen), mutter fires the timeouts - gsd-power activates the action associated with the timeout Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1953 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
This commit is contained in:
parent
14b6c8780d
commit
c789b6be38
@ -181,6 +181,7 @@ struct _MetaBackendPrivate
|
||||
guint upower_watch_id;
|
||||
GDBusProxy *upower_proxy;
|
||||
gboolean lid_is_closed;
|
||||
gboolean on_battery;
|
||||
|
||||
guint sleep_signal_id;
|
||||
GCancellable *cancellable;
|
||||
@ -670,6 +671,23 @@ upower_properties_changed (GDBusProxy *proxy,
|
||||
}
|
||||
}
|
||||
|
||||
v = g_variant_lookup_value (changed_properties,
|
||||
"OnBattery",
|
||||
G_VARIANT_TYPE_BOOLEAN);
|
||||
if (v)
|
||||
{
|
||||
gboolean on_battery;
|
||||
|
||||
on_battery = g_variant_get_boolean (v);
|
||||
g_variant_unref (v);
|
||||
|
||||
if (on_battery != priv->on_battery)
|
||||
{
|
||||
priv->on_battery = on_battery;
|
||||
reset_idle_time = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (reset_idle_time)
|
||||
meta_idle_manager_reset_idle_time (priv->idle_manager);
|
||||
}
|
||||
@ -713,6 +731,13 @@ upower_ready_cb (GObject *source_object,
|
||||
priv->lid_is_closed);
|
||||
}
|
||||
}
|
||||
|
||||
v = g_dbus_proxy_get_cached_property (proxy, "OnBattery");
|
||||
if (v)
|
||||
{
|
||||
priv->on_battery = g_variant_get_boolean (v);
|
||||
g_variant_unref (v);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user