[mutter] backends/native: Reset idle time when resuming from suspend
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] backends/native: Reset idle time when resuming from suspend
- Date: Thu, 28 May 2015 12:22:34 +0000 (UTC)
commit b62db404ee33c68f2524c931051f06b980c3b5f0
Author: Rui Matos <tiagomatos gmail com>
Date: Wed May 27 20:10:51 2015 +0200
backends/native: Reset idle time when resuming from suspend
https://bugzilla.gnome.org/show_bug.cgi?id=749994
src/backends/native/meta-backend-native.c | 56 +++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index a14bd4c..e1d66c1 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -42,6 +42,9 @@ struct _MetaBackendNativePrivate
MetaLauncher *launcher;
MetaBarrierManagerNative *barrier_manager;
UpClient *up_client;
+ guint sleep_signal_id;
+ GCancellable *cancellable;
+ GDBusConnection *system_bus;
};
typedef struct _MetaBackendNativePrivate MetaBackendNativePrivate;
@@ -56,11 +59,58 @@ meta_backend_native_finalize (GObject *object)
meta_launcher_free (priv->launcher);
g_object_unref (priv->up_client);
+ if (priv->sleep_signal_id)
+ g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->system_bus);
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
}
static void
+prepare_for_sleep_cb (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ gboolean suspending;
+ g_variant_get (parameters, "(b)", &suspending);
+ if (suspending)
+ return;
+ meta_idle_monitor_native_reset_idletime (meta_idle_monitor_get_core ());
+}
+
+static void
+system_bus_gotten_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ MetaBackendNativePrivate *priv;
+ GDBusConnection *bus;
+
+ bus = g_bus_get_finish (res, NULL);
+ if (!bus)
+ return;
+
+ priv = meta_backend_native_get_instance_private (META_BACKEND_NATIVE (user_data));
+ priv->system_bus = bus;
+ priv->sleep_signal_id = g_dbus_connection_signal_subscribe (priv->system_bus,
+ "org.freedesktop.login1",
+ "org.freedesktop.login1.Manager",
+ "PrepareForSleep",
+ "/org/freedesktop/login1",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ prepare_for_sleep_cb,
+ NULL,
+ NULL);
+}
+
+static void
lid_is_closed_changed_cb (UpClient *client,
GParamSpec *pspec,
gpointer user_data)
@@ -286,6 +336,12 @@ meta_backend_native_init (MetaBackendNative *native)
priv->up_client = up_client_new ();
g_signal_connect (priv->up_client, "notify::lid-is-closed",
G_CALLBACK (lid_is_closed_changed_cb), NULL);
+
+ priv->cancellable = g_cancellable_new ();
+ g_bus_get (G_BUS_TYPE_SYSTEM,
+ priv->cancellable,
+ system_bus_gotten_cb,
+ native);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]