|
|
1a3082 |
From c5020c3d303ab211a970d88638e7d723034688db 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 |
---
|
|
|
1a3082 |
src/backends/meta-backend.c | 98 ++++++++++++++++++++++++++++++----
|
|
|
1a3082 |
src/org.freedesktop.login1.xml | 1 +
|
|
|
1a3082 |
2 files changed, 88 insertions(+), 11 deletions(-)
|
|
|
1c7749 |
|
|
|
1c7749 |
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
|
|
|
1a3082 |
index 5d71977c6..f59b899b7 100644
|
|
|
1c7749 |
--- a/src/backends/meta-backend.c
|
|
|
1c7749 |
+++ b/src/backends/meta-backend.c
|
|
|
1a3082 |
@@ -53,6 +53,8 @@
|
|
|
1a3082 |
|
|
|
1a3082 |
#include <stdlib.h>
|
|
|
1a3082 |
|
|
|
1a3082 |
+#include <gio/gunixfdlist.h>
|
|
|
1a3082 |
+
|
|
|
1a3082 |
#include "backends/meta-cursor-tracker-private.h"
|
|
|
1a3082 |
#include "backends/meta-idle-monitor-private.h"
|
|
|
1a3082 |
#include "backends/meta-input-settings-private.h"
|
|
|
1a3082 |
@@ -87,6 +89,8 @@ enum
|
|
|
1c7749 |
LAST_DEVICE_CHANGED,
|
|
|
1c7749 |
LID_IS_CLOSED_CHANGED,
|
|
|
1c7749 |
|
|
|
1c7749 |
+ SUSPENDING,
|
|
|
1c7749 |
+ RESUMING,
|
|
|
1c7749 |
N_SIGNALS
|
|
|
1c7749 |
};
|
|
|
1c7749 |
|
|
|
1a3082 |
@@ -745,6 +749,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;
|
|
|
1a3082 |
@@ -768,15 +786,66 @@ 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;
|
|
|
1a3082 |
+ g_autoptr (GUnixFDList) fd_list = NULL;
|
|
|
1c7749 |
+ g_autoptr (GError) error = NULL;
|
|
|
1a3082 |
+ int handle, fd;
|
|
|
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",
|
|
|
1a3082 |
+ NULL,
|
|
|
1c7749 |
+ &fd_variant,
|
|
|
1a3082 |
+ &fd_list,
|
|
|
1c7749 |
+ priv->cancellable,
|
|
|
1c7749 |
+ &error))
|
|
|
1c7749 |
+ {
|
|
|
1c7749 |
+ g_warning ("Failed to inhibit sleep: %s", error->message);
|
|
|
1c7749 |
+ return;
|
|
|
1c7749 |
+ }
|
|
|
1c7749 |
+
|
|
|
1a3082 |
+ handle = g_variant_get_handle (fd_variant);
|
|
|
1a3082 |
+ fd = g_unix_fd_list_get (fd_list, handle, &error);
|
|
|
1a3082 |
+
|
|
|
1a3082 |
+ if (fd < 0)
|
|
|
1a3082 |
+ {
|
|
|
1a3082 |
+ g_warning ("Failed to fetch sleep inhibitor fd: %s", error->message);
|
|
|
1a3082 |
+ return;
|
|
|
1a3082 |
+ }
|
|
|
1a3082 |
+
|
|
|
1a3082 |
+ priv->inhibit_sleep_fd = fd;
|
|
|
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 |
|
|
|
1a3082 |
@@ -803,6 +872,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;
|
|
|
1a3082 |
@@ -814,15 +884,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
|
|
|
1a3082 |
diff --git a/src/org.freedesktop.login1.xml b/src/org.freedesktop.login1.xml
|
|
|
1a3082 |
index 1ecfd976f..7db8f373c 100644
|
|
|
1a3082 |
--- a/src/org.freedesktop.login1.xml
|
|
|
1a3082 |
+++ b/src/org.freedesktop.login1.xml
|
|
|
1a3082 |
@@ -46,6 +46,7 @@
|
|
|
1a3082 |
|
|
|
1a3082 |
<interface name="org.freedesktop.login1.Manager">
|
|
|
1a3082 |
<method name="Inhibit">
|
|
|
1a3082 |
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
|
|
|
1a3082 |
<arg name="what" type="s" direction="in"/>
|
|
|
1a3082 |
<arg name="who" type="s" direction="in"/>
|
|
|
1a3082 |
<arg name="why" type="s" direction="in"/>
|
|
|
1c7749 |
--
|
|
|
1c7749 |
2.21.0
|
|
|
1c7749 |
|