mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 07:30:42 -05:00
backend: Refactor "lid-is-closed" handling code
We'll need to handle another property in the same place, so refactor the code to allow falling-through to handle another property. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
This commit is contained in:
parent
e38db1237d
commit
14b6c8780d
@ -647,28 +647,31 @@ upower_properties_changed (GDBusProxy *proxy,
|
|||||||
MetaBackend *backend = user_data;
|
MetaBackend *backend = user_data;
|
||||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
GVariant *v;
|
GVariant *v;
|
||||||
gboolean lid_is_closed;
|
gboolean reset_idle_time = FALSE;
|
||||||
|
|
||||||
v = g_variant_lookup_value (changed_properties,
|
v = g_variant_lookup_value (changed_properties,
|
||||||
"LidIsClosed",
|
"LidIsClosed",
|
||||||
G_VARIANT_TYPE_BOOLEAN);
|
G_VARIANT_TYPE_BOOLEAN);
|
||||||
if (!v)
|
if (v)
|
||||||
return;
|
{
|
||||||
|
gboolean lid_is_closed;
|
||||||
|
|
||||||
lid_is_closed = g_variant_get_boolean (v);
|
lid_is_closed = g_variant_get_boolean (v);
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
|
|
||||||
if (lid_is_closed == priv->lid_is_closed)
|
if (lid_is_closed != priv->lid_is_closed)
|
||||||
return;
|
{
|
||||||
|
priv->lid_is_closed = lid_is_closed;
|
||||||
|
g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
|
||||||
|
priv->lid_is_closed);
|
||||||
|
|
||||||
priv->lid_is_closed = lid_is_closed;
|
if (lid_is_closed)
|
||||||
g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
|
reset_idle_time = TRUE;
|
||||||
priv->lid_is_closed);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lid_is_closed)
|
if (reset_idle_time)
|
||||||
return;
|
meta_idle_manager_reset_idle_time (priv->idle_manager);
|
||||||
|
|
||||||
meta_idle_manager_reset_idle_time (priv->idle_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -699,15 +702,16 @@ upower_ready_cb (GObject *source_object,
|
|||||||
G_CALLBACK (upower_properties_changed), backend);
|
G_CALLBACK (upower_properties_changed), backend);
|
||||||
|
|
||||||
v = g_dbus_proxy_get_cached_property (proxy, "LidIsClosed");
|
v = g_dbus_proxy_get_cached_property (proxy, "LidIsClosed");
|
||||||
if (!v)
|
if (v)
|
||||||
return;
|
|
||||||
priv->lid_is_closed = g_variant_get_boolean (v);
|
|
||||||
g_variant_unref (v);
|
|
||||||
|
|
||||||
if (priv->lid_is_closed)
|
|
||||||
{
|
{
|
||||||
g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
|
priv->lid_is_closed = g_variant_get_boolean (v);
|
||||||
priv->lid_is_closed);
|
g_variant_unref (v);
|
||||||
|
|
||||||
|
if (priv->lid_is_closed)
|
||||||
|
{
|
||||||
|
g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
|
||||||
|
priv->lid_is_closed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user