|
|
1c7749 |
From 9f566208d584ec4d8da797390b6806157c7d2402 Mon Sep 17 00:00:00 2001
|
|
|
1c7749 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
1c7749 |
Date: Thu, 10 Jan 2019 10:47:19 -0500
|
|
|
1c7749 |
Subject: [PATCH 3/9] backend: add signals for reporting suspend and resume
|
|
|
1c7749 |
|
|
|
1c7749 |
This commit adds "suspending" and "resuming" signals
|
|
|
1c7749 |
to MetaBackend.
|
|
|
1c7749 |
|
|
|
1c7749 |
It's preliminary work needed for tracking when to purge
|
|
|
1c7749 |
and recreate all textures (needed by nvidia).
|
|
|
1c7749 |
---
|
|
|
1c7749 |
src/backends/meta-backend.c | 83 ++++++++++++++++++++++++++++++++-----
|
|
|
1c7749 |
1 file changed, 72 insertions(+), 11 deletions(-)
|
|
|
1c7749 |
|
|
|
1c7749 |
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
|
|
|
1c7749 |
index 5d71977c6..c980cf150 100644
|
|
|
1c7749 |
--- a/src/backends/meta-backend.c
|
|
|
1c7749 |
+++ b/src/backends/meta-backend.c
|
|
|
1c7749 |
@@ -87,6 +87,8 @@ enum
|
|
|
1c7749 |
LAST_DEVICE_CHANGED,
|
|
|
1c7749 |
LID_IS_CLOSED_CHANGED,
|
|
|
1c7749 |
|
|
|
1c7749 |
+ SUSPENDING,
|
|
|
1c7749 |
+ RESUMING,
|
|
|
1c7749 |
N_SIGNALS
|
|
|
1c7749 |
};
|
|
|
1c7749 |
|
|
|
1c7749 |
@@ -745,6 +747,20 @@ meta_backend_class_init (MetaBackendClass *klass)
|
|
|
1c7749 |
0,
|
|
|
1c7749 |
NULL, NULL, NULL,
|
|
|
1c7749 |
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
|
|
1c7749 |
+ signals[SUSPENDING] =
|
|
|
1c7749 |
+ g_signal_new ("suspending",
|
|
|
1c7749 |
+ G_TYPE_FROM_CLASS (object_class),
|
|
|
1c7749 |
+ G_SIGNAL_RUN_LAST,
|
|
|
1c7749 |
+ 0,
|
|
|
1c7749 |
+ NULL, NULL, NULL,
|
|
|
1c7749 |
+ G_TYPE_NONE, 0);
|
|
|
1c7749 |
+ signals[RESUMING] =
|
|
|
1c7749 |
+ g_signal_new ("resuming",
|
|
|
1c7749 |
+ G_TYPE_FROM_CLASS (object_class),
|
|
|
1c7749 |
+ G_SIGNAL_RUN_LAST,
|
|
|
1c7749 |
+ 0,
|
|
|
1c7749 |
+ NULL, NULL, NULL,
|
|
|
1c7749 |
+ G_TYPE_NONE, 0);
|
|
|
1c7749 |
|
|
|
1c7749 |
mutter_stage_views = g_getenv ("MUTTER_STAGE_VIEWS");
|
|
|
1c7749 |
stage_views_disabled = g_strcmp0 (mutter_stage_views, "0") == 0;
|
|
|
1c7749 |
@@ -768,15 +784,53 @@ meta_backend_create_renderer (MetaBackend *backend,
|
|
|
1c7749 |
return META_BACKEND_GET_CLASS (backend)->create_renderer (backend, error);
|
|
|
1c7749 |
}
|
|
|
1c7749 |
|
|
|
1c7749 |
+static void
|
|
|
1c7749 |
+inhibit_sleep (MetaBackend *backend)
|
|
|
1c7749 |
+{
|
|
|
1c7749 |
+ MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
1c7749 |
+ g_autoptr (GVariant) fd_variant = NULL;
|
|
|
1c7749 |
+ g_autoptr (GError) error = NULL;
|
|
|
1c7749 |
+
|
|
|
1c7749 |
+ if (priv->inhibit_sleep_fd >= 0)
|
|
|
1c7749 |
+ return;
|
|
|
1c7749 |
+
|
|
|
1c7749 |
+ if (!login1_manager_call_inhibit_sync (priv->logind_proxy,
|
|
|
1c7749 |
+ "sleep",
|
|
|
1c7749 |
+ "Display Server",
|
|
|
1c7749 |
+ "Prepare for suspend",
|
|
|
1c7749 |
+ "delay",
|
|
|
1c7749 |
+ &fd_variant,
|
|
|
1c7749 |
+ priv->cancellable,
|
|
|
1c7749 |
+ &error))
|
|
|
1c7749 |
+ {
|
|
|
1c7749 |
+ g_warning ("Failed to inhibit sleep: %s", error->message);
|
|
|
1c7749 |
+ return;
|
|
|
1c7749 |
+ }
|
|
|
1c7749 |
+
|
|
|
1c7749 |
+ priv->inhibit_sleep_fd = g_variant_get_handle (fd_variant);
|
|
|
1c7749 |
+}
|
|
|
1c7749 |
+
|
|
|
1c7749 |
+static void
|
|
|
1c7749 |
+uninhibit_sleep (MetaBackend *backend)
|
|
|
1c7749 |
+{
|
|
|
1c7749 |
+ MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
1c7749 |
+
|
|
|
1c7749 |
+ close (priv->inhibit_sleep_fd);
|
|
|
1c7749 |
+ priv->inhibit_sleep_fd = -1;
|
|
|
1c7749 |
+}
|
|
|
1c7749 |
+
|
|
|
1c7749 |
static void
|
|
|
1c7749 |
prepare_for_sleep_cb (MetaBackend *backend,
|
|
|
1c7749 |
gboolean suspending)
|
|
|
1c7749 |
{
|
|
|
1c7749 |
- gboolean suspending;
|
|
|
1c7749 |
-
|
|
|
1c7749 |
- g_variant_get (parameters, "(b)", &suspending);
|
|
|
1c7749 |
- if (suspending)
|
|
|
1c7749 |
+ if (suspending) {
|
|
|
1c7749 |
+ g_signal_emit (backend, signals[SUSPENDING], 0);
|
|
|
1c7749 |
+ uninhibit_sleep (backend);
|
|
|
1c7749 |
return;
|
|
|
1c7749 |
+ }
|
|
|
1c7749 |
+
|
|
|
1c7749 |
+ inhibit_sleep (backend);
|
|
|
1c7749 |
+ g_signal_emit (backend, signals[RESUMING], 0);
|
|
|
1c7749 |
meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
|
|
|
1c7749 |
}
|
|
|
1c7749 |
|
|
|
1c7749 |
@@ -803,6 +857,7 @@ system_bus_gotten_cb (GObject *object,
|
|
|
1c7749 |
GAsyncResult *res,
|
|
|
1c7749 |
gpointer user_data)
|
|
|
1c7749 |
{
|
|
|
1c7749 |
+ MetaBackend *backend = META_BACKEND (user_data);
|
|
|
1c7749 |
MetaBackendPrivate *priv;
|
|
|
1c7749 |
g_autoptr (GError) error = NULL;
|
|
|
1c7749 |
GDBusConnection *bus;
|
|
|
1c7749 |
@@ -814,15 +869,21 @@ system_bus_gotten_cb (GObject *object,
|
|
|
1c7749 |
priv = meta_backend_get_instance_private (user_data);
|
|
|
1c7749 |
priv->system_bus = bus;
|
|
|
1c7749 |
priv->logind_proxy = get_logind_proxy (priv->cancellable, &error);
|
|
|
1c7749 |
+ priv->inhibit_sleep_fd = -1;
|
|
|
1c7749 |
|
|
|
1c7749 |
if (!priv->logind_proxy)
|
|
|
1c7749 |
- g_warning ("Failed to get logind proxy: %s", error->message);
|
|
|
1c7749 |
-
|
|
|
1c7749 |
- g_signal_connect_object (priv->logind_proxy,
|
|
|
1c7749 |
- "prepare-for-sleep",
|
|
|
1c7749 |
- G_CALLBACK (prepare_for_sleep_cb),
|
|
|
1c7749 |
- user_data,
|
|
|
1c7749 |
- G_CONNECT_SWAPPED);
|
|
|
1c7749 |
+ {
|
|
|
1c7749 |
+ g_warning ("Failed to get logind proxy: %s", error->message);
|
|
|
1c7749 |
+ }
|
|
|
1c7749 |
+ else
|
|
|
1c7749 |
+ {
|
|
|
1c7749 |
+ inhibit_sleep (backend);
|
|
|
1c7749 |
+ g_signal_connect_object (priv->logind_proxy,
|
|
|
1c7749 |
+ "prepare-for-sleep",
|
|
|
1c7749 |
+ G_CALLBACK (prepare_for_sleep_cb),
|
|
|
1c7749 |
+ user_data,
|
|
|
1c7749 |
+ G_CONNECT_SWAPPED);
|
|
|
1c7749 |
+ }
|
|
|
1c7749 |
}
|
|
|
1c7749 |
|
|
|
1c7749 |
static gboolean
|
|
|
1c7749 |
--
|
|
|
1c7749 |
2.21.0
|
|
|
1c7749 |
|